def testUpdateENTHistoryExtra(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)
        patientid = int(ret[1]["id"])

        x = CreateENTHistory(host, port, token)
        x.setPatient(patientid)
        x.setClinic(clinicid)
        x.setDrainageSide("right")
        x.setDrainageDuration("weeks")
        x.setHearingLossSide("right")
        x.setHearingLossDuration("weeks")
        x.setPainSide("right")
        x.setPainDuration("weeks")

        x.setComment("A comment")
        x.setUsername("Gomez")

        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        enthistoryid = int(ret[1]["id"])

        x = CreateENTHistoryExtra(host, port, token)
        x.setENTHistory(enthistoryid)
        x.setName("Somethingitis")
        x.setSide("left")
        x.setDuration("weeks")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        id = int(ret[1]["id"])

        x = GetENTHistoryExtra(host, port, token)
        x.setId(id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        self.assertTrue("enthistory" in ret[1])
        historyId = int(ret[1]["enthistory"])
        self.assertTrue(enthistoryid == historyId)
        self.assertTrue("name" in ret[1])
        self.assertTrue(ret[1]["name"] == "Somethingitis")
        self.assertTrue(ret[1]["side"] == "left")
        self.assertTrue(ret[1]["duration"] == "weeks")

        x = UpdateENTHistoryExtra(host, port, token, id)
        x.setSide("right")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)

        x = GetENTHistoryExtra(host, port, token)
        x.setId(id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        self.assertTrue("enthistory" in ret[1])
        historyId = int(ret[1]["enthistory"])
        self.assertTrue(enthistoryid == historyId)
        self.assertTrue("name" in ret[1])
        self.assertTrue(ret[1]["name"] == "Somethingitis")
        self.assertTrue(ret[1]["side"] == "right")

        x = UpdateENTHistoryExtra(host, port, token, id)
        x.setName("xyz")
        x.setDuration("days")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)

        x = GetENTHistoryExtra(host, port, token)
        x.setId(id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        self.assertTrue("enthistory" in ret[1])
        historyId = int(ret[1]["enthistory"])
        self.assertTrue(enthistoryid == historyId)
        self.assertTrue("name" in ret[1])
        self.assertTrue(ret[1]["name"] == "xyz")
        self.assertTrue(ret[1]["side"] == "right")
        self.assertTrue(ret[1]["duration"] == "days")

        x = UpdateENTHistoryExtra(host, port, token, None)
        x.setName("xyz")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 404)

        x = UpdateENTHistoryExtra(host, port, token, 6789)
        x.setName("xyz")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 404)

        x = UpdateENTHistoryExtra(host, port, token, "")
        x.setName("xyz")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        x = DeleteENTHistoryExtra(host, port, token, id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)

        x = DeleteENTHistory(host, port, token, enthistoryid)
        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 testGetAllENTHistoryExtra(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"] = "3abcd1234"
        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 = CreateENTHistory(host, port, token)
        x.setPatient(patientid)
        x.setClinic(clinicid)
        x.setDrainageSide("right")
        x.setDrainageDuration("weeks")
        x.setHearingLossSide("right")
        x.setHearingLossDuration("weeks")
        x.setPainSide("right")
        x.setPainDuration("weeks")

        x.setComment("A comment")
        x.setUsername("Gomez")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        enthistoryid = int(ret[1]["id"])

        delids = []

        for i in range(0, 100):
            x = CreateENTHistoryExtra(host, port, token)
            x.setENTHistory(enthistoryid)
            x.setName("name{}".format(i))
            x.setSide("both")
            x.setDuration("days")

            ret = x.send(timeout=30)
            self.assertEqual(ret[0], 200)
            delids.append(ret[1]["id"])

        x = GetENTHistoryExtra(host, port, token)
        x.setENTHistory(enthistoryid)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        rtcs = ret[1]
        self.assertTrue(len(rtcs) == 100)

        for x in delids:
            y = DeleteENTHistoryExtra(host, port, token, x)
            ret = y.send(timeout=30)
            self.assertEqual(ret[0], 200)

        x = DeleteENTHistory(host, port, token, enthistoryid)
        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)
Exemple #3
0
    def testCreateENTHistory(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)
        patientid = int(ret[1]["id"])

        x = CreateENTHistory(host, port, token)
        x.setPatient(patientid)
        x.setClinic(clinicid)
        x.setDrainageSide("right")
        x.setDrainageDuration("weeks")
        x.setHearingLossSide("right")
        x.setHearingLossDuration("weeks")
        x.setPainSide("right")
        x.setPainDuration("weeks")
        x.setComment("A comment")
        x.setUsername("Gomez")

        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)
        id = int(ret[1]["id"])
        x = GetENTHistory(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("patient" in ret[1])
        patientId = int(ret[1]["patient"])
        self.assertTrue(patientId == patientid)
        data = ret[1]

        self.assertTrue("painSide" in data)
        self.assertTrue(data["painSide"] == "right")
        self.assertTrue("painDuration" in data)
        self.assertTrue(data["painDuration"] == "weeks")
        self.assertTrue("hearingLossSide" in data)
        self.assertTrue(data["hearingLossSide"] == "right")
        self.assertTrue("hearingLossDuration" in data)
        self.assertTrue(data["hearingLossDuration"] == "weeks")
        self.assertTrue("drainageSide" in data)
        self.assertTrue(data["drainageSide"] == "right")
        self.assertTrue("drainageDuration" in data)
        self.assertTrue(data["drainageDuration"] == "weeks")
        self.assertTrue("comment" in data)
        self.assertTrue(data["comment"] == "A comment")
        self.assertTrue("username" in data)
        self.assertTrue(data["username"] == "Gomez")

        x = DeleteENTHistory(host, port, token, id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 200)

        x = GetENTHistory(host, port, token)
        x.setId(id)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 404)  # not found

        # non-existent clinic param

        x = CreateENTHistory(host, port, token)
        x.setClinic(9999)
        x.setPatient(patientid)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        # non-existent patient param

        x = CreateENTHistory(host, port, token)
        x.setClinic(clinicid)
        x.setPatient(9999)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        # no data

        x = CreateENTHistory(host, port, token)
        x.setClinic(clinicid)
        x.setPatient(patientid)
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        # invalid data

        x = CreateENTHistory(host, port, token)
        x.setClinic(clinicid)
        x.setPatient(patientid)
        x.setDrainageDuration("17")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        x.setHearingLossSide("oooo")
        x.setHearingLossDuration("weeks")
        x.setComment("A comment")
        x.setUsername("Gomez")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        x.setPainSide("left")
        x.setPainDuration("jjjj")
        x.setComment("A comment")
        x.setUsername("Gomez")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        # missing username
        x = CreateENTHistory(host, port, token)
        x.setClinic(clinicid)
        x.setPatient(patientid)
        x.setDrainageSide("right")
        x.setDrainageDuration("weeks")
        x.setHearingLossSide("right")
        x.setHearingLossDuration("weeks")
        x.setPainSide("right")
        x.setPainDuration("weeks")
        x.setComment("A comment")
        ret = x.send(timeout=30)
        self.assertEqual(ret[0], 400)

        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)