コード例 #1
0
    def test_external_documentation_fields_values(self):
        """ Test Top.external_documentation group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.external_documentation.any_field.url = 'http://example.com'
        top.external_documentation.any_field.title = 'the-title'
        top.external_documentation.any_field.description = 'the-description'
        top.external_documentation.any_field.source = 'http://example.com'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(
            new_top.external_documentation.any_field.url,
            'http://example.com')
        self.assertEqual(
            new_top.external_documentation.any_field.title,
            'the-title')
        self.assertEqual(
            new_top.external_documentation.any_field.description,
            'the-description')
        self.assertEqual(
            new_top.external_documentation.any_field.source,
            'http://example.com')
コード例 #2
0
    def test_identity_fields_values(self):
        """ Test contacts group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.identity.bspace = 'b-space'
        top.identity.btime = 'b-time'
        top.identity.dataset = dataset.vid
        top.identity.id = dataset.id
        top.identity.revision = 7
        top.identity.source = 'example.com'
        top.identity.subset = 'mortality'
        top.identity.type = '?'
        top.identity.variation = 1
        top.identity.version = '0.0.7'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.identity.bspace, 'b-space')
        self.assertEqual(new_top.identity.btime, 'b-time')
        self.assertEqual(new_top.identity.dataset, dataset.vid)
        self.assertEqual(new_top.identity.id, dataset.id)
        self.assertEqual(new_top.identity.revision, 7)
        self.assertEqual(new_top.identity.source, 'example.com')
        self.assertEqual(new_top.identity.subset, 'mortality')
        self.assertEqual(new_top.identity.type, '?')
        self.assertEqual(new_top.identity.variation, 1)
        self.assertEqual(new_top.identity.version, '0.0.7')
コード例 #3
0
    def test_identity_fields_values(self):
        """ Test contacts group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.identity.bspace = 'b-space'
        top.identity.btime = 'b-time'
        top.identity.dataset = dataset.vid
        top.identity.id = dataset.id
        top.identity.revision = 7
        top.identity.source = 'example.com'
        top.identity.subset = 'mortality'
        top.identity.type = '?'
        top.identity.variation = 1
        top.identity.version = '0.0.7'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.identity.bspace, 'b-space')
        self.assertEqual(new_top.identity.btime, 'b-time')
        self.assertEqual(new_top.identity.dataset, dataset.vid)
        self.assertEqual(new_top.identity.id, dataset.id)
        self.assertEqual(new_top.identity.revision, 7)
        self.assertEqual(new_top.identity.source, 'example.com')
        self.assertEqual(new_top.identity.subset, 'mortality')
        self.assertEqual(new_top.identity.type, '?')
        self.assertEqual(new_top.identity.variation, 1)
        self.assertEqual(new_top.identity.version, '0.0.7')
コード例 #4
0
    def test_create_group_and_config_in_the_db(self):
        """ Setting empty property tree key creates group and config in the db. """
        db = self.db
        dataset = self.dataset

        top = Top()

        # bind tree to the database
        top.link_config(db.session, dataset)

        # change some fields
        top.names.vid = dataset.vid
        top.about.access = 'public'

        # testing
        query = db.session.query(Config)
        top_config = query.filter_by(d_vid=dataset.vid,
                                     type='metadata',
                                     parent=None).first()

        # top config does not have key or value
        self.assertIsNone(top_config.key, '')
        self.assertEqual(top_config.value, {})

        #
        # names and about groups does not have values
        #
        names_group = query.filter_by(d_vid=dataset.vid,
                                      type='metadata',
                                      group='names').first()
        self.assertEqual(names_group.key, 'names')
        self.assertEqual(names_group.value, {})
        self.assertEqual(names_group.parent, top_config)

        about_group = query.filter_by(d_vid=dataset.vid,
                                      type='metadata',
                                      group='about').first()
        self.assertEqual(about_group.key, 'about')
        self.assertEqual(about_group.value, {})
        self.assertEqual(about_group.parent, top_config)

        #
        # Configs have proper parents and values.
        #
        vid_config = query.filter_by(d_vid=dataset.vid,
                                     type='metadata',
                                     key='vid').first()
        self.assertEqual(vid_config.key, 'vid')
        self.assertEqual(vid_config.value, dataset.vid)
        self.assertEqual(vid_config.parent, names_group)
コード例 #5
0
    def test_versions_fields_values(self):
        """ Test Top().versions group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.versions['1'].date = '2015-04-12T15:49:55.077036'
        top.versions['1'].description = 'Adding coverage'
        top.versions['1'].version = '0.0.2'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.versions['1'].date, '2015-04-12T15:49:55.077036')
        self.assertEqual(new_top.versions['1'].description, 'Adding coverage')
        self.assertEqual(new_top.versions['1'].version, '0.0.2')
