Ejemplo n.º 1
0
	def test_find(self):
		
		testDataContent = [
		  '648:abcdefghi',
		  '517:QjhWkizN5t',
		  '323:dwcIY99gTN1',
		  '653:UlfY2UvMfeuX'
		]
		data1 = DAO(testDataContent)

		found = data1.find('abcdefghi')
		assert found.tasktime == '648' and found.taskstring == 'abcdefghi'

		notFound = data1.find('nonexistent')
		assert notFound is None
Ejemplo n.º 2
0
	def test_remove_entry(self):

		testDataContent = [
		  '648:abcdefghi',
		  '517:QjhWkizN5t',
		  '323:dwcIY99gTN1',
		  '653:UlfY2UvMfeuX'
		]
		data1 = DAO(testDataContent)
		assert data1.find('abcdefghi')

		data1.remove_entry('abcdefghi')
		assert data1.find('abcdefghi') is None

		with pytest.raises(Exception):
			data1.remove_entry('abcdefghi')
Ejemplo n.º 3
0
 def get(self):
     '''
     return all the certs
     '''
     cert_col = DAO().get_collection("certificates")
     certs = cert_col.find({}, {'_id': 0})
     return list(certs)
Ejemplo n.º 4
0
	def test_add_entry(self):

		data1 = DAO([])
		assert data1.is_empty()

		data1.add_entry('648', 'abcdefghi')

		assert not data1.is_empty()

		found = data1.find('abcdefghi')
		assert found.tasktime == '648' and found.taskstring == 'abcdefghi'

		with pytest.raises(Exception):
			data1.add_entry('648', 'abcdefghi')
			data1.add_entry('000', 'abcdefghi')
Ejemplo n.º 5
0
	def test_advance_time(self):

		testDataContent = [
		  '648:abcdefghi',
		  '517:QjhWkizN5t',
		  '323:dwcIY99gTN1',
		  '653:UlfY2UvMfeuX'
		]
		data1 = DAO(testDataContent)

		with pytest.raises(Exception):
			data1.advance_time('nonexistent', '30')

		data1.advance_time('abcdefghi', '30')

		assert data1.find('abcdefghi').tasktime == '678'