Ejemplo n.º 1
0
 def test_time_to_live_property(self, dir):
     ''' testing the time to live property for the input data '''
     print('testing time to live function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test1 = {"a": {"test1": "data1"}}
     obj.create(test1, 5)  #5 seconds is provided
     time.sleep(5)
     with self.assertRaises(Exception):
         obj.read("a")
Ejemplo n.º 2
0
 def test_multiple_input_create_fun(self, dir):
     ''' testing create func with multiple inputs '''
     print('testing multiple input for create function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test1 = {"a": {"test1": "data1"}}
     obj.create(test1)
     compare(test1, json.loads(dir.read('test.txt')))
     test2 = {"b": {"test2": "data2"}}
     obj.create(test2)
     test1.update(test2)
     compare(test1, json.loads(dir.read('test.txt')))
Ejemplo n.º 3
0
 def test_read_fun(self, dir):
     ''' checking the wheather proper response is obtained from the 
     read method of src.py
     '''
     print('testing read function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test = {"a": {"test": "data"}}
     obj.create(test)
     self.assertEqual(obj.read('a'), test['a'])
     with self.assertRaises(Exception):
         obj.read("b")
Ejemplo n.º 4
0
 def test_delete_fun(self, dir):
     '''checking wheather delete operation is performed by delete method 
     with proper key value
     '''
     print('testing read function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test = {"a": {"test": "data"}}
     obj.create(test)
     obj.delete("a")
     compare({}, json.loads(dir.read('test.txt')))
     with self.assertRaises(Exception):
         obj.delete("b")
Ejemplo n.º 5
0
 def test_buisness_marks(self, dir):
     ''' testing buisness marks '''
     print('testing create function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test = {"a": {"test": "data"}}
     obj.create(test)
     with self.assertRaises(Exception):
         obj.create({'error': 'vaue is not of json'})
         obj.create({'a b1': {'error': 'key is not of type string'}})
         obj.create({
             'keyLengthGreaterThanThirtyTwoCharacter': {
                 'error': 'key size error'
             }
         })
         obj.create({'a': {'error': 'key is not unique'}})
Ejemplo n.º 6
0
 def test_single_input_create_fun(self, dir):
     ''' testing create func with single input '''
     print('testing create function')
     path = os.path.join(dir.path, 'test.txt')
     obj = KeyValueDataSet(path)
     test = {"a": {"test": "data"}}
     obj.create(test)
     compare(test, json.loads(dir.read('test.txt')))
     with self.assertRaises(Exception):
         obj.create({'error': 'vaue is not of json'})
         obj.create({'a b1': {'error': 'key is not of type string'}})
         obj.create({
             'keyLengthGreaterThanThirtyTwoCharacter': {
                 'error': 'key size error'
             }
         })
         obj.create({'a': {'error': 'key is not unique'}})