def test_doctor_same_hospital_get_admin_info(self): response = self.client.post( "/doctors", { "email": "*****@*****.**", "password": "******", "first_name": "Vasco", "last_name": "Ramos", "birth_date": "2020-03-04" }) self.assertEqual(response.status_code, HTTP_201_CREATED) login(self.client, "*****@*****.**", "pwd") response = self.client.get("/admins/[email protected]") self.assertEqual(response.status_code, HTTP_403_FORBIDDEN)
def setUp(self): response = self.client.post( "/clients", { "email": "*****@*****.**", "password": "******", "first_name": "Vasco", "last_name": "Ramos", "height": 1.60, "weight_goal": 65, "current_weight": 90, "sex": "Male", "birth_date": "2020-03-04" }) self.assertEqual(response.status_code, HTTP_201_CREATED) login(self.client, "*****@*****.**", "pwd")
def test_get_client_info_other_client(self): response = self.client.post( "/clients", { "email": "*****@*****.**", "password": "******", "first_name": "Tomas", "last_name": "Ramos", "height": 1.60, "weight_goal": 65, "current_weight": 90, "sex": "Male", "birth_date": "2020-03-04" }) self.assertEqual(response.status_code, HTTP_201_CREATED) login(self.client, "*****@*****.**", "pwd") response = self.client.get("/clients/[email protected]") self.assertEqual(response.status_code, HTTP_403_FORBIDDEN)
def test_get_client_info_client_doctor(self): Client.objects.filter(user__auth_user__username="******").update( doctor=self.doctor) login(self.client, "*****@*****.**", "pwd") response = self.client.get("/clients/[email protected]") self.assertEqual(response.status_code, HTTP_200_OK)
def test_get_client_self_info(self): login(self.client, "*****@*****.**", "pwd") response = self.client.get("/clients/[email protected]") self.assertEqual(response.status_code, HTTP_200_OK)
def test_get_client_info_client_no_doctor(self): login(self.client, "*****@*****.**", "pwd") response = self.client.get("/clients/[email protected]") self.assertEqual(response.status_code, HTTP_403_FORBIDDEN)