Skip to content

Commit

Permalink
Handle case when there is no db-facts config (#21)
Browse files Browse the repository at this point in the history
* Add test for empty config

* Handle empty config case
  • Loading branch information
vinceatbluelabs authored Mar 7, 2020
1 parent f2886fd commit 6160053
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion db_facts/db_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def db_config(dbcli_config: DBCLIConfig, db_name: DBName) -> Optional[DBConfig]:
dbs = dbcli_config['dbs']
dbs = dbcli_config.get('dbs', {})

config_name = "-".join(db_name)

Expand Down
2 changes: 1 addition & 1 deletion metrics/bigfiles_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
326
337
2 changes: 1 addition & 1 deletion metrics/coverage_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
97.9100
97.9200
2 changes: 1 addition & 1 deletion metrics/mypy_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72.6500
72.7300
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys


VERSION = '3.0.1'
VERSION = '3.0.2'


# From https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
Expand Down
11 changes: 11 additions & 0 deletions tests/test_db_info.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import db_facts
from db_facts.db_info import db
import unittest
from unittest.mock import patch
Expand Down Expand Up @@ -79,3 +80,13 @@ def test_db_info_two_level_with_one_level_config(self,
assert_called_with(['frazzle', 'mumble'],
mock_dbcli_config['dbs']['frazzle'],
mock_dbcli_config)

def test_db_info_empty_config(self,
mock_lpass_field,
mock_db_info_from_lpass,
mock_pull_jinja_context):
mock_pull_jinja_context.return_value = ({}, {})
with self.assertRaises(db_facts.errors.UserErrorException) as e:
db(['frazzle', 'mumble'], dbcli_config={})
self.assertTrue('frazzle-mumble is not a valid DB name' in str(e.exception),
str(e.exception))

0 comments on commit 6160053

Please sign in to comment.