-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: respect config options in dbt_project.yml (#255)
* respect config options in dbt_project.yml * add unit test harness
- Loading branch information
Showing
9 changed files
with
140 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os.path | ||
import yaml | ||
|
||
import dbt.project as project | ||
|
||
|
||
def read_config(profiles_dir): | ||
# TODO: validate profiles_dir | ||
path = os.path.join(profiles_dir, 'profiles.yml') | ||
|
||
if os.path.isfile(path): | ||
with open(path, 'r') as f: | ||
profile = yaml.safe_load(f) | ||
return profile.get('config', {}) | ||
|
||
return {} | ||
|
||
|
||
def send_anonymous_usage_stats(profiles_dir): | ||
config = read_config(profiles_dir) | ||
|
||
if config is not None and config.get("send_anonymous_usage_stats") == False: | ||
return False | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
. /usr/src/app/test/setup.sh | ||
workon dbt | ||
|
||
cd /usr/src/app | ||
tox -e integration-py27,integration-py35 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import unittest | ||
import yaml | ||
|
||
import dbt.config | ||
|
||
if os.name == 'nt': | ||
TMPDIR = 'c:/Windows/TEMP' | ||
else: | ||
TMPDIR = '/tmp' | ||
|
||
class ConfigTest(unittest.TestCase): | ||
|
||
def set_up_empty_config(self): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
with open(profiles_path, 'w') as f: | ||
f.write(yaml.dump({})) | ||
|
||
def set_up_config_options(self, send_anonymous_usage_stats=False): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
with open(profiles_path, 'w') as f: | ||
f.write(yaml.dump({ | ||
'config': { | ||
'send_anonymous_usage_stats': send_anonymous_usage_stats | ||
} | ||
})) | ||
|
||
def tearDown(self): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
try: | ||
os.remove(profiles_path) | ||
except: | ||
pass | ||
|
||
def test__implicit_opt_in(self): | ||
self.set_up_empty_config() | ||
self.assertTrue(dbt.config.send_anonymous_usage_stats(TMPDIR)) | ||
|
||
def test__explicit_opt_out(self): | ||
self.set_up_config_options(send_anonymous_usage_stats=False) | ||
self.assertFalse(dbt.config.send_anonymous_usage_stats(TMPDIR)) | ||
|
||
def test__explicit_opt_in(self): | ||
self.set_up_config_options(send_anonymous_usage_stats=True) | ||
self.assertTrue(dbt.config.send_anonymous_usage_stats(TMPDIR)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters