mirror of https://github.com/snachodog/mybuddy.git
add tests
This commit is contained in:
parent
807ba37de8
commit
8e180082dc
52
api/tests.py
52
api/tests.py
|
@ -215,6 +215,24 @@ class DiaperChangeAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
||||||
self.assertEqual(obj.amount, data["amount"])
|
self.assertEqual(obj.amount, data["amount"])
|
||||||
self.assertEqual(obj.notes, data["notes"])
|
self.assertEqual(obj.notes, data["notes"])
|
||||||
|
|
||||||
|
def test_post_null_time(self):
|
||||||
|
data = {
|
||||||
|
"child": 1,
|
||||||
|
"wet": False,
|
||||||
|
"solid": True,
|
||||||
|
"color": "black",
|
||||||
|
"amount": 3,
|
||||||
|
"notes": "noxious",
|
||||||
|
}
|
||||||
|
response = self.client.post(self.endpoint, data, format="json")
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
obj = models.DiaperChange.objects.get(pk=response.data["id"])
|
||||||
|
self.assertFalse(obj.wet)
|
||||||
|
self.assertTrue(obj.solid)
|
||||||
|
self.assertEqual(obj.color, data["color"])
|
||||||
|
self.assertEqual(obj.amount, data["amount"])
|
||||||
|
self.assertEqual(obj.notes, data["notes"])
|
||||||
|
|
||||||
def test_patch(self):
|
def test_patch(self):
|
||||||
endpoint = "{}{}/".format(self.endpoint, 3)
|
endpoint = "{}{}/".format(self.endpoint, 3)
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint)
|
||||||
|
@ -332,6 +350,16 @@ class NoteAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
||||||
obj = models.Note.objects.get(pk=response.data["id"])
|
obj = models.Note.objects.get(pk=response.data["id"])
|
||||||
self.assertEqual(obj.note, data["note"])
|
self.assertEqual(obj.note, data["note"])
|
||||||
|
|
||||||
|
def test_post_null_time(self):
|
||||||
|
data = {
|
||||||
|
"child": 1,
|
||||||
|
"note": "Another fake note.",
|
||||||
|
}
|
||||||
|
response = self.client.post(self.endpoint, data, format="json")
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
obj = models.Note.objects.get(pk=response.data["id"])
|
||||||
|
self.assertEqual(obj.note, data["note"])
|
||||||
|
|
||||||
def test_patch(self):
|
def test_patch(self):
|
||||||
endpoint = "{}{}/".format(self.endpoint, 1)
|
endpoint = "{}{}/".format(self.endpoint, 1)
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint)
|
||||||
|
@ -433,6 +461,18 @@ class TemperatureAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
||||||
self.assertEqual(str(obj.temperature), data["temperature"])
|
self.assertEqual(str(obj.temperature), data["temperature"])
|
||||||
self.assertEqual(obj.notes, data["notes"])
|
self.assertEqual(obj.notes, data["notes"])
|
||||||
|
|
||||||
|
def test_post_null_time(self):
|
||||||
|
data = {
|
||||||
|
"child": 1,
|
||||||
|
"temperature": "100.5",
|
||||||
|
"notes": "temporal",
|
||||||
|
}
|
||||||
|
response = self.client.post(self.endpoint, data, format="json")
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
obj = models.Temperature.objects.get(pk=response.data["id"])
|
||||||
|
self.assertEqual(str(obj.temperature), data["temperature"])
|
||||||
|
self.assertEqual(obj.notes, data["notes"])
|
||||||
|
|
||||||
def test_patch(self):
|
def test_patch(self):
|
||||||
endpoint = "{}{}/".format(self.endpoint, 1)
|
endpoint = "{}{}/".format(self.endpoint, 1)
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint)
|
||||||
|
@ -602,6 +642,18 @@ class WeightAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
|
||||||
self.assertEqual(str(obj.weight), data["weight"])
|
self.assertEqual(str(obj.weight), data["weight"])
|
||||||
self.assertEqual(str(obj.notes), data["notes"])
|
self.assertEqual(str(obj.notes), data["notes"])
|
||||||
|
|
||||||
|
def test_post_null_date(self):
|
||||||
|
data = {
|
||||||
|
"child": 1,
|
||||||
|
"weight": "12.25",
|
||||||
|
"notes": "with diaper at peds",
|
||||||
|
}
|
||||||
|
response = self.client.post(self.endpoint, data, format="json")
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
obj = models.Weight.objects.get(pk=response.data["id"])
|
||||||
|
self.assertEqual(str(obj.weight), data["weight"])
|
||||||
|
self.assertEqual(str(obj.notes), data["notes"])
|
||||||
|
|
||||||
def test_patch(self):
|
def test_patch(self):
|
||||||
endpoint = "{}{}/".format(self.endpoint, 2)
|
endpoint = "{}{}/".format(self.endpoint, 2)
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint)
|
||||||
|
|
Loading…
Reference in New Issue