Beispiel #1
0
 def test_table_defaults(self):
     table_1 = UnparsedSourceTableDefinition(name='table1')
     table_2 = UnparsedSourceTableDefinition(
         name='table2',
         description='table 2',
         quoting=Quoting(database=True),
     )
     source = self.ContractType(
         name='foo',
         tables=[table_1, table_2]
     )
     from_dict = {
         'name': 'foo',
         'tables': [
             {'name': 'table1'},
             {
                 'name': 'table2',
                 'description': 'table 2',
                 'quoting': {'database': True},
             },
         ],
     }
     to_dict = {
         'name': 'foo',
         'description': '',
         'loader': '',
         'freshness': {},
         'quoting': {},
         'meta': {},
         'tables': [
             {
                 'name': 'table1',
                 'description': '',
                 'docs': {'show': True},
                 'tests': [],
                 'columns': [],
                 'quoting': {},
                 'freshness': {},
                 'meta': {},
                 'tags': [],
             },
             {
                 'name': 'table2',
                 'description': 'table 2',
                 'docs': {'show': True},
                 'tests': [],
                 'columns': [],
                 'quoting': {'database': True},
                 'freshness': {},
                 'meta': {},
                 'tags': [],
             },
         ],
         'tags': [],
     }
     self.assert_from_dict(source, from_dict)
     self.assert_symmetric(source, to_dict)
     pickle.loads(pickle.dumps(source))
Beispiel #2
0
 def test_basic(self):
     source_def_dict = {
         'package_name': 'test',
         'root_path': '/root',
         'path': '/root/models/sources.yml',
         'original_file_path': '/root/models/sources.yml',
         'database': 'some_db',
         'schema': 'some_schema',
         'fqn': ['test', 'source', 'my_source', 'my_source_table'],
         'source_name': 'my_source',
         'name': 'my_source_table',
         'source_description': 'my source description',
         'loader': 'stitch',
         'identifier': 'my_source_table',
         'resource_type': str(NodeType.Source),
         'description': '',
         'columns': {},
         'quoting': {},
         'unique_id': 'test.source.my_source.my_source_table',
         'meta': {},
         'source_meta': {},
         'tags': [],
         'config': {
             'enabled': True,
         }
     }
     source_def = self.ContractType(
         columns={},
         database='some_db',
         description='',
         fqn=['test', 'source', 'my_source', 'my_source_table'],
         identifier='my_source_table',
         loader='stitch',
         name='my_source_table',
         original_file_path='/root/models/sources.yml',
         package_name='test',
         path='/root/models/sources.yml',
         quoting=Quoting(),
         resource_type=NodeType.Source,
         root_path='/root',
         schema='some_schema',
         source_description='my source description',
         source_name='my_source',
         unique_id='test.source.my_source.my_source_table',
         tags=[],
         config=SourceConfig(),
     )
     self.assert_symmetric(source_def, source_def_dict)
     minimum = self._minimum_dict()
     self.assert_from_dict(source_def, minimum)
     pickle.loads(pickle.dumps(source_def))
 def test_contents(self):
     empty = self.ContractType(
         name='foo',
         description='a description',
         quoting=Quoting(database=False),
         loader='some_loader',
         freshness=FreshnessThreshold(),
         tables=[],
     )
     dct = {
         'name': 'foo',
         'description': 'a description',
         'quoting': {'database': False},
         'loader': 'some_loader',
         'freshness': {},
         'tables': [],
     }
     self.assert_symmetric(empty, dct)