예제 #1
0
    def test_broken_links_by_email_when_no_broken_links(self):
        sysadmin = custom_factories.Sysadmin()
        extra_environ = {'REMOTE_USER': str(sysadmin["name"])}

        response = self.app.get("/ckan-admin/broken_links",
                                extra_environ=extra_environ)

        assert "This site has no broken links" in response
    def test_sysadmins_can_get_broken_links_by_email_report(self):
        sysadmin = custom_factories.Sysadmin()
        config.authorized_users = []
        context = dict(user=sysadmin["name"], model=model)

        assert custom_helpers.call_auth(
            "ckanext_deadoralive_broken_links_by_email",
            context=context) is True
예제 #3
0
    def test_broken_links_by_email(self):
        sysadmin = custom_factories.Sysadmin()
        extra_environ = {'REMOTE_USER': str(sysadmin["name"])}

        maintainer_1 = "*****@*****.**"
        dataset_1 = custom_factories.Dataset(maintainer_email=maintainer_1)
        resource_1 = custom_factories.Resource(package_id=dataset_1["id"])
        dataset_2 = custom_factories.Dataset(maintainer_email=maintainer_1)
        resource_2 = custom_factories.Resource(package_id=dataset_2["id"])

        maintainer_2 = "*****@*****.**"
        dataset_3 = custom_factories.Dataset(maintainer_email=maintainer_2)
        resource_3 = custom_factories.Resource(package_id=dataset_3["id"])
        resource_4 = custom_factories.Resource(package_id=dataset_3["id"])

        maintainer_3 = "*****@*****.**"
        dataset_4 = custom_factories.Dataset(maintainer_email=maintainer_3)
        resource_5 = custom_factories.Resource(package_id=dataset_4["id"])
        dataset_5 = custom_factories.Dataset(maintainer_email=maintainer_3)
        resource_6 = custom_factories.Resource(package_id=dataset_5["id"])
        resource_7 = custom_factories.Resource(package_id=dataset_5["id"])
        resource_8 = custom_factories.Resource(package_id=dataset_5["id"])

        custom_helpers.make_broken((resource_1, resource_3, resource_4,
                                    resource_5, resource_6, resource_7),
                                   user=sysadmin)
        custom_helpers.make_working((resource_2, resource_8), user=sysadmin)

        response = self.app.get("/ckan-admin/broken_links",
                                extra_environ=extra_environ)

        assert maintainer_1 in response
        assert maintainer_2 in response
        assert maintainer_3 in response
        assert dataset_1["name"] in response
        assert dataset_2["name"] not in response
        assert dataset_3["name"] in response
        assert dataset_4["name"] in response
        assert dataset_5["name"] in response
예제 #4
0
    def test_broken_links_by_email_with_unicode(self):
        sysadmin = custom_factories.Sysadmin()
        extra_environ = {'REMOTE_USER': str(sysadmin["name"])}
        maintainer = u"Mäintainer"
        maintainer_email = u"mä[email protected]"
        author = u"Aüthör"
        author_email = u"aüthö[email protected]"
        dataset_1 = custom_factories.Dataset(title=u"Test Dätaßet",
                                             maintainer=maintainer,
                                             maintainer_email=maintainer_email)
        dataset_2 = custom_factories.Dataset(title=u"Test Dätaßet",
                                             author=author,
                                             author_email=author_email)
        resource_1 = custom_factories.Resource(package_id=dataset_1["id"],
                                               name=u"Test Rësourße",
                                               url=u"http://bröken_link")
        resource_2 = custom_factories.Resource(package_id=dataset_2["id"],
                                               name=u"Test Rësourße",
                                               url=u"http://bröken_link")

        custom_helpers.make_broken((resource_1, resource_2), user=sysadmin)

        self.app.get("/ckan-admin/broken_links", extra_environ=extra_environ)