Skip to content

Instantly share code, notes, and snippets.

@nickretallack
Last active August 29, 2015 13:56
Show Gist options
  • Save nickretallack/8985745 to your computer and use it in GitHub Desktop.
Save nickretallack/8985745 to your computer and use it in GitHub Desktop.
Test cases for my patch to ArrowType.
#!/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