Пример #1
0
    def setup_class(self):
        super(TestDeletedDecoyWhenAdmin, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"quarterly_epidemiological_commentary",
                "title": "Quarterly Epidemiological Commentary",
                "version": None, "url": None, "author": None, "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "Epidemiological analyses of Mandatory surveillance data on MRSA bacteraemia and C. difficile infection covering at least nine quarters\r\nSource agency: Health Protection Agency\r\nDesignation: Official Statistics not designated as National Statistics\r\nLanguage: English\r\nAlternative title: Quarterly Epi Commentary",
                "license_id": "uk-ogl",
                "tags": ["conditions-and-diseases", "health", "health-and-social-care", "health-of-the-population", "nhs-trust-hcai-pct-mrsa-mrsa-bacteraemia-c-difficile-c-diff-clostridium-difficile-healthcare-associa", "well-being-and-care"],
                "groups": ['health-protection-agency'],
                "extras": {
                    "geographic_coverage": "100000: England",
                    "geographic_granularity": "Other",
                    "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_7_days_to_2010-06-23",
                    "date_released": "2010-06-18",
                    "temporal_coverage-to": "",
                    "update_frequency": "quarterly",
                    "national_statistic": "no",
                    "categories": "Health and Social Care"
                    },
                "resources": []            
                }
            self.deleted_decoy_pkg_dict = {
                "name": u"quarterly_epidemiological_commentary_-_none",
                "title": "Quarterly Epidemiological Commentary",
                "groups": ['health-protection-agency'],
                }
            CreateTestData.create_arbitrary([self.orig_pkg_dict])
            CreateTestData.create_arbitrary([self.deleted_decoy_pkg_dict],
                                            extra_user_names=[u'testsysadmin'])

            # make a sysadmin user
            rev = model.repo.new_revision()
            testsysadmin = model.User.by_name(u'testsysadmin')
            model.add_user_to_role(testsysadmin, model.Role.ADMIN, model.System())

            # delete decoy
            decoy_pkg = model.Package.by_name(self.deleted_decoy_pkg_dict['name'])
            assert decoy_pkg
            decoy_pkg.delete()
            model.repo.commit_and_remove()

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(9), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
        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(TestDeletedDecoyWhenAdmin, self).setup_class()
        try:
            self.orig_pkg_dict = {
                "name": u"quarterly_epidemiological_commentary",
                "title": "Quarterly Epidemiological Commentary",
                "version": None, "url": None, "author": None, "author_email": None, "maintainer": None, "maintainer_email": None,
                "notes": "Epidemiological analyses of Mandatory surveillance data on MRSA bacteraemia and C. difficile infection covering at least nine quarters\r\nSource agency: Health Protection Agency\r\nDesignation: Official Statistics not designated as National Statistics\r\nLanguage: English\r\nAlternative title: Quarterly Epi Commentary",
                "license_id": "uk-ogl",
                "tags": ["conditions-and-diseases", "health", "health-and-social-care", "health-of-the-population", "nhs-trust-hcai-pct-mrsa-mrsa-bacteraemia-c-difficile-c-diff-clostridium-difficile-healthcare-associa", "well-being-and-care"],
                "groups": ['health-protection-agency'],
                "extras": {
                    "geographic_coverage": "100000: England",
                    "geographic_granularity": "Other",
                    "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_7_days_to_2010-06-23",
                    "date_released": "2010-06-18",
                    "temporal_coverage-to": "",
                    "update_frequency": "quarterly",
                    "national_statistic": "no",
                    "categories": "Health and Social Care"
                    },
                "resources": []            
                }
            self.deleted_decoy_pkg_dict = {
                "name": u"quarterly_epidemiological_commentary_-_none",
                "title": "Quarterly Epidemiological Commentary",
                "groups": ['health-protection-agency'],
                }
            CreateTestData.create_arbitrary([self.orig_pkg_dict])
            CreateTestData.create_arbitrary([self.deleted_decoy_pkg_dict],
                                            extra_user_names=[u'testsysadmin'])

            # make a sysadmin user
            rev = model.repo.new_revision()
            testsysadmin = model.User.by_name(u'testsysadmin')
            model.add_user_to_role(testsysadmin, model.Role.ADMIN, model.System())

            # delete decoy
            decoy_pkg = model.Package.by_name(self.deleted_decoy_pkg_dict['name'])
            assert decoy_pkg
            decoy_pkg.delete()
            model.repo.commit_and_remove()

            # same data is imported, but should find record and add department
            importer_ = importer.OnsImporter(sample_filepath(9), self.testclient)
            self.pkg_dict = [pkg_dict for pkg_dict in importer_.pkg_dict()][0]
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'a',
             'extras': {
                 'department': 'abc',
                 'agency': 'ag-a'
             },
         },
         {
             'name': 'b',
             'extras': {
                 'department': 'bcd',
                 'agency': 'ag-b'
             },
         },
         {
             'name': 'c',
             'extras': {
                 'department': 'cde abc'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'department': ''
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Пример #5
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
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {"name": "a", "extras": {"department": "abc", "agency": "ag-a"}},
         {"name": "b", "extras": {"department": "bcd", "agency": "ag-b"}},
         {"name": "c", "extras": {"department": "cde abc"}},
         {"name": "none", "extras": {"department": ""}},
     ]
     CreateTestData.create_arbitrary(init_data)
Пример #7
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
Пример #8
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
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {"name": "eng", "extras": {"geographic_coverage": "100000: England"}},
         {"name": "eng_ni", "extras": {"geographic_coverage": "100100: England, Northern Ireland"}},
         {
             "name": "uk",
             "extras": {"geographic_coverage": "111100: United Kingdom (England, Scotland, Wales, Northern Ireland"},
         },
         {"name": "gb", "extras": {"geographic_coverage": "111000: Great Britain (England, Scotland, Wales)"}},
         {"name": "none", "extras": {"geographic_coverage": "000000:"}},
     ]
     CreateTestData.create_arbitrary(init_data)
Пример #10
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [{'name':u'test1-penguin-canary',
                   'title':u'penguin',
                   'tags':u'canary goose squirrel wombat wombat'.split()},
                  {'name':u'test2-squirrel-squirrel-canary-goose',
                   'title':u'squirrel goose',
                   'tags':u'penguin wombat'.split()},
                  ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary',
         u'test2-squirrel-squirrel-canary-goose'
     ]
Пример #11
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'a',
          'extras':{'department':'abc',
                    'agency':'ag-a'},},
         {'name':'b',
          'extras':{'department':'bcd',
                    'agency':'ag-b'},},
         {'name':'c',
          'extras':{'department':'cde abc'},},
         {'name':'none',
          'extras':{'department':''},},
         ]
     CreateTestData.create_arbitrary(init_data)
Пример #12
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'eng',
          'extras':{'geographic_coverage':'100000: England'},},
         {'name':'eng_ni',
          'extras':{'geographic_coverage':'100100: England, Northern Ireland'},},
         {'name':'uk',
          'extras':{'geographic_coverage':'111100: United Kingdom (England, Scotland, Wales, Northern Ireland'},},
         {'name':'gb',
          'extras':{'geographic_coverage':'111000: Great Britain (England, Scotland, Wales)'},},
         {'name':'none',
          'extras':{'geographic_coverage':'000000:'},},
     ]
     CreateTestData.create_arbitrary(init_data)
