Ejemplo n.º 1
0
    def test_get_dynamic_table_fields(self):
        """
        Get table fields when a schema file is not defined.
        """
        # pre-conditions
        expected_fields = [{
            "type": "integer",
            "name": "foo_id",
            "mode": "nullable",
            "description": "The foo_id used in the foo table."
        }, {
            "type":
            "string",
            "name":
            "src_id",
            "mode":
            "nullable",
            "description":
            "The provenance of the data associated with the foo_id."
        }]
        table = 'foo'
        ext_table = 'foo' + gen_ext.EXT_TABLE_SUFFIX

        # test
        with self.assertLogs(level='INFO') as cm:
            actual = gen_ext.get_table_fields(table, ext_table)

        # post conditions
        static_msg = 'using dynamic extension table schema for table:'
        self.assertIn(static_msg, cm.output[0])
        self.assertCountEqual(expected_fields, actual)
    def test_get_obs_fields(self):
        # pre-conditions
        table = common.OBSERVATION
        expected = self.obs_fields

        # test
        actual = gen_ext.get_table_fields(table)

        # post conditions
        self.assertCountEqual(expected, actual)
Ejemplo n.º 3
0
    def test_get_schema_defined_table_fields(self):
        """
        Get table fields when a schema file is defined.
        """
        # pre-conditions
        table = common.OBSERVATION
        ext_table = common.OBSERVATION + gen_ext.EXT_TABLE_SUFFIX
        table_path = os.path.join(fields_path, 'extension_tables',
                                  ext_table + '.json')
        with open(table_path, 'r') as schema:
            expected = json.load(schema)

        # test
        with self.assertLogs(level='INFO') as cm:
            actual = gen_ext.get_table_fields(table, ext_table)

        # post conditions
        static_msg = 'using json schema file definition for table:'
        self.assertIn(static_msg, cm.output[0])
        self.assertCountEqual(expected, actual)