Last active
August 29, 2015 13:56
-
-
Save nickretallack/8985745 to your computer and use it in GitHub Desktop.
Test cases for my patch to ArrowType.
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
#!/usr/bin/env py.test | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy import create_engine, Column | |
from sqlalchemy_utils.types.arrow import ArrowType | |
import arrow | |
Base = declarative_base() | |
class Thing(Base): | |
__tablename__ = u'thing' | |
time = Column(ArrowType, primary_key=True) | |
engine = create_engine('postgres://localhost:5432/util_test', echo=True) | |
Base.metadata.create_all(engine) | |
Session = sessionmaker(bind=engine) | |
session = Session() | |
def test_utc(): | |
time = arrow.utcnow() | |
thing = Thing(time=time) | |
session.add(thing) | |
assert thing.time == time | |
session.commit() | |
assert thing.time == time | |
def test_other_tz(): | |
time = arrow.utcnow() | |
local = time.to('US/Pacific') | |
thing = Thing(time=local) | |
session.add(thing) | |
assert thing.time == time == local | |
session.commit() | |
assert thing.time == time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment