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 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 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 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 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 testResetExistSidResponse(self): register(1, "sid-1") resp = resetSid("sid-1") self.assertEqual(resp["success"], "true")
def testRegisterFailedDatabase(self): register(1, "sid-1") register(1, "sid-1") resp = query("sid-1") self.assertEqual(len(resp["data"]), 1)
def testRegisterFailedResponse(self): resp = register(1, "sid-1") self.assertEqual(resp["success"], "true") resp = register(1, "sid-1") self.assertEqual(resp["success"], "false")
def testRegisterSuccessResponse(self): resp = register(1, "sid-1") self.assertEqual(resp["success"], "true")
def testUnregisterSuccessfulResponse(self): register(1, "sid-1") resp = unregister("sid-1", "name-1") self.assertEqual(resp["success"], "true")