|
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import unittest |
8 | | -from etl_manager.meta import DatabaseMeta, TableMeta, read_database_folder, read_table_json, _agnostic_to_glue_spark_dict, MetaColumnTypeMismatch |
| 8 | +from etl_manager.meta import DatabaseMeta, TableMeta, read_database_folder, read_table_json, _agnostic_to_glue_spark_dict, MetaColumnTypeMismatch, _get_spec |
9 | 9 | from etl_manager.utils import _end_with_slash, _validate_string, _glue_client, read_json, _remove_final_slash |
10 | 10 | from etl_manager.etl import GlueJob |
11 | 11 | import boto3 |
@@ -158,6 +158,16 @@ def test_table_to_dict(self) : |
158 | 158 |
|
159 | 159 | self.assertDictEqual(test_dict, expected_dict) |
160 | 160 |
|
| 161 | + # Test file with glue specific |
| 162 | + expected_dict2 = read_json('example/meta_data/db1/pay.json') |
| 163 | + test_dict2 = db.table('pay').to_dict() |
| 164 | + |
| 165 | + # Null out schema as may need changing when on branch but still need to unit test |
| 166 | + expected_dict2["$schema"] = '' |
| 167 | + test_dict2["$schema"] = '' |
| 168 | + |
| 169 | + self.assertDictEqual(test_dict2, expected_dict2) |
| 170 | + |
161 | 171 | def test_db_table_names(self) : |
162 | 172 | db = read_database_folder('example/meta_data/db1/') |
163 | 173 | t = all(t in ['teams', 'employees', 'pay'] for t in db.table_names) |
@@ -189,6 +199,13 @@ def test_glue_specific_table(self): |
189 | 199 | glue_def = t.glue_table_definition("db_path") |
190 | 200 | self.assertTrue(t.glue_table_definition("db_path")["Parameters"]['skip.header.line.count'] == '1') |
191 | 201 |
|
| 202 | + def test_glue_table_definition_doesnt_overwrite_base_spec(self) : |
| 203 | + expected_dict = _get_spec('base') |
| 204 | + db = read_database_folder('example/meta_data/db1/') |
| 205 | + glue_def_dump = db.table('pay').glue_table_definition() |
| 206 | + |
| 207 | + self.assertDictEqual(expected_dict, _get_spec('base')) |
| 208 | + |
192 | 209 | def test_add_remove_table(self) : |
193 | 210 | db = read_database_folder('example/meta_data/db1/') |
194 | 211 | self.assertRaises(ValueError, db.remove_table, 'not_a_table') |
|
0 commit comments