コード例 #6
0
    def test_build_fields_values(self):
        """ Test Top().build group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.build.key1 = 'value1'
        top.build.key2 = 'value2'
        top.build.key3 = 'value3'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.build.key1, 'value1')
        self.assertEqual(new_top.build.key2, 'value2')
        self.assertEqual(new_top.build.key3, 'value3')
コード例 #7
0
    def test_requirements_fields_values(self):
        """ Test Top.requirements group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.requirements.xlrd = 'xlrd'
        top.requirements.requests = 'requests'
        top.requirements.suds = 'suds'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.requirements.xlrd, 'xlrd')
        self.assertEqual(new_top.requirements.requests, 'requests')
        self.assertEqual(new_top.requirements.suds, 'suds')
コード例 #8
0
    def test_versions_fields_values(self):
        """ Test Top().versions group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.versions['1'].date = '2015-04-12T15:49:55.077036'
        top.versions['1'].description = 'Adding coverage'
        top.versions['1'].version = '0.0.2'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.versions['1'].date,
                         '2015-04-12T15:49:55.077036')
        self.assertEqual(new_top.versions['1'].description, 'Adding coverage')
        self.assertEqual(new_top.versions['1'].version, '0.0.2')
コード例 #9
0
    def test_names_fields_values(self):
        """ Test Top().names group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.names.fqname = 'fq-name'
        top.names.name = 'name'
        top.names.vid = 'd001'
        top.names.vname = 'vname'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.names.fqname, 'fq-name')
        self.assertEqual(new_top.names.name, 'name')
        self.assertEqual(new_top.names.vid, 'd001')
        self.assertEqual(new_top.names.vname, 'vname')
コード例 #10
0
    def test_names_fields_values(self):
        """ Test Top().names group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.names.fqname = 'fq-name'
        top.names.name = 'name'
        top.names.vid = 'd001'
        top.names.vname = 'vname'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.names.fqname, 'fq-name')
        self.assertEqual(new_top.names.name, 'name')
        self.assertEqual(new_top.names.vid, 'd001')
        self.assertEqual(new_top.names.vname, 'vname')
コード例 #11
0
    def test_about_group_fields_values(self):
        """ Test about group fields values. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.about.access = 'restricted'
        top.about.footnote = 'the-footnote'
        top.about.grain = 'hospital'
        top.about.groups = ['health', 'california']
        top.about.license = 'ckdbl'
        top.about.processed = 'processed'
        top.about.rights = 'public'
        top.about.source = 'http://example.com'
        top.about.space = 'California'
        top.about.subject = 'Subject'
        top.about.summary = 'The Inpatient Mortality Indicators (IMIs) are a subset of...'
        top.about.tags = ['tag1', 'tag2']
        top.about.time = '15:55'  # TODO: How to convert time?  ESB: You don't; it's usually an ISO duration, or integer year.
        top.about.title = 'Inpatient Mortality Indicators'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.about.access, 'restricted')
        self.assertEqual(new_top.about.footnote, 'the-footnote')
        self.assertEqual(new_top.about.grain, 'hospital')
        self.assertEqual(new_top.about.groups, ['health', 'california'])
        self.assertEqual(new_top.about.license, 'ckdbl')
        self.assertEqual(new_top.about.processed, 'processed')
        self.assertEqual(new_top.about.rights, 'public')
        self.assertEqual(new_top.about.source, 'http://example.com')
        self.assertEqual(new_top.about.space, 'California')
        self.assertEqual(new_top.about.subject, 'Subject')
        self.assertEqual(
            new_top.about.summary,
            'The Inpatient Mortality Indicators (IMIs) are a subset of...')

        self.assertEqual(new_top.about.tags, ['tag1', 'tag2'])
        self.assertEqual(new_top.about.time,
                         '15:55')  # TODO: How to convert time?
        self.assertEqual(new_top.about.title, 'Inpatient Mortality Indicators')
コード例 #12
0
    def test_about_group_fields_values(self):
        """ Test about group fields values. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.about.access = 'restricted'
        top.about.footnote = 'the-footnote'
        top.about.grain = 'hospital'
        top.about.groups = ['health', 'california']
        top.about.license = 'ckdbl'
        top.about.processed = 'processed'
        top.about.rights = 'public'
        top.about.source = 'http://example.com'
        top.about.space = 'California'
        top.about.subject = 'Subject'
        top.about.summary = 'The Inpatient Mortality Indicators (IMIs) are a subset of...'
        top.about.tags = ['tag1', 'tag2']
        top.about.time = '15:55'  # TODO: How to convert time?  ESB: You don't; it's usually an ISO duration, or integer year.
        top.about.title = 'Inpatient Mortality Indicators'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.about.access, 'restricted')
        self.assertEqual(new_top.about.footnote, 'the-footnote')
        self.assertEqual(new_top.about.grain, 'hospital')
        self.assertEqual(new_top.about.groups, ['health', 'california'])
        self.assertEqual(new_top.about.license, 'ckdbl')
        self.assertEqual(new_top.about.processed, 'processed')
        self.assertEqual(new_top.about.rights, 'public')
        self.assertEqual(new_top.about.source, 'http://example.com')
        self.assertEqual(new_top.about.space, 'California')
        self.assertEqual(new_top.about.subject, 'Subject')
        self.assertEqual(
            new_top.about.summary,
            'The Inpatient Mortality Indicators (IMIs) are a subset of...')

        self.assertEqual(new_top.about.tags, ['tag1', 'tag2'])
        self.assertEqual(new_top.about.time, '15:55')  # TODO: How to convert time?
        self.assertEqual(new_top.about.title, 'Inpatient Mortality Indicators')
コード例 #13
0
    def test_create_group_and_config_in_the_db(self):
        """ Setting empty property tree key creates group and config in the db. """
        db = self.db
        dataset = self.dataset

        top = Top()

        # bind tree to the database
        top.link_config(db.session, dataset)

        # change some fields
        top.names.vid = dataset.vid
        top.about.access = 'public'

        # testing
        query = db.session.query(Config)
        top_config = query.filter_by(d_vid=dataset.vid, type='metadata', parent=None).first()

        # top config does not have key or value
        self.assertIsNone(top_config.key, '')
        self.assertEqual(top_config.value, {})

        #
        # names and about groups does not have values
        #
        names_group = query.filter_by(d_vid=dataset.vid, type='metadata', group='names').first()
        self.assertEqual(names_group.key, 'names')
        self.assertEqual(names_group.value, {})
        self.assertEqual(names_group.parent, top_config)

        about_group = query.filter_by(d_vid=dataset.vid, type='metadata', group='about').first()
        self.assertEqual(about_group.key, 'about')
        self.assertEqual(about_group.value, {})
        self.assertEqual(about_group.parent, top_config)

        #
        # Configs have proper parents and values.
        #
        vid_config = query.filter_by(d_vid=dataset.vid, type='metadata', key='vid').first()
        self.assertEqual(vid_config.key, 'vid')
        self.assertEqual(vid_config.value, dataset.vid)
        self.assertEqual(vid_config.parent, names_group)
コード例 #14
0
    def test_change_database_values(self):
        """ Changing existing property tree key value changes config instance. """
        db = self.db
        dataset = self.dataset

        top = Top()

        # bind tree to the database
        top.link_config(db.session, dataset)

        # change some fields
        top.names.vid = dataset.vid

        # testing
        query = db.session.query(Config)
        vid_config = query.filter_by(d_vid=dataset.vid, type='metadata', key='vid').first()
        self.assertEqual(vid_config.value, dataset.vid)

        top.names.vid = 'vid-1'
        vid_config = query.filter_by(type='metadata', key='vid').first()
        self.assertEqual(vid_config.value, 'vid-1')
コード例 #15
0
    def test_dependencies_fields_values(self):
        """ Test Top.dependencies group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.dependencies.counties = 'census.gov-index-counties'
        top.dependencies.facility_index = 'oshpd.ca.gov-facilities-index-facilities_index-2010e2014'
        top.dependencies.facility_info = 'oshpd.ca.gov-facilities-index-facilities'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.dependencies.counties,
                         'census.gov-index-counties')
        self.assertEqual(
            new_top.dependencies.facility_index,
            'oshpd.ca.gov-facilities-index-facilities_index-2010e2014')
        self.assertEqual(new_top.dependencies.facility_info,
                         'oshpd.ca.gov-facilities-index-facilities')
