Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_datetime_string():
s = "2017-12-24T20:48:25.90349Z"
t = datetime.datetime(2017, 12, 24, 20, 48, 25, 903490, tzinfo=tzutc())
assert utils.parse_datetime_string(s) == t
assert utils.parse_datetime_string(None) is None
def test_parse_datetime_string():
s = "2017-12-24T20:48:25.90349Z"
t = datetime.datetime(2017, 12, 24, 20, 48, 25, 903490, tzinfo=tzutc())
assert utils.parse_datetime_string(s) == t
assert utils.parse_datetime_string(None) is None
mutation($value: String!
$type: String!) {
v2ChangeStake(value: $value
type: $type) {
dueDate
requestedAmount
status
type
}
}
'''
arguments = {'value': str(nmr), 'type': action}
result = self.raw_query(query, arguments, authorization=True)
stake = result['data']['v2ChangeStake']
utils.replace(stake, "requestedAmount", utils.parse_float_string)
utils.replace(stake, "dueDate", utils.parse_datetime_string)
return stake
openTime
resolveTime
resolvedGeneral
resolvedStaking
}
}
}
}
"""
data = self.raw_query(query, authorization=True)['data']
payments = data['user']
# convert strings to python objects
for p in payments['payments']:
utils.replace(p['round'], "openTime", utils.parse_datetime_string)
utils.replace(p['round'], "resolveTime",
utils.parse_datetime_string)
utils.replace(p, "usdAmount", utils.parse_float_string)
utils.replace(p, "nmrAmount", utils.parse_float_string)
for p in payments['reputationPayments']:
utils.replace(p, "nmrAmount", utils.parse_float_string)
utils.replace(p, "insertedAt", utils.parse_datetime_string)
for p in payments['otherUsdIssuances']:
utils.replace(p, "usdAmount", utils.parse_float_string)
utils.replace(p, "insertedAt", utils.parse_datetime_string)
return payments
False
"""
query = '''
query($tournament: Int!) {
rounds(tournament: $tournament
number: 0) {
number
openTime
}
}
'''
arguments = {'tournament': tournament}
raw = self.raw_query(query, arguments)['data']['rounds'][0]
if raw is None:
return False
open_time = utils.parse_datetime_string(raw['openTime'])
now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
is_new_round = open_time > now - datetime.timedelta(hours=hours)
return is_new_round