-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Make run_started_at timezone aware Set run_started_at timezone to UTC Enable timezone change in models Extend requirements Extend tests * Address comments from code review Create modules namespace to context Move pytz to modules Add new dependencies to setup.py
- Loading branch information
Showing
7 changed files
with
77 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
freezegun==0.3.9 | ||
nose>=1.3.7 | ||
mock>=1.3.0 | ||
pep8>=1.6.2 | ||
pytz==2017.2 | ||
bumpversion==0.5.3 | ||
coverage==4.2 | ||
tox==2.5.0 |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
argparse>=1.2.1 | ||
freezegun==0.3.9 | ||
Jinja2>=2.8 | ||
pytz==2017.2 | ||
PyYAML>=3.11 | ||
psycopg2==2.7.1 | ||
sqlparse==0.2.3 | ||
|
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,10 @@ | ||
|
||
{{ | ||
config( | ||
materialized='table' | ||
) | ||
}} | ||
|
||
select | ||
'{{ run_started_at.astimezone(modules.pytz.timezone("America/New_York")) }}' as run_started_at_est, | ||
'{{ run_started_at }}' as run_started_at_utc |
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,55 @@ | ||
from freezegun import freeze_time | ||
from nose.plugins.attrib import attr | ||
from test.integration.base import DBTIntegrationTest | ||
|
||
|
||
class TestTimezones(DBTIntegrationTest): | ||
|
||
def setUp(self): | ||
DBTIntegrationTest.setUp(self) | ||
|
||
@property | ||
def schema(self): | ||
return "timezones_025" | ||
|
||
@property | ||
def models(self): | ||
return "test/integration/025_timezones_test/models" | ||
|
||
@property | ||
def profile_config(self): | ||
return { | ||
'test': { | ||
'outputs': { | ||
'dev': { | ||
'type': 'postgres', | ||
'threads': 1, | ||
'host': 'database', | ||
'port': 5432, | ||
'user': "root", | ||
'pass': "password", | ||
'dbname': 'dbt', | ||
'schema': self.unique_schema() | ||
}, | ||
}, | ||
'target': 'dev' | ||
} | ||
} | ||
|
||
@property | ||
def query(self): | ||
return """ | ||
select | ||
run_started_at_est, | ||
run_started_at_utc | ||
from {schema}.timezones | ||
""".format(schema=self.unique_schema()) | ||
|
||
@freeze_time("2017-01-01 03:00:00", tz_offset=0) | ||
@attr(type='postgres') | ||
def test_run_started_at(self): | ||
self.run_dbt(['run']) | ||
result = self.run_sql(self.query, fetch='all')[0] | ||
est, utc = result | ||
self.assertEqual(utc, '2017-01-01 03:00:00+00:00') | ||
self.assertEqual(est, '2016-12-31 22:00:00-05:00') |