def testRegisterIn2SidWithSameName(self): register(1, "sid-1") register(1, "sid-2") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1) resp = query("sid-2") self.assertEqual(len(resp["data"]), 1)
def testUnregisterSuccessfulDatabase(self): register(1, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1) unregister("sid-1", "name-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 0)
def testResetNotEmptySid(self): register(1, "sid-1") register(2, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 2) resetSid("sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 0)
def testRegisterAndQuery(self): register(1, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1) exitServer() time.sleep(0.5) resp = query("sid-1") self.assertEqual(resp["data"], {"name-1": "value-1"})
def testRegisterPersistence(self): register(1, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1) exitServer() time.sleep(0.5) resp = query("sid-1") self.assertEqual(len(resp["data"]), 1)
def testUnregisterPersistence(self): register(1, "sid-1") register(2, "sid-1") register(3, "sid-1") unregister("sid-1", "name-2") resp = query("sid-1") self.assertEqual(len(resp["data"]), 2) exitServer() time.sleep(0.5) resp = query("sid-1") self.assertEqual(len(resp["data"]), 2)
def testNotEmptySidResponse(self): register(1, "sid-1") register(2, "sid-1") resp = query("sid-1") self.assertEqual(resp, { "success": "true", "data": { "name-1": "value-1", "name-2": "value-2" } })
def testRegisterFailedDatabase(self): register(1, "sid-1") register(1, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1)
def testQueryEmptySid(self): resp = query("sid-1") self.assertEqual(len(resp["data"]), 0)
def testQueryNotExistSid(self): resp = query("sid-13030708") self.assertEqual(len(resp["data"]), 0)