mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 19:32:33 +03:00
fix flaky datetime test with fixed values
This commit is contained in:
parent
eb7966eca7
commit
f42d6965ad
|
@ -27,8 +27,19 @@ class Query(ObjectType):
|
||||||
schema = Schema(query=Query)
|
schema = Schema(query=Query)
|
||||||
|
|
||||||
|
|
||||||
def test_datetime_query():
|
@pytest.fixture
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
def now():
|
||||||
|
utc_datetime = datetime.datetime(2019, 5, 25, 5, 30, 15, 10, pytz.utc)
|
||||||
|
return utc_datetime
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def time(now):
|
||||||
|
time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)
|
||||||
|
return time
|
||||||
|
|
||||||
|
|
||||||
|
def test_datetime_query(now):
|
||||||
isoformat = now.isoformat()
|
isoformat = now.isoformat()
|
||||||
|
|
||||||
result = schema.execute("""{ datetime(in: "%s") }""" % isoformat)
|
result = schema.execute("""{ datetime(in: "%s") }""" % isoformat)
|
||||||
|
@ -36,8 +47,8 @@ def test_datetime_query():
|
||||||
assert result.data == {"datetime": isoformat}
|
assert result.data == {"datetime": isoformat}
|
||||||
|
|
||||||
|
|
||||||
def test_date_query():
|
def test_date_query(now):
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc).date()
|
now = now.date()
|
||||||
isoformat = now.isoformat()
|
isoformat = now.isoformat()
|
||||||
|
|
||||||
result = schema.execute("""{ date(in: "%s") }""" % isoformat)
|
result = schema.execute("""{ date(in: "%s") }""" % isoformat)
|
||||||
|
@ -45,9 +56,7 @@ def test_date_query():
|
||||||
assert result.data == {"date": isoformat}
|
assert result.data == {"date": isoformat}
|
||||||
|
|
||||||
|
|
||||||
def test_time_query():
|
def test_time_query(time):
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
|
||||||
time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)
|
|
||||||
isoformat = time.isoformat()
|
isoformat = time.isoformat()
|
||||||
|
|
||||||
result = schema.execute("""{ time(at: "%s") }""" % isoformat)
|
result = schema.execute("""{ time(at: "%s") }""" % isoformat)
|
||||||
|
@ -85,8 +94,7 @@ def test_bad_time_query():
|
||||||
assert result.data is None
|
assert result.data is None
|
||||||
|
|
||||||
|
|
||||||
def test_datetime_query_variable():
|
def test_datetime_query_variable(now):
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
|
||||||
isoformat = now.isoformat()
|
isoformat = now.isoformat()
|
||||||
|
|
||||||
# test datetime variable provided as Python datetime
|
# test datetime variable provided as Python datetime
|
||||||
|
@ -106,8 +114,8 @@ def test_datetime_query_variable():
|
||||||
assert result.data == {"datetime": isoformat}
|
assert result.data == {"datetime": isoformat}
|
||||||
|
|
||||||
|
|
||||||
def test_date_query_variable():
|
def test_date_query_variable(now):
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc).date()
|
now = now.date()
|
||||||
isoformat = now.isoformat()
|
isoformat = now.isoformat()
|
||||||
|
|
||||||
# test date variable provided as Python date
|
# test date variable provided as Python date
|
||||||
|
@ -125,9 +133,7 @@ def test_date_query_variable():
|
||||||
assert result.data == {"date": isoformat}
|
assert result.data == {"date": isoformat}
|
||||||
|
|
||||||
|
|
||||||
def test_time_query_variable():
|
def test_time_query_variable(time):
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
|
||||||
time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)
|
|
||||||
isoformat = time.isoformat()
|
isoformat = time.isoformat()
|
||||||
|
|
||||||
# test time variable provided as Python time
|
# test time variable provided as Python time
|
||||||
|
|
Loading…
Reference in New Issue
Block a user