Exemplo n.º 1
0
    def test_context_url_not_found(self, client):
        entity = "http://www.example.com"
        project = factories.ProjectFactory()
        response = client.get(reverse("url_listing", args=[project.project_slug, entity]))
        expected_context = {
            "project": project,
            "form": views.URLForm({"url_value": entity}),
            "url_not_found": True,
            "metadata_vals": views.get_metadata(project),
            "form_errors": None,
            "summary_list": None,
            "json_data": None,
            "form_types": None,
            "institutions": views.get_look_ahead(project),
            "url_entity": entity,
        }

        for key in expected_context:
            assert str(response.context[key]) == str(expected_context[key])
Exemplo n.º 2
0
    def test_base_context_values(self, client):
        entity = u"http://www.example.com"
        entity_surt = u"http://(com,example,www,)"
        project = factories.ProjectFactory()
        project_metadata = factories.ProjectMetadataFactory(project=project)
        url = factories.URLFactory(url_project=project, entity=entity)
        factories.SURTFactory(url_project=project, entity=entity, value=entity_surt)
        related_urls = factories.SURTFactory.create_batch(
            1, url_project=project, entity=u"{0}/main/page".format(entity), value=u"{0}/main/page".format(entity_surt)
        )
        expected_context = {
            "project": project,
            "url_data": views.create_url_list(project, related_urls + [url]),
            "related_url_list": related_urls,
            "metadata_vals": views.get_metadata(project),
            "institutions": views.get_look_ahead(project),
            "form_types": json.dumps({project_metadata.metadata.name: project_metadata.form_type}),
        }
        response = client.get(reverse("url_listing", args=[project.project_slug, entity]))

        for key in expected_context:
            assert str(response.context[key]) == str(expected_context[key])