Exemplo n.º 1
0
 def test_retrieve(self):
     table_name = 'password_db'
     table_model = DataModel(table_name, PasswordData)
     table_model.new_table()
     vo1 = PasswordData("your", "your_password")
     vo2 = PasswordData("me", "hello")
     vo3 = PasswordData("Jack", "lsjdf23dfs")
     table_model.create(vo1)
     table_model.create(vo2)
     table_model.create(vo3)
     res = table_model.retrieve("name", "Jack")
     obj = PasswordData("Jack", "lsjdf23dfs")
     self.assertEqual(res, obj)
     res = table_model.retrieve("name", "not_this_name")
     self.assertEqual(res, None)
     os.remove("./password_db.db")
Exemplo n.º 2
0
 def test_create_batch_and_retrieve_limit(self):
     table_name = 'password_db'
     table_model = DataModel(table_name, PasswordData)
     table_model.new_table()
     l = []
     for x in range(0, 5):
         l.append(PasswordData('111' + str(x), '222'))
     table_model.create_batch(l)
     self.assertEqual(table_model.retrieve("name", "1110"), PasswordData('1110', '222'))
     self.assertEqual(table_model.retrieve("name", "1114"), PasswordData('1114', '222'))
     self.assertEqual(len(table_model.retrieve_limit(1, 3)), 3)
     os.remove("./password_db.db")