Пример #1
0
    def setup_class(self):
        super(TestOnsLoadMissingDept, self).setup_class()

        try:
            self.orig_pkg_dict = {
                 "name": u"measuring_subjective_wellbeing_in_the_uk",
                 "title": "Measuring Subjective Wellbeing in the UK",
                 "notes": "This report reviews:\n\nWhat is subjective wellbeing and why should we measure it?\n\nHow subjective wellbeing is currently measured in the UK - what subjective wellbeing questions are already being asked on major social surveys in the UK\n\nThe potential uses of subjective wellbeing data collected via these surveys\n\n\nIt concludes that subjective wellbeing is a valid construct that can be measured reliably. This is the first output of ONS' work on subjective wellbeing.\n\nSource agency: Office for National Statistics\n\nDesignation: Supporting material\n\nLanguage: English\n\nAlternative title: Working Paper: Measuring Subjective Wellbeing in the UK",
                 "license_id": "ukcrown-withrights",
                 "tags": ["communities", "health-well-being-and-care", "people-and-places", "societal-wellbeing", "subjective-wellbeing-subjective-well-being-objective-measures-subjective-measures", "well-being"],
                 "groups": ['office-for-national-statistics'],
                 "extras": {"geographic_coverage": "111100: United Kingdom (England, Scotland, Wales, Northern Ireland)", "geographic_granularity": "UK and GB", "external_reference": "ONSHUB", "temporal_granularity": "", "date_updated": "", "precision": "", "temporal_coverage_to": "", "temporal_coverage_from": "", "national_statistic": "no", "import_source": "ONS-ons_data_7_days_to_2010-09-17", "update_frequency": "", "date_released": "2010-09-14", "categories": "People and Places"},
                "resources": [{"url": "http://www.ons.gov.uk/about-statistics/measuring-equality/wellbeing/news-and-events/index.html", "format": "", "description": "2010", "extras":{"hub-id":"77-31166"}}],
                 }
            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(5), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            loader = OnsLoader(self.testclient)
            self.res = loader.load_package(self.pkg_dict)
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #2
0
    def setup_class(self):
        super(TestOnsLoadMissingDept, self).setup_class()

        try:
            self.orig_pkg_dict = {
                 "name": u"measuring_subjective_wellbeing_in_the_uk",
                 "title": "Measuring Subjective Wellbeing in the UK",
                 "notes": "This report reviews:\n\nWhat is subjective wellbeing and why should we measure it?\n\nHow subjective wellbeing is currently measured in the UK - what subjective wellbeing questions are already being asked on major social surveys in the UK\n\nThe potential uses of subjective wellbeing data collected via these surveys\n\n\nIt concludes that subjective wellbeing is a valid construct that can be measured reliably. This is the first output of ONS' work on subjective wellbeing.\n\nSource agency: Office for National Statistics\n\nDesignation: Supporting material\n\nLanguage: English\n\nAlternative title: Working Paper: Measuring Subjective Wellbeing in the UK",
                 "license_id": "ukcrown-withrights",
                 "tags": ["communities", "health-well-being-and-care", "people-and-places", "societal-wellbeing", "subjective-wellbeing-subjective-well-being-objective-measures-subjective-measures", "well-being"],
                 "groups": ['office-for-national-statistics'],
                 "extras": {"geographic_coverage": "111100: United Kingdom (England, Scotland, Wales, Northern Ireland)", "geographic_granularity": "UK and GB", "external_reference": "ONSHUB", "temporal_granularity": "", "date_updated": "", "precision": "", "temporal_coverage_to": "", "temporal_coverage_from": "", "national_statistic": "no", "import_source": "ONS-ons_data_7_days_to_2010-09-17", "update_frequency": "", "date_released": "2010-09-14", "categories": "People and Places"},
                "resources": [{"url": "http://www.ons.gov.uk/about-statistics/measuring-equality/wellbeing/news-and-events/index.html", "format": "", "description": "2010", "extras":{"hub-id":"77-31166"}}],
                 }
            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(5), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            loader = OnsLoader(self.testclient)
            self.res = loader.load_package(self.pkg_dict)
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #3
0
    def setup_class(self):
        super(TestAgencyFind, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"national_child_measurement_programme",
                "title": "National Child Measurement Programme",
                "version": None, "url": None, "author": None, "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "The National Child Measurement Programme weighs and measures primary school children.\r\nThis publication was formerly announced as \"National Child Measurement Programme - Statistics on Child Obesity 2008-09\" but the title has been amended to reflect suggestions from the UKSA Assessments Board.\r\nSource agency: Information Centre for Health and Social Care\r\nDesignation: National Statistics\r\nLanguage: English\r\nAlternative title: National Child Measurement Programme",
                "license_id": "uk-ogl",
                "tags": ["health", "health-and-social-care", "health-of-the-population", "lifestyles-and-behaviours", "nhs", "well-being-and-care"],
                "groups": ['nhs-information-centre-for-health-and-social-care'],
                "extras": {
                    "geographic_coverage": "100000: England",
                    "geographic_granularity": "Country",
                    "external_reference": "ONSHUB",
                    "temporal_coverage-from": "",
                    "temporal_granularity": "",
                    "date_updated": "",
                    "precision": "",
                    "geographic_granularity": "",
                    "temporal_coverage_to": "",
                    "temporal_coverage_from": "",
                    "taxonomy_url": "",
                    "import_source": "ONS-ons_data_2009-12",
                    "date_released": "2009-12-10",
                    "temporal_coverage-to": "",
                    "update_frequency": "",
                    "national_statistic": "yes",
                    "categories": "Health and Social Care"},
                "resources": [{"url": "http://www.ic.nhs.uk/ncmp", "format": "", "description": "England, 2008/09 School Year", "extras":{"hub-id":"119-37085", "publish-date":"2008-01-01"}},
                              {"url": "http://www.dh.gov.uk/en/Publichealth/Healthimprovement/Healthyliving/DH_073787", "format": "", "description": "2008", "extras":{"hub-id":"119-31792", "publish-date":"2007-01-01"}},
                              {"url": "http://www.ic.nhs.uk/ncmp", "format": "", "description": "Statistics on child obesity 2007-08", "extras":{"hub-id":"119-31784", "publish-date":"2009-01-01"}}],
                }

            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(8), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            assert self.pkg_dict['groups'][0].startswith('nhs-information')
            loader = OnsLoader(self.testclient)
            print self.pkg_dict
            # load package twice, to ensure reload works too
            self.res = loader.load_package(self.pkg_dict)
            self.res = loader.load_package(self.pkg_dict)
            self.name = self.orig_pkg_dict['name']
            self.num_resources_originally = len(self.orig_pkg_dict['resources'])
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #4
0
    def setup_class(self):
        super(TestAgencyFind, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"national_child_measurement_programme",
                "title": "National Child Measurement Programme",
                "version": None, "url": None, "author": None, "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "The National Child Measurement Programme weighs and measures primary school children.\r\nThis publication was formerly announced as \"National Child Measurement Programme - Statistics on Child Obesity 2008-09\" but the title has been amended to reflect suggestions from the UKSA Assessments Board.\r\nSource agency: Information Centre for Health and Social Care\r\nDesignation: National Statistics\r\nLanguage: English\r\nAlternative title: National Child Measurement Programme",
                "license_id": "uk-ogl",
                "tags": ["health", "health-and-social-care", "health-of-the-population", "lifestyles-and-behaviours", "nhs", "well-being-and-care"],
                "groups": ['nhs-information-centre-for-health-and-social-care'],
                "extras": {
                    "geographic_coverage": "100000: England",
                    "geographic_granularity": "Country",
                    "external_reference": "ONSHUB",
                    "temporal_coverage-from": "",
                    "temporal_granularity": "",
                    "date_updated": "",
                    "precision": "",
                    "geographic_granularity": "",
                    "temporal_coverage_to": "",
                    "temporal_coverage_from": "",
                    "taxonomy_url": "",
                    "import_source": "ONS-ons_data_2009-12",
                    "date_released": "2009-12-10",
                    "temporal_coverage-to": "",
                    "update_frequency": "",
                    "national_statistic": "yes",
                    "categories": "Health and Social Care"},
                "resources": [{"url": "http://www.ic.nhs.uk/ncmp", "format": "", "description": "England, 2008/09 School Year", "extras":{"hub-id":"119-37085", "publish-date":"2008-01-01"}},
                              {"url": "http://www.dh.gov.uk/en/Publichealth/Healthimprovement/Healthyliving/DH_073787", "format": "", "description": "2008", "extras":{"hub-id":"119-31792", "publish-date":"2007-01-01"}},
                              {"url": "http://www.ic.nhs.uk/ncmp", "format": "", "description": "Statistics on child obesity 2007-08", "extras":{"hub-id":"119-31784", "publish-date":"2009-01-01"}}],
                }

            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(8), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            assert self.pkg_dict['groups'][0].startswith('nhs-information')
            loader = OnsLoader(self.testclient)
            print self.pkg_dict
            # load package twice, to ensure reload works too
            self.res = loader.load_package(self.pkg_dict)
            self.res = loader.load_package(self.pkg_dict)
            self.name = self.orig_pkg_dict['name']
            self.num_resources_originally = len(self.orig_pkg_dict['resources'])
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #5
0
    def setup_class(self):
        super(TestDeathsOverwrite, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"weekly_provisional_figures_on_deaths_registered_in_england_and_wales",
                "title": "Weekly provisional figures on deaths registered in England and Wales",
                "version": None, "url": None, "author": "Office for National Statistics", "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "Weekly death figures provide provisional counts of the number of deaths registered in England and Wales in the latest four weeks for which data are available up to the end of 2009. From week one 2010 the latest eight weeks for which data are available will be published.\n\nSource agency: Office for National Statistics\n\nDesignation: National Statistics\n\nLanguage: English\n\nAlternative title: Weekly deaths",
                "license_id": "ukcrown-withrights",
                "tags": ["death", "deaths", "life-events", "life-in-the-community", "mortality-rates", "population", "weekly-deaths"],
                "groups": ['office-for-national-statistics'],
                "extras": {
                    "geographic_coverage": "101000: England, Wales",
                    "geographic_granularity": "Country",
                    "external_reference": "ONSHUB",
                    "temporal_coverage-from": "",
                    "temporal_granularity": "",
                    "date_updated": "",
                    "series": "Weekly provisional figures on deaths registered in England and Wales",
                    "precision": "",
                    "geographic_granularity": "",
                    "temporal_coverage_to": "",
                    "temporal_coverage_from": "",
                    "taxonomy_url": "",
                    "import_source": "ONS-ons_data_60_days_to_2010-09-22",
                    "date_released": "2010-08-03",
                    "temporal_coverage-to": "",
                    "update_frequency": "",
                    "national_statistic": "yes",
                    "categories": "Population"},
                "resources": [
                    {"url": "http://www.statistics.gov.uk/StatBase/Prep/9684.asp", "format": "", "description": "17/07/2009", "hash": "", "extras": {"hub-id": "77-27942"} }],
                }

            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(7), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            loader = OnsLoader(self.testclient)
            print self.pkg_dict
            self.res = loader.load_package(self.pkg_dict)
            self.name = self.orig_pkg_dict['name']
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #6
0
    def setup_class(self):
        super(TestDeathsOverwrite, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"weekly_provisional_figures_on_deaths_registered_in_england_and_wales",
                "title": "Weekly provisional figures on deaths registered in England and Wales",
                "version": None, "url": None, "author": "Office for National Statistics", "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "Weekly death figures provide provisional counts of the number of deaths registered in England and Wales in the latest four weeks for which data are available up to the end of 2009. From week one 2010 the latest eight weeks for which data are available will be published.\n\nSource agency: Office for National Statistics\n\nDesignation: National Statistics\n\nLanguage: English\n\nAlternative title: Weekly deaths",
                "license_id": "ukcrown-withrights",
                "tags": ["death", "deaths", "life-events", "life-in-the-community", "mortality-rates", "population", "weekly-deaths"],
                "groups": ['office-for-national-statistics'],
                "extras": {
                    "geographic_coverage": "101000: England, Wales",
                    "geographic_granularity": "Country",
                    "external_reference": "ONSHUB",
                    "temporal_coverage-from": "",
                    "temporal_granularity": "",
                    "date_updated": "",
                    "series": "Weekly provisional figures on deaths registered in England and Wales",
                    "precision": "",
                    "geographic_granularity": "",
                    "temporal_coverage_to": "",
                    "temporal_coverage_from": "",
                    "taxonomy_url": "",
                    "import_source": "ONS-ons_data_60_days_to_2010-09-22",
                    "date_released": "2010-08-03",
                    "temporal_coverage-to": "",
                    "update_frequency": "",
                    "national_statistic": "yes",
                    "categories": "Population"},
                "resources": [
                    {"url": "http://www.statistics.gov.uk/StatBase/Prep/9684.asp", "format": "", "description": "17/07/2009", "hash": "", "extras": {"hub-id": "77-27942"} }],
                }

            CreateTestData.create_arbitrary([self.orig_pkg_dict])

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(7), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
            loader = OnsLoader(self.testclient)
            print self.pkg_dict
            self.res = loader.load_package(self.pkg_dict)
            self.name = self.orig_pkg_dict['name']
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #7
0
    def test_load(self):
        user = model.User.by_name(u'testsysadmin')
        assert user
        testclient_admin = WsgiCkanClient(self.app, api_key=user.apikey)
        loader = OnsLoader(testclient_admin)
        print self.pkg_dict
        self.res = loader.load_package(self.pkg_dict)
        self.name = self.orig_pkg_dict['name']
        self.decoy_name = self.deleted_decoy_pkg_dict['name']
        self.num_resources_originally = len(self.orig_pkg_dict['resources'])

        names = [pkg.name for pkg in model.Session.query(model.Package).all()]
        assert_equal(set(names), set((self.name, self.decoy_name)))
        pkg = model.Package.by_name(self.name)
        assert pkg
        assert_equal(len(pkg.resources), self.num_resources_originally + 1)
Пример #8
0
    def test_load(self):
        user = model.User.by_name(u'testsysadmin')
        assert user
        testclient_admin = WsgiCkanClient(self.app, api_key=user.apikey)
        loader = OnsLoader(testclient_admin)
        print self.pkg_dict
        self.res = loader.load_package(self.pkg_dict)
        self.name = self.orig_pkg_dict['name']
        self.decoy_name = self.deleted_decoy_pkg_dict['name']
        self.num_resources_originally = len(self.orig_pkg_dict['resources'])

        names = [pkg.name for pkg in model.Session.query(model.Package).all()]
        assert_equal(set(names), set((self.name, self.decoy_name)))
        pkg = model.Package.by_name(self.name)
        assert pkg
        assert_equal(len(pkg.resources), self.num_resources_originally + 1)