-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: respect config options in dbt_project.yml #255
Changes from 10 commits
4811888
cd531aa
29a31bd
7912de0
6ae353c
16418ae
1aad991
9afcb79
05ab471
fceb38a
1a4f607
50d2726
5db3c99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os.path | ||
import yaml | ||
|
||
import dbt.project as project | ||
|
||
|
||
def read_config(profiles_dir=None): | ||
if profiles_dir is None: | ||
profiles_dir = default_profiles_dir | ||
|
||
path = os.path.join(profiles_dir, 'profiles.yml') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think passing Previously, this file was assumed to be located at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a good call. since |
||
|
||
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 |
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.
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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does
default_profiles_dir
come from?