コード例 #16
0
    def test_contacts_fields_values(self):
        """ Test contacts group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.contacts.creator.role = 'c-developer'
        top.contacts.creator.org = 'c-home'
        top.contacts.creator.email = '*****@*****.**'
        top.contacts.creator.name = 'c-tester'
        top.contacts.creator.url = 'http://creator.example.com'
        # FIXME: Populate maintainer, source and analyst too.

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.contacts.creator.role, 'c-developer')
        self.assertEqual(new_top.contacts.creator.org, 'c-home')
        self.assertEqual(new_top.contacts.creator.email, '*****@*****.**')
        self.assertEqual(new_top.contacts.creator.name, 'c-tester')
        self.assertEqual(new_top.contacts.creator.url, 'http://creator.example.com')
コード例 #17
0
    def test_dependencies_fields_values(self):
        """ Test Top.dependencies group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.dependencies.counties = 'census.gov-index-counties'
        top.dependencies.facility_index = 'oshpd.ca.gov-facilities-index-facilities_index-2010e2014'
        top.dependencies.facility_info = 'oshpd.ca.gov-facilities-index-facilities'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(
            new_top.dependencies.counties,
            'census.gov-index-counties')
        self.assertEqual(
            new_top.dependencies.facility_index,
            'oshpd.ca.gov-facilities-index-facilities_index-2010e2014')
        self.assertEqual(
            new_top.dependencies.facility_info,
            'oshpd.ca.gov-facilities-index-facilities')
コード例 #18
0
    def test_contacts_fields_values(self):
        """ Test contacts group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.contacts.creator.role = 'c-developer'
        top.contacts.creator.org = 'c-home'
        top.contacts.creator.email = '*****@*****.**'
        top.contacts.creator.name = 'c-tester'
        top.contacts.creator.url = 'http://creator.example.com'
        # FIXME: Populate maintainer, source and analyst too.

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.contacts.creator.role, 'c-developer')
        self.assertEqual(new_top.contacts.creator.org, 'c-home')
        self.assertEqual(new_top.contacts.creator.email, '*****@*****.**')
        self.assertEqual(new_top.contacts.creator.name, 'c-tester')
        self.assertEqual(new_top.contacts.creator.url,
                         'http://creator.example.com')
コード例 #19
0
    def test_build_fields_values(self):
        """ Test Top().build group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.build.key1 = 'value1'
        top.build.key2 = 'value2'
        top.build.key3 = 'value3'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(
            new_top.build.key1,
            'value1')
        self.assertEqual(
            new_top.build.key2,
            'value2')
        self.assertEqual(
            new_top.build.key3,
            'value3')
コード例 #20
0
    def test_external_documentation_fields_values(self):
        """ Test Top.external_documentation group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.external_documentation.any_field.url = 'http://example.com'
        top.external_documentation.any_field.title = 'the-title'
        top.external_documentation.any_field.description = 'the-description'
        top.external_documentation.any_field.source = 'http://example.com'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(new_top.external_documentation.any_field.url,
                         'http://example.com')
        self.assertEqual(new_top.external_documentation.any_field.title,
                         'the-title')
        self.assertEqual(new_top.external_documentation.any_field.description,
                         'the-description')
        self.assertEqual(new_top.external_documentation.any_field.source,
                         'http://example.com')
コード例 #21
0
    def test_change_database_values(self):
        """ Changing existing property tree key value changes config instance. """
        db = self.db
        dataset = self.dataset

        top = Top()

        # bind tree to the database
        top.link_config(db.session, dataset)

        # change some fields
        top.names.vid = dataset.vid

        # testing
        query = db.session.query(Config)
        vid_config = query.filter_by(d_vid=dataset.vid,
                                     type='metadata',
                                     key='vid').first()
        self.assertEqual(vid_config.value, dataset.vid)

        top.names.vid = 'vid-1'
        vid_config = query.filter_by(type='metadata', key='vid').first()
        self.assertEqual(vid_config.value, 'vid-1')
コード例 #22
0
    def test_requirements_fields_values(self):
        """ Test Top.requirements group fields of the metadata config. """
        # Test both - setting and saving to db.
        top = Top()
        dataset = DatasetFactory()
        top.link_config(self.my_library.database.session, dataset)

        top.requirements.xlrd = 'xlrd'
        top.requirements.requests = 'requests'
        top.requirements.suds = 'suds'

        # build from db and check
        new_top = Top()
        new_top.build_from_db(dataset)
        self.assertEqual(
            new_top.requirements.xlrd,
            'xlrd')
        self.assertEqual(
            new_top.requirements.requests,
            'requests')
        self.assertEqual(
            new_top.requirements.suds,
            'suds')