Esempio n. 1
0
    def test_should_model_certain_properties_in_DatasetConfig(self):
        # when
        config = DatasetConfig('dev',
                               project_id='my_dev_project_id',
                               dataset_name='None',
                               internal_tables=['table_1', 'table_2'],
                               properties={
                                   'page-routes-v2': 'page-routes-v2-{env}',
                                   'datastore_project_id': 'my_dev_datastore_project',
                                   'output_topic_name': 'projects/{project_id}/topics/mini',
                                   'window_period_seconds': '60'
                               }) \
            .add_configuration('prod',
                               project_id='my_prod_project_id',
                               external_tables={'table': 'table_1'},
                               properties={
                                   'datastore_project_id': 'my_prod_datastore_project'
                               })

        # then
        self.assertEqual(config.resolve_project_id(), 'my_dev_project_id')
        self.assertEqual(config.resolve_project_id('dev'), 'my_dev_project_id')
        self.assertEqual(config.resolve_dataset_name('dev'), 'None')
        self.assertEqual(config.resolve_internal_tables('dev'),
                         ['table_1', 'table_2'])
        self.assertEqual(config.resolve_external_tables('dev'), {})
        self.assertEqual(
            config.resolve_extra_properties('dev'), {
                'page-routes-v2': 'page-routes-v2-dev',
                'datastore_project_id': 'my_dev_datastore_project',
                'output_topic_name': 'projects/my_dev_project_id/topics/mini',
                'window_period_seconds': '60'
            })

        self.assertEqual(config.resolve_project_id('prod'),
                         'my_prod_project_id')
        self.assertEqual(config.resolve_dataset_name('prod'), 'None')
        self.assertEqual(config.resolve_internal_tables('prod'),
                         ['table_1', 'table_2'])
        self.assertEqual(config.resolve_external_tables('prod'),
                         {'table': 'table_1'})
        self.assertEqual(
            config.resolve_extra_properties('prod'), {
                'page-routes-v2': 'page-routes-v2-prod',
                'datastore_project_id': 'my_prod_datastore_project',
                'output_topic_name': 'projects/my_prod_project_id/topics/mini',
                'window_period_seconds': '60'
            })
Esempio n. 2
0
    def test_should_use_default_env_from_master_config_in_DatasetConfig(self):
        # when
        config = DatasetConfig('dev',
                               project_id='my_dev_project_id',
                               properties={
                                   'a': 'dev_',
                               }) \
            .add_configuration('prod',
                               project_id='my_prod_project_id',
                               properties={
                                   'a': 'prod_',
                               })

        # then
        self.assertEqual(config.resolve_project_id(), 'my_dev_project_id')
        self.assertEqual(config.resolve_extra_properties(), { 'a': 'dev_'})