def test_should_return_token_for_valid_email(self): # Given # A valid email address # email = "*****@*****.**" # email = "*****@*****.**" email = "*****@*****.**" # email = "*****@*****.**" password = "******" # When # We try to authenticate with the email address response = self.app.post("/login", data=dumps({ "email": email, "password": password }), content_type="application/json") # Then # We should get a response containing "reporting_units" in the data and the updated token. self.assertEqual(response.status_code, ok) string = response.data.decode() json = loads(string) self.assertTrue("token" in json) self.assertTrue("respondent_id" in get_json(json["token"]))
def test_should_return_reporting_units_for_valid_token(self): # Given # A valid token and an expected association token = encode({"respondent_id": "101"}) # When # We try to get reporting units with the token response = self.app.get("/reporting_units", headers={"token": token}) # Then # We should get a response containing "reporting_units" in the data and the updated token. self.assertEqual(response.status_code, ok) string = response.data.decode() json = loads(string) self.assertTrue("data" in json) self.assertTrue("reporting_units" in json["data"]) self.assertTrue("token" in json) self.assertTrue("reporting_units" in get_json(json["token"])) print(json)
def test_should_return_token_for_valid_access_code(self): # Given # A valid internet access code access_code = "abc123" # access_code= "def456" # access_code= "ghi789" # When # We try to authenticate with the code response = self.app.post("/code", data=dumps({"code": access_code}), content_type="application/json") # Then # We should get a response containing "reporting_units" in the data and the updated token. self.assertEqual(response.status_code, ok) string = response.data.decode() json = loads(string) self.assertTrue("token" in json) self.assertTrue("response_id" in get_json(json["token"]))