def test_empty_storage(self):
     cfg = Configuration(
         os.path.join(os.getenv('KBC_DATADIR', ''), '..', 'data2'))
     self.assertEqual(cfg.tables_output_mapping, [])
     self.assertEqual(cfg.files_output_mapping, [])
     self.assertEqual(cfg.tables_input_mapping, [])
     self.assertEqual(cfg.files_input_mapping, [])
     self.assertEqual(cfg.parameters, {})
    def test_get_input_mappings(self):
        cfg = Configuration(os.environ["KBC_DATADIR"])
        tables = cfg.tables_input_mapping

        self.assertEqual(len(tables), 2)
        for table in tables:
            if table['destination'] == 'sample.csv':
                self.assertEqual(table['source'], 'in.c-main.test')
            else:
                self.assertEqual('in.c-main.test2', table['source'])
 def test_get_parameters(self):
     cfg = Configuration(os.environ["KBC_DATADIR"])
     params = cfg.parameters
     self.assertEqual({
         'fooBar': {
             'bar': 24,
             'foo': 42
         },
         'baz': 'bazBar'
     }, params)
     self.assertEqual(params['fooBar']['foo'], 42)
     self.assertEqual(params['fooBar']['bar'], 24)
 def test_get_input_mappings_with_column_types(self):
     path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         'data_examples', 'data4')
     cfg = Configuration(path)
     tables = cfg.tables_input_mapping
     coltypes = tables[0].column_types[0]
     source = coltypes.source
     self.assertEqual(source, "Sales")
     column_type = coltypes.type
     self.assertEqual(column_type, "VARCHAR")
     destination = coltypes.destination
     self.assertEqual(destination, "id")
     length = coltypes.length
     self.assertEqual(length, "255")
     nullable = coltypes.nullable
     self.assertEqual(nullable, False)
     convert_empty_values_to_null = coltypes.convert_empty_values_to_null
     self.assertEqual(convert_empty_values_to_null, False)
 def test_get_oauthapi_appkey(self):
     cfg = Configuration(os.environ["KBC_DATADIR"])
     self.assertEqual(cfg.oauth_credentials.appKey, "myappkey")
 def test_get_oauthapi_data(self):
     cfg = Configuration(os.environ["KBC_DATADIR"])
     self.assertDictEqual(cfg.oauth_credentials.data, {"mykey": "myval"})
 def test_get_authorization(self):
     cfg = Configuration(os.environ["KBC_DATADIR"])
     auth = cfg.oauth_credentials
     # self.assertEqual(auth['id'], "123456")
     self.assertEqual(auth["id"], "main")
 def test_empty_params(self):
     cfg = Configuration(
         os.path.join(os.getenv('KBC_DATADIR', ''), '..', 'data3'))
     self.assertEqual([], cfg.tables_output_mapping)
     self.assertEqual([], cfg.files_output_mapping)
     self.assertEqual({}, cfg.parameters)
 def test_get_output_mapping(self):
     cfg = Configuration(os.environ["KBC_DATADIR"])
     tables = cfg.tables_output_mapping
     self.assertEqual(len(tables), 2)
     self.assertEqual(tables[0]['source'], 'results.csv')
     self.assertEqual(tables[1]['source'], 'results-new.csv')
 def test_get_action_empty_config(self):
     cfg = Configuration(
         os.path.join(os.getenv('KBC_DATADIR', ''), '..', 'data2'))
     self.assertEqual(cfg.action, '')
    def test_get_action(self):
        cfg = Configuration(os.environ["KBC_DATADIR"])

        self.assertEqual(cfg.action, 'run')
 def test_missing_config(self):
     with self.assertRaisesRegex(
             ValueError, "Configuration file config.json not found"):
         Configuration('/non-existent/')