def test_add_state_twice_doesnt_duplicate(self, get_data): """.""" req = self.request_builder.post("/foo", {"state": "NY"}) req.user = self.auth_user add_state(req) count1 = Consequence.objects.filter(state='NY').count() add_state(req) count2 = Consequence.objects.filter(state='NY').count() self.assertEqual(count1, count2)
def test_add_state_post_good_abbr_has_url(self, get_data): """.""" req = self.request_builder.post("/foo", {"state": "NY"}) req.user = self.auth_user response = add_state(req) self.assertTrue("https://niccc" in str(response.content))
def test_add_state_post_good_abbr_succeeds(self, get_data): """.""" req = self.request_builder.post("/foo", {"state": "NY"}) req.user = self.auth_user response = add_state(req) self.assertTrue("success" in str(response.content))
def test_add_state_post_bad_abbr_fails(self): """.""" req = self.request_builder.post("/foo", {"state": "WAT"}) req.user = self.auth_user response = add_state(req) self.assertTrue("unable" in str(response.content))
def test_add_state_get_is_200(self): """.""" req = self.request_builder.get("/foo") req.user = self.auth_user response = add_state(req) self.assertTrue(response.status_code == 200)