def testCreateStateChangeBadPatient(self): x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) clinicstationid = int(ret[1]["id"]) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(9999) x.setState("in") ret = x.send(timeout=30) self.assertEqual(ret[0], 404) x = DeleteClinicStation(host, port, token, clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteStation(host, port, token, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinic(host, port, token, clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)
def testGetAllStateChange(self): x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) clinicstationid = int(ret[1]["id"]) data = {} data["paternal_last"] = "abcd1234" data["maternal_last"] = "yyyyyy" data["first"] = "zzzzzzz" data["middle"] = "" data["suffix"] = "Jr." data["prefix"] = "" data["dob"] = "04/01/1962" data["gender"] = "Female" data["street1"] = "1234 First Ave" data["street2"] = "" data["city"] = "Ensenada" data["colonia"] = "" data["state"] = u"Baja California" data["phone1"] = "1-111-111-1111" data["phone2"] = "" data["email"] = "*****@*****.**" data["emergencyfullname"] = "Maria Sanchez" data["emergencyphone"] = "1-222-222-2222" data["emergencyemail"] = "*****@*****.**" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid = int(ret[1]["id"]) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("in") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) statechangeid = int(ret[1]["id"]) x = GetStateChange(host, port, token) x.setId(statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) self.assertTrue(int(ret[1]["id"]) == statechangeid) self.assertTrue(int(ret[1]["clinicstation"] == clinicstationid)) self.assertTrue(int(ret[1]["patient"] == patientid)) self.assertTrue("time" in ret[1]) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "in") # following tests assume that there is only one matching statechange # in the DB. Note these forms of the GET return vectors, not a single # object x = GetStateChange(host, port, token) x.setClinicStation(clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ret = ret[1][0] self.assertTrue("id" in ret) self.assertTrue(int(ret["id"]) == statechangeid) self.assertTrue(int(ret["clinicstation"] == clinicstationid)) self.assertTrue(int(ret["patient"] == patientid)) self.assertTrue("time" in ret) self.assertTrue("state" in ret) self.assertTrue(ret["state"] == "in") x.clearArgs() x.setClinicStation(clinicstationid) x.setPatient(patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ret = ret[1][0] self.assertTrue("id" in ret) self.assertTrue(int(ret["id"]) == statechangeid) self.assertTrue(int(ret["clinicstation"] == clinicstationid)) self.assertTrue(int(ret["patient"] == patientid)) self.assertTrue("time" in ret) self.assertTrue("state" in ret) self.assertTrue(ret["state"] == "in") x.clearArgs() x.setClinic(clinicid) x.setPatient(patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ret = ret[1][0] self.assertTrue("id" in ret) self.assertTrue(int(ret["id"]) == statechangeid) self.assertTrue(int(ret["clinicstation"] == clinicstationid)) self.assertTrue(int(ret["patient"] == patientid)) self.assertTrue("time" in ret) self.assertTrue("state" in ret) self.assertTrue(ret["state"] == "in") x.clearArgs() x.setClinic(clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ret = ret[1][0] self.assertTrue("id" in ret) self.assertTrue(int(ret["id"]) == statechangeid) self.assertTrue(int(ret["clinicstation"] == clinicstationid)) self.assertTrue(int(ret["patient"] == patientid)) self.assertTrue("time" in ret) self.assertTrue("state" in ret) self.assertTrue(ret["state"] == "in") x.clearArgs() x.setClinicStation(clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ret = ret[1][0] self.assertTrue("id" in ret) self.assertTrue(int(ret["id"]) == statechangeid) self.assertTrue(int(ret["clinicstation"] == clinicstationid)) self.assertTrue(int(ret["patient"] == patientid)) self.assertTrue("time" in ret) self.assertTrue("state" in ret) self.assertTrue(ret["state"] == "in") x = DeleteStateChange(host, port, token, statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinicStation(host, port, token, clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteStation(host, port, token, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinic(host, port, token, clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)
def testDeleteStateChange(self): # create statechange, delete, verify it is gone x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) clinicstationid = int(ret[1]["id"]) data = {} data["paternal_last"] = "abcd1234" data["maternal_last"] = "yyyyyy" data["first"] = "zzzzzzz" data["middle"] = "" data["suffix"] = "Jr." data["prefix"] = "" data["dob"] = "04/01/1962" data["gender"] = "Female" data["street1"] = "1234 First Ave" data["street2"] = "" data["city"] = "Ensenada" data["colonia"] = "" data["state"] = u"Baja California" data["phone1"] = "1-111-111-1111" data["phone2"] = "" data["email"] = "*****@*****.**" data["emergencyfullname"] = "Maria Sanchez" data["emergencyphone"] = "1-222-222-2222" data["emergencyemail"] = "*****@*****.**" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid = int(ret[1]["id"]) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("in") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) statechangeid = int(ret[1]["id"]) x = GetStateChange(host, port, token) x.setId(statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) self.assertTrue(int(ret[1]["id"]) == statechangeid) self.assertTrue(int(ret[1]["clinicstation"] == clinicstationid)) self.assertTrue(int(ret[1]["patient"] == patientid)) self.assertTrue("time" in ret[1]) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "in") x = DeleteStateChange(host, port, token, statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) # try deleting an invalid state change x = DeleteStateChange(host, port, token, statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 404) # create a few state change objects, delete them # and verify there are none in the database ids = [] x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("out") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ids.append(int(ret[1]["id"])) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("in") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ids.append(int(ret[1]["id"])) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("out") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ids.append(int(ret[1]["id"])) for x in ids: y = GetStateChange(host, port, token) y.setId(x) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) self.assertTrue(int(ret[1]["id"]) == x) for x in ids: y = DeleteStateChange(host, port, token, x) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) for x in ids: y = GetStateChange(host, port, token) y.setId(x) ret = y.send(timeout=30) self.assertEqual(ret[0], 404) x = DeleteClinicStation(host, port, token, clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteStation(host, port, token, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinic(host, port, token, clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)
def testCreateMultipleStateChange(self): x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) clinicstationid = int(ret[1]["id"]) data = {} data["paternal_last"] = "abcd1234" data["maternal_last"] = "yyyyyy" data["first"] = "zzzzzzz" data["middle"] = "" data["suffix"] = "Jr." data["prefix"] = "" data["dob"] = "04/01/1962" data["gender"] = "Female" data["street1"] = "1234 First Ave" data["street2"] = "" data["city"] = "Ensenada" data["colonia"] = "" data["state"] = u"Baja California" data["phone1"] = "1-111-111-1111" data["phone2"] = "" data["email"] = "*****@*****.**" data["emergencyfullname"] = "Maria Sanchez" data["emergencyphone"] = "1-222-222-2222" data["emergencyemail"] = "*****@*****.**" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid = int(ret[1]["id"]) x = CreateStateChange(host, port, token) x.setClinicStation(clinicstationid) x.setPatient(patientid) x.setState("in") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) statechangeid = int(ret[1]["id"]) x = GetStateChange(host, port, token) x.setId(statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) self.assertTrue(int(ret[1]["id"]) == statechangeid) self.assertTrue(int(ret[1]["clinicstation"] == clinicstationid)) self.assertTrue(int(ret[1]["patient"] == patientid)) self.assertTrue("time" in ret[1]) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "in") x = DeleteStateChange(host, port, token, statechangeid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinicStation(host, port, token, clinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteStation(host, port, token, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinic(host, port, token, clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)
def testGetAllReturnToClinicStations(self): x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) data = {} data["paternal_last"] = "abcd1234" data["maternal_last"] = "yyyyyy" data["first"] = "zzzzzzz" data["middle"] = "" data["suffix"] = "Jr." data["prefix"] = "" data["dob"] = "04/01/1962" data["gender"] = "Female" data["street1"] = "1234 First Ave" data["street2"] = "" data["city"] = "Ensenada" data["colonia"] = "" data["state"] = u"Baja California" data["phone1"] = "1-111-111-1111" data["phone2"] = "" data["email"] = "*****@*****.**" data["emergencyfullname"] = "Maria Sanchez" data["emergencyphone"] = "1-222-222-2222" data["emergencyemail"] = "*****@*****.**" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid1 = int(ret[1]["id"]) data["paternal_last"] = "bbcd1234" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid2 = int(ret[1]["id"]) data["paternal_last"] = "cbcd1234" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid3 = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid, name="test1") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) requestingclinicstationid1 = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid, name="test2") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) requestingclinicstationid2 = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid, name="test3") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) requestingclinicstationid3 = int(ret[1]["id"]) ids = [] delids = [] # 3 different patients, # 3 different requesting clinicstations = 9 combinations for aPatient in [patientid1, patientid2, patientid3]: for aRequestingClinicStation in [ requestingclinicstationid1, requestingclinicstationid2, requestingclinicstationid3 ]: x = CreateReturnToClinicStation( host, port, token, patient=aPatient, clinic=clinicid, station=stationid, requestingclinicstation=aRequestingClinicStation) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) ids.append(int(ret[1]["id"])) delids.append(int(ret[1]["id"])) x = GetReturnToClinicStation(host, port, token) x.setPatient(patientid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertEqual(len(rtcs), 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(patientid1 == int(ret[1]["patient"])) x = GetReturnToClinicStation(host, port, token) x.setPatient(patientid2) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertEqual(len(rtcs), 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(patientid2 == int(ret[1]["patient"])) x = GetReturnToClinicStation(host, port, token) x.setPatient(patientid3) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertEqual(len(rtcs), 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(patientid3 == int(ret[1]["patient"])) x = GetReturnToClinicStation(host, port, token) x.setClinic(clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertTrue(len(rtcs) == 9) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(stationid == int(ret[1]["station"])) x = GetReturnToClinicStation(host, port, token) x.setRequestingClinicStation(requestingclinicstationid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertTrue(len(rtcs) == 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(requestingclinicstationid1 == int( ret[1]["requestingclinicstation"])) x = GetReturnToClinicStation(host, port, token) x.setRequestingClinicStation(requestingclinicstationid2) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertTrue(len(rtcs) == 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(requestingclinicstationid2 == int( ret[1]["requestingclinicstation"])) x = GetReturnToClinicStation(host, port, token) x.setStation(stationid) x.setRequestingClinicStation(requestingclinicstationid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertTrue(len(rtcs) == 3) for x in rtcs: y = GetReturnToClinicStation(host, port, token) y.setId(int(x["id"])) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue(stationid == int(ret[1]["station"])) self.assertTrue(requestingclinicstationid1 == int( ret[1]["requestingclinicstation"])) x = GetReturnToClinicStation(host, port, token) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) rtcs = ret[1] self.assertTrue(len(rtcs) == 9) for x in rtcs: if x["id"] in ids: ids.remove(x["id"]) if len(ids): self.assertTrue( "failed to find all created returntoclinicstation items {}". format(ids) == None) for x in delids: y = DeleteReturnToClinicStation(host, port, token, x) ret = y.send(timeout=30) self.assertEqual(ret[0], 200) x = GetReturnToClinicStation(host, port, token) x.setPatient(patientid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 404) rtcs = ret[1] self.assertTrue(len(rtcs) == 0) x = GetReturnToClinicStation(host, port, token) x.setClinic(stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 404) rtcs = ret[1] self.assertTrue(len(rtcs) == 0) x = GetReturnToClinicStation(host, port, token) x.setRequestingClinicStation(requestingclinicstationid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 404) rtcs = ret[1] self.assertTrue(len(rtcs) == 0) x = GetReturnToClinicStation(host, port, token) x.setClinic(clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 404) rtcs = ret[1] self.assertTrue(len(rtcs) == 0) x = DeleteClinicStation(host, port, token, requestingclinicstationid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinicStation(host, port, token, requestingclinicstationid2) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinicStation(host, port, token, requestingclinicstationid3) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid1) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid2) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid3) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)
def testUpdateReturnToClinicStation(self): x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("id" in ret[1]) clinicid = int(ret[1]["id"]) x = CreateStation(host, port, token, "ENT") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) stationid = int(ret[1]["id"]) data = {} data["paternal_last"] = "abcd1234" data["maternal_last"] = "yyyyyy" data["first"] = "zzzzzzz" data["middle"] = "" data["suffix"] = "Jr." data["prefix"] = "" data["dob"] = "04/01/1962" data["gender"] = "Female" data["street1"] = "1234 First Ave" data["street2"] = "" data["city"] = "Ensenada" data["colonia"] = "" data["state"] = u"Baja California" data["phone1"] = "1-111-111-1111" data["phone2"] = "" data["email"] = "*****@*****.**" data["emergencyfullname"] = "Maria Sanchez" data["emergencyphone"] = "1-222-222-2222" data["emergencyemail"] = "*****@*****.**" x = CreatePatient(host, port, token, data) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) patientid = int(ret[1]["id"]) x = CreateClinicStation(host, port, token, clinicid, stationid, name="test2") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) requestingclinicstationid = int(ret[1]["id"]) x = CreateReturnToClinicStation( host, port, token, patient=patientid, clinic=clinicid, station=stationid, requestingclinicstation=requestingclinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) id = int(ret[1]["id"]) x = GetReturnToClinicStation(host, port, token) x.setId(id) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("clinic" in ret[1]) clinicId = int(ret[1]["clinic"]) self.assertTrue(clinicId == clinicid) self.assertTrue("station" in ret[1]) stationId = int(ret[1]["station"]) self.assertTrue(stationId == stationid) self.assertTrue("requestingclinicstation" in ret[1]) clinicstationId = int(ret[1]["requestingclinicstation"]) self.assertTrue(clinicstationId == requestingclinicstationid) x = UpdateReturnToClinicStation(host, port, token, id) x.setState("scheduled_dest") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = GetReturnToClinicStation(host, port, token) x.setId(id) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "scheduled_dest") x = UpdateReturnToClinicStation(host, port, token, id) x.setState("checked_out_dest") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = GetReturnToClinicStation(host, port, token) x.setId(id) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "checked_out_dest") x = UpdateReturnToClinicStation(host, port, token, id) x.setState("scheduled_return") ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = GetReturnToClinicStation(host, port, token) x.setId(id) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) self.assertTrue("state" in ret[1]) self.assertTrue(ret[1]["state"] == "scheduled_return") x = UpdateReturnToClinicStation(host, port, token, id) x.setState("foo") ret = x.send(timeout=30) self.assertEqual(ret[0], 400) x = UpdateReturnToClinicStation(host, port, token, id) x.setState("") ret = x.send(timeout=30) self.assertEqual(ret[0], 400) x = UpdateReturnToClinicStation(host, port, token, 9999) x.setState("scheduled_dest") ret = x.send(timeout=30) self.assertEqual(ret[0], 404) x = DeleteReturnToClinicStation(host, port, token, id) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinicStation(host, port, token, requestingclinicstationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteStation(host, port, token, stationid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeleteClinic(host, port, token, clinicid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200) x = DeletePatient(host, port, token, patientid) ret = x.send(timeout=30) self.assertEqual(ret[0], 200)