Exemplo n.º 1
0
    def test_organization_with_no_broken_links(self):

        def organization_list(context=None, data_dict=None):
            return [{
                "name": "test_org",
                "image_display_url": "",
                "description": "",
                "packages": "",
            }]

        def all_results():
            now = datetime.datetime.now().isoformat()
            results = []
            for i in range(1, 10):
                results.append({
                    "resource_id": "test_resource_{0}".format(i),
                    "alive": True,
                    "last_checked": now,
                    "last_successful": now,
                    "num_fails": 0,
                    "pending": False,
                    "pending_since": None,
                    "status": None,
                    "reason": None,
                })
            return results

        def package_search(*args, **kwargs):
            return [
                {"name": "test_dataset_1",
                 "resources": [
                     {"id": "test_resource_1"},
                     {"id": "test_resource_2"},
                     {"id": "test_resource_3"}
                 ]},
                {"name": "test_dataset_2",
                 "resources": [
                     {"id": "test_resource_4"},
                     {"id": "test_resource_5"},
                     {"id": "test_resource_6"}
                 ]},
                {"name": "test_dataset_3",
                 "resources": [
                     {"id": "test_resource_7"},
                     {"id": "test_resource_8"},
                     {"id": "test_resource_9"}
                 ]}
            ]

        report = get._broken_links_by_organization(
            None, organization_list, all_results, package_search)

        assert report == []
Exemplo n.º 2
0
    def test_when_there_are_no_organizations(self):

        def organization_list(context=None, data_dict=None):
            return []

        def all_results():
            return []

        def package_search(*args, **kwargs):
            return []

        report = get._broken_links_by_organization(
            None, organization_list, all_results, package_search)

        assert report == []
Exemplo n.º 3
0
    def test_with_org_with_no_datasets(self):

        def organization_list(context=None, data_dict=None):
            return [{
                "name": "test_org",
                "image_display_url": "",
                "description": "",
                "packages": "",
            }]

        def all_results():
            return []

        def package_search(*args, **kwargs):
            return []

        report = get._broken_links_by_organization(
            None, organization_list, all_results, package_search)

        assert report == [], ("Organizations with no broken datasets should "
                              "not be listed in the report.")
Exemplo n.º 4
0
    def test_with_dataset_with_no_resources(self):

        def organization_list(context=None, data_dict=None):
            return [{
                "name": "test_org",
                "image_display_url": "",
                "description": "",
                "packages": "",
            }]

        def all_results():
            return []

        def package_search(*args, **kwargs):
            return [
                {"name": "test_dataset",
                 "resources": [],
                 },
            ]

        report = get._broken_links_by_organization(
            None, organization_list, all_results, package_search)

        assert report == []