Esempio n. 1
0
    def test_uses_exactly_two_db_hits_to_build_config(self):

        # create appropriate tree in the database
        configs = [
            ('names.fqname', self.dataset.fqname),
            ('names.name', self.dataset.name),
            ('names.vid', self.dataset.vid),
            ('names.vname', self.dataset.vname),

            # about
            ('about.access', 'restricted'),
            ('about.footnote', None),
            ('about.grain', 'hospital')
        ]

        self._create_db_tree(configs)

        # now collect all queries
        queries = []

        def before_cursor_execute(conn, cursor, statement, parameters, context,
                                  executemany):
            queries.append((statement, parameters))

        event.listen(self.db.engine, 'before_cursor_execute',
                     before_cursor_execute)

        # build from db
        top = Top()
        top.build_from_db(self.dataset)
        expected_queries = [
            'dataset retrieve', 'all configs retrieve while cache building'
        ]
        self.assertEqual(len(expected_queries), len(queries))
Esempio n. 2
0
    def test_build_tree_from_database(self):
        """ Populates property tree with values from database. """

        # create appropriate tree in the database
        self._create_db_tree()

        # build from db
        top = Top()
        top.build_from_db(self.dataset)
        self.assertEqual(top.names.vid, self.dataset.vid)
Esempio n. 3
0
    def test_build_tree_from_database(self):
        """ Populates property tree with values from database. """

        # create appropriate tree in the database
        self._create_db_tree()

        # build from db
        top = Top()
        top.build_from_db(self.dataset)
        self.assertEqual(top.names.vid, self.dataset.vid)
Esempio n. 4
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')
Esempio n. 5
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)
Esempio n. 6
0
    def test_change_tree_build_from_database(self):

        # create appropriate tree in the database
        self._create_db_tree()

        # build from db
        top = Top()
        top.build_from_db(self.dataset)

        # change and test
        assert top.is_bound()
        vid_value_config = self.db.session.query(Config).filter_by(key='vid', type='metadata').one()
        self.assertNotEqual(vid_value_config.value, 'vid-2')
        top.names.vid = 'vid-2'
        vid_value_config = self.db.session.query(Config).filter_by(key='vid', type='metadata').one()
        self.assertEqual(vid_value_config.value, 'vid-2')
Esempio n. 7
0
 def test_external_documentation_fields(self):
     """ Test external_documentation group of the metadata config. """
     # requirements group allow any field
     expected_fields = ['url', 'title', 'description', 'source']
     self._assert_fields_match(
         expected_fields,
         Top().external_documentation.any_random_field)
Esempio n. 8
0
    def test_dependencies_fields(self):
        """ Test dependencies group of the metadata config. """
        expected_fields = [
            'counties',
            'facility_index',
            'facility_info',
        ]

        self._assert_fields_match(expected_fields, Top().dependencies)
Esempio n. 9
0
    def test_change_tree_build_from_database(self):

        # create appropriate tree in the database
        self._create_db_tree()

        # build from db
        top = Top()
        top.build_from_db(self.dataset)

        # change and test
        assert top.is_bound()
        vid_value_config = self.db.session.query(Config).filter_by(
            key='vid', type='metadata').one()
        self.assertNotEqual(vid_value_config.value, 'vid-2')
        top.names.vid = 'vid-2'
        vid_value_config = self.db.session.query(Config).filter_by(
            key='vid', type='metadata').one()
        self.assertEqual(vid_value_config.value, 'vid-2')
Esempio n. 10
0
    def test_versions_fields(self):
        """ Test contacts group of the metadata config. """
        expected_fields = [
            'version',
            'date',
            'description',
        ]

        self._assert_fields_match(expected_fields, Top().versions.any_field)
Esempio n. 11
0
    def test_about_group_fields(self):
        """ Test about group of the metadata config. """
        expected_fields = [
            'access', 'footnote', 'grain', 'groups', 'license', 'processed',
            'rights', 'source', 'space', 'subject', 'summary', 'tags', 'time',
            'title'
        ]

        self._assert_fields_match(expected_fields, Top().about)
Esempio n. 12
0
    def test_contacts_fields(self):
        """ Test contacts group of the metadata config. """
        expected_fields = [
            'creator',
            'maintainer',
            'source',
            'analyst',
        ]

        self._assert_fields_match(expected_fields, Top().contacts)
Esempio n. 13
0
    def test_names_fields(self):
        """ Test Top().names group of the metadata config. """
        expected_fields = [
            'fqname',
            'name',
            'vid',
            'vname',
        ]

        self._assert_fields_match(expected_fields, Top().names)
Esempio n. 14
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)
Esempio n. 15
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')
Esempio n. 16
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')
Esempio n. 17
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')
Esempio n. 18
0
    def test_requirements_fields(self):
        """ Test requirements group of the metadata config. """
        # requirements group allow any field
        expected_fields = [
            'xlrd',
            'requests',
            'suds',
        ]
        top = Top()
        top.requirements.xlrd = 'xlrd'
        top.requirements.requests = 'requests'
        top.requirements.suds = 'suds'

        self._assert_fields_match(expected_fields, top.requirements)
Esempio n. 19
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')
Esempio n. 20
0
    def test_top_level_fields(self):
        """ Test top level groups of the structured property tree. """
        expected_fields = [
            'about',
            'identity',
            'dependencies',
            'external_documentation',
            'build',
            'contacts',
            'versions',
            'names',
        ]

        self._assert_fields_match(expected_fields, Top())
Esempio n. 21
0
    def test_build_fields(self):
        """ Test build group of the metadata config. """
        # build group allows any field
        expected_fields = [
            'key1',
            'key2',
            'key3',
        ]
        top = Top()
        top.build.key1 = 'value1'
        top.build.key2 = 'value2'
        top.build.key3 = 'value3'

        self._assert_fields_match(expected_fields, top.build)
Esempio n. 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')
Esempio n. 23
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')
Esempio n. 24
0
    def test_identity_fields(self):
        """ Test identity group of the metadata config. """
        expected_fields = [
            'bspace',
            'btime',
            'dataset',
            'id',
            'revision',
            'source',
            'subset',
            'type',
            'variation',
            'version',
        ]

        self._assert_fields_match(expected_fields, Top().identity)
Esempio n. 25
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')
Esempio n. 26
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')
Esempio n. 27
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')
Esempio n. 28
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')
Esempio n. 29
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')
Esempio n. 30
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')
Esempio n. 31
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')
Esempio n. 32
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')
Esempio n. 33
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')
Esempio n. 34
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')
Esempio n. 35
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')
Esempio n. 36
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')
Esempio n. 37
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')
Esempio n. 38
0
 def metadata(self):
     """Access process configuarion values as attributes. """
     from ambry.metadata.schema import Top  # cross-module import
     top = Top()
     top.build_from_db(self.dataset)
     return top