def test_get_filter_principle_view(self, logged_in_client): AgileFactory.create_batch(12, type="value") url = reverse("agile:agile-list") resp = logged_in_client.get(url, {"type": Agile.TYPE_PRINCIPLE}) assert resp.status_code == status.HTTP_200_OK if len(resp.json()) > 0: if "type" in resp.json()[0]: assert resp.json()[0]["type"] == Agile.TYPE_PRINCIPLE
def test_patch(self, logged_in_client): """Tests patch request updates the instance.""" agile_value = AgileFactory.create(type="value") url = self.get_detail_url(agile_value.id) payload = {"description": "New Description"} resp = logged_in_client.patch(url, payload) assert resp.status_code == status.HTTP_200_OK agile_value = Agile.objects.get(id=resp.json()["id"]) assert agile_value.description == payload["description"]
def defaults(self) -> Dict[str, Dict[str, str]]: agile_fixture = AgileFactory.create() uuid_val = uuid.uuid4() data = { "name": "Responding to change over following a plan.", "description": "Circumstances change and sometimes customers demand extra.", "uuid": str(uuid_val), } return { "page": agile_fixture, "data": data, }
def test_unauthenticated_get_view(self, client): """Tests get request are allowed for unauthenticated Users.""" agile_value = AgileFactory.create(type="value") url = self.get_detail_url(agile_value.id) resp = client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_get_view(self, logged_in_client): agile_value = AgileFactory.create(type="value") url = self.get_detail_url(agile_value.id) resp = logged_in_client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_uuid_get(self, logged_in_client): agile_value = AgileFactory.create(type="value") url = self.get_detail_url(agile_value.id) resp = logged_in_client.get(url) assert resp.status_code == status.HTTP_200_OK assert validate_uuid4(resp.json()["uuid"])
def test_unauthenticated_put(self, client, defaults): """Tests post request creates a Agile instance.""" agile_value = AgileFactory.create(type="value") url = self.get_detail_url(agile_value.id) resp = client.put(url, defaults["payload"]) assert resp.status_code == status.HTTP_403_FORBIDDEN
def test_get_values(self): """Tests expected Agile type values from fixtures.""" AgileFactory.create_batch(4, type="principle") AgileFactory.create_batch(3, type="value") assert Agile.objects.get_values().count() == 3
def test_get_or_none(self): """Tests expects none.""" AgileFactory.create_batch(4) assert Agile.objects.get_or_none(id=30) is None
def test_get_or_none_found(self): """Tests expected Agile instance.""" AgileFactory.create_batch(7) assert isinstance(Agile.objects.get_or_none(id=1), Agile)