示例#1
0
def create_and_run_thread(no_threads):
    d = DataStore.connect()
    threads = [
        threading.Thread(target=thread_function, args=(str(i), d))
        for i in range(no_threads)
    ]
    for t in threads:
        t.start()
        t.join()
示例#2
0
 def test_key_capping(self):
     d = DataStore.connect(self._file_path)
     k, v = "".join(["k" for _ in range(36)]), "Key capped at 36 chars"
     d.create(k, v)
     self.assertEqual(d.read(k[:30] + ".."), v,
                      "The key is not capped at 36 chars")
示例#3
0
 def test_time_to_live(self):
     d = DataStore.connect()
     k, v = "timeToLive", "5sec"
     d.create(k, v, time_to_live=1)
     time.sleep(2)
     self.assertRaises(KeyNotFoundException, d.read, k)
示例#4
0
 def test_default_file_create(self):
     d = DataStore.connect()
     self.assertTrue(d._file_path,
                     "Default DataStore file connection doesn't work")
示例#5
0
 def test_delete(self):
     d = DataStore.connect(self._file_path)
     k, v = "delete", "create to delete"
     d.create(k, v)
     self.assertEqual(d.delete(k), v, "Delete operation doesn't work")
示例#6
0
 def test_read(self):
     d = DataStore.connect(self._file_path)
     k, v = "created", datetime.date.today().strftime("%d/%m/%Y")
     self.assertTrue(self.read_check(d, k, v), "Key is not found")
示例#7
0
 def test_create(self):
     d = DataStore.connect(self._file_path)
     k, v = "dict", {"name": "Johnitto Francis", "rollno": 1234}
     d.create(k, v)
     self.assertTrue(self.read_check(d, k, v),
                     "Key is not created properly")
示例#8
0
 def test_connect(self):
     d = DataStore.connect(self._file_path)
     self.assertTrue(os.path.exists(self._file_path),
                     "DataStore file connection doesn't work")