Пример #13
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
Пример #14
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
Пример #15
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             "name": u"test1-penguin-canary",
             "title": u"penguin",
             "tags": u"canary goose squirrel wombat wombat".split(),
         },
         {
             "name": u"test2-squirrel-squirrel-canary-goose",
             "title": u"squirrel goose",
             "tags": u"penguin wombat".split(),
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [u"test1-penguin-canary", u"test2-squirrel-squirrel-canary-goose"]
Пример #16
0
    def setup_class(self):
        super(TestOnsLoadClashSource, self).setup_class()

        self.clash_name = u'cereals_and_oilseeds_production_harvest'
        CreateTestData.create_arbitrary([{
            'name': self.clash_name,
            'title': 'Test clash',
            'extras': {
                'published_by':
                'Department for Environment, Food and Rural Affairs',
                'import_source': 'DECC-Jan-09',
            },
        }])
        importer_ = importer.OnsImporter(sample_filepath(''))
        pkg_dicts = [pkg_dict for pkg_dict in importer_.pkg_dict()]
        loader = OnsLoader(self.testclient)
        self.res = loader.load_packages(pkg_dicts)
        assert self.res['num_errors'] == 0, self.res
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': u'test1-penguin-canary',
             'title': u'penguin',
             'tags': u'canary goose squirrel wombat wombat'.split()
         },
         {
             'name': u'test2-squirrel-squirrel-canary-goose',
             'title': u'squirrel goose',
             'tags': u'penguin wombat'.split()
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary', u'test2-squirrel-squirrel-canary-goose'
     ]
Пример #18
0
    def setup_class(self):
        super(TestOnsLoadClashSource, self).setup_class()

        self.clash_name = u'cereals_and_oilseeds_production_harvest'
        CreateTestData.create_arbitrary([
            {'name':self.clash_name,
             'title':'Test clash',
             'groups':['department-for-environment-food-and-rural-affairs'],
             'extras':{
                 'import_source':'DECC-Jan-09',
                 },
             }
            ])
        importer_ = importer.OnsImporter(sample_filepath(''))
        pkg_dicts = [pkg_dict for pkg_dict in importer_.pkg_dict()]
        loader = OnsLoader(self.testclient)
        self.res = loader.load_packages(pkg_dicts)
        assert self.res['num_errors'] == 0, self.res
