Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed timezone logic and improved README
- Loading branch information
Showing
18 changed files
with
209 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# file GENERATED by distutils, do NOT edit | ||
setup.cfg | ||
setup.py | ||
sqlalchemy_serializer/__init__.py | ||
sqlalchemy_serializer/serializer.py | ||
sqlalchemy_serializer/lib/__init__.py | ||
sqlalchemy_serializer/lib/rules.py | ||
sqlalchemy_serializer/lib/timezones.py | ||
sqlalchemy_serializer/lib/utils.py |
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,4 +1,6 @@ | ||
.PHONY: test | ||
FILE = $(file) | ||
|
||
test: | ||
docker-compose up --build --abort-on-container-exit | ||
TEST_FILE=$(FILE) docker-compose up --build --abort-on-container-exit | ||
|
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,2 +1,3 @@ | ||
SQLAlchemy==1.3.0 | ||
psycopg2==2.7.3.1 | ||
pytz==2019.1 |
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,28 @@ | ||
from .models import (CustomSerializerModel, DATETIME, TIME, DATE, | ||
CUSTOM_TZINFO, CUSTOM_DATE_FORMAT, CUSTOM_TIME_FORMAT, CUSTOM_DATE_TIME_FORMAT) | ||
|
||
|
||
def test_tzinfo_set_in_serializer(get_instance): | ||
""" | ||
Checks how serializer applies tzinfo for datetime objects | ||
:param get_instance: | ||
:return: | ||
""" | ||
i = get_instance(CustomSerializerModel) | ||
data = i.to_dict() | ||
|
||
# Check time/date formats | ||
assert 'date' in data | ||
assert data['date'] == DATE.strftime(CUSTOM_DATE_FORMAT) | ||
assert 'datetime' in data | ||
assert 'time' in data | ||
assert data['time'] == TIME.strftime(CUSTOM_TIME_FORMAT) | ||
|
||
# Timezone info affects only datetime objects | ||
assert data['datetime'] == DATETIME.astimezone(CUSTOM_TZINFO).strftime(CUSTOM_DATE_TIME_FORMAT) | ||
|
||
# Check other fields | ||
assert 'id' in data | ||
assert 'string' in data | ||
assert 'bool' in data | ||
|
Oops, something went wrong.