Пример #19
0
 def setup_class(cls):     
     
     script_path = os.path.join(os.path.dirname(os.path.abspath( __file__ )), 'scripts', 'create_tables.sql')
     script = open(script_path, 'r').read()
     cls._execute_sql(script)
     
     #CreateTestData.create_test_user()
     
     '''
     schema = default_create_package_schema()
     context = {
             'model': model,
             'session': Session,
             'user': '******',
             'schema': schema,
             'api_version': 2
         }
     '''
     package_fixture_data =  {
             'name': 'test-ngds',
             'title': 'test title',
             'resources': [
                     {
                         'name': 'test-resource',
                         'url': 'http://azgs.az.gov',
                         'format': 'plain text',
                         'description': 'This is a test description',
                         'hash': 'abc123',
                         'extras': {'size_extra': '123'}
                     }
                 ]
         }
     
     '''
     package_dict = package_create(context, package_fixture_data)
     cls.package_id = context.get('id') 
     '''
     CreateTestData.create_arbitrary(package_fixture_data)
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'eng',
             'extras': {
                 'geographic_coverage': '100000: England'
             },
         },
         {
             'name': 'eng_ni',
             'extras': {
                 'geographic_coverage': '100100: England, Northern Ireland'
             },
         },
         {
             'name': 'uk',
             'extras': {
                 'geographic_coverage':
                 '111100: United Kingdom (England, Scotland, Wales, Northern Ireland'
             },
         },
         {
             'name': 'gb',
             'extras': {
                 'geographic_coverage':
                 '111000: Great Britain (England, Scotland, Wales)'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'geographic_coverage': '000000:'
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Пример #21
0
    def setup_class(self):
        super(TestOnsLoadClashSource, self).setup_class()

        try:
            self.clash_name = u'cereals_and_oilseeds_production_harvest'
            CreateTestData.create_arbitrary([
                {'name':self.clash_name,
                 'title':'Test clash',
                 'groups':['department-for-environment-food-and-rural-affairs'],
                 'extras':{
                     'import_source':'DECC-Jan-09',
                     },
                 }
                ])
            importer_ = importer.OnsImporter(sample_filepath(''), self.testclient)
            pkg_dicts = [pkg_dict for pkg_dict in importer_.pkg_dict()]
            loader = OnsLoader(self.testclient)
            self.res = loader.load_packages(pkg_dicts)
            assert self.res['num_errors'] == 0, self.res
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #22
0
    def setup_class(self):
        super(TestOnsLoadClashSource, self).setup_class()

        try:
            self.clash_name = u'cereals_and_oilseeds_production_harvest'
            CreateTestData.create_arbitrary([
                {'name':self.clash_name,
                 'title':'Test clash',
                 'groups':['department-for-environment-food-and-rural-affairs'],
                 'extras':{
                     'import_source':'DECC-Jan-09',
                     },
                 }
                ])
            importer_ = importer.OnsImporter(sample_filepath(''), self.testclient)
            pkg_dicts = [pkg_dict for pkg_dict in importer_.pkg_dict()]
            loader = OnsLoader(self.testclient)
            self.res = loader.load_packages(pkg_dicts)
            assert self.res['num_errors'] == 0, self.res
        except:
            # ensure that mock_drupal is destroyed
            MockDrupalCase.teardown_class()
            model.repo.rebuild_db()
            raise
Пример #23
0
 def setup_class(cls):
     """
     Remove any initial sessions.
     """
     Session.remove()
     package_dicts = [{'name':u'abraham', 'title':u'Abraham'},
             {'name':u'homer', 'title':u'Homer', 'tags':['foo', 'bar',
                                                         'baz']},
             {'name':u'homer_derived', 'title':u'Homer Derived'},
             {'name':u'beer', 'title':u'Beer'},
             {'name':u'bart', 'title':u'Bart'},
             {'name':u'lisa', 'title':u'Lisa', 'extras': {'fezina':'foo'}},
             {'name':u'marge', 'title':u'Marge'},
             {'name':u'marge1', 'title':u'Marge'},
             {'name':u'marge11', 'title':u'Marge'},
             {'name':u'marge121', 'title':u'Marge'},
             {'name':u'marge311', 'title':u'Marge'},
             {'name':u'marge24', 'title':u'Marge'},
             {'name':u'marget1', 'title':u'Marge'},
             {'name':u'marge31', 'title':u'Marge'},
             {'name':u'marge1121', 'title':u'Marge'},
             {'name':u'marge1t', 'title':u'Marge'},
             {'name':u'marge1b', 'title':u'Marge'},
             {'name':u'marge1a', 'title':u'Marge'},
             ]
     CreateTestData.create_arbitrary(package_dicts)
     package_dicts = [u'abraham',
             u'homer',
             u'homer_derived',
             u'beer',
             u'bart',
             u'lisa',
             u'marge',
             u'marge1',
             u'marge11',
             u'marge121',
             u'marge311',
             u'marge24',
             u'marget1',
             u'marge31',
             u'marge1121',
             u'marge1t',
             u'marge1b',
             u'marge1a',
             ]
     group_dicts = [{'name':'roger', 'title':'roger', 'description':'',
                     'packages': package_dicts},
                    {'name':'roger1', 'title':'roger', 'description':''},
                    {'name':'roger2', 'title':'roger', 'description':''},
                    {'name':'roger3', 'title':'roger', 'description':''},
                    {'name':'roger4', 'title':'roger', 'description':''},
                    {'name':'roger5', 'title':'roger', 'description':''},
                    {'name':'roger6', 'title':'roger', 'description':''},
                    {'name':'roger7', 'title':'roger', 'description':''},
                    {'name':'roger8', 'title':'roger', 'description':''},
                    {'name':'roger9', 'title':'roger', 'description':''},
                    {'name':'roger0', 'title':'roger', 'description':''},
                    {'name':'roger11', 'title':'roger', 'description':''},
                    {'name':'roger12', 'title':'roger', 'description':''},
                    {'name':'roger13', 'title':'roger', 'description':''},
                    {'name':'roger14', 'title':'roger', 'description':''}]
     CreateTestData.create_groups(group_dicts)
     setup()
     cls._first = True
     cls._second = False
Пример #24
0
 def _create_package(self, package=None):
     CreateTestData.create_arbitrary(self.new_pkg_dict)
     return model.Package.by_name(self.new_pkg_dict['name'])
 def _create_package(self, package=None):
     CreateTestData.create_arbitrary(self.new_pkg_dict)
     return model.Package.by_name(self.new_pkg_dict['name'])