2016-09-30 06:06:07 +02:00
|
|
|
import datetime
|
|
|
|
import time
|
2017-02-18 01:59:57 +01:00
|
|
|
import binascii
|
|
|
|
import os
|
2016-09-30 06:06:07 +02:00
|
|
|
|
|
|
|
import mock
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_TIMESTAMP = datetime.datetime(2016, 1, 1)
|
|
|
|
DEFAULT_ISO_TIME = time.mktime(DEFAULT_TIMESTAMP.timetuple())
|
|
|
|
|
|
|
|
|
2017-02-18 01:59:57 +01:00
|
|
|
def random_lbry_hash():
|
|
|
|
return binascii.b2a_hex(os.urandom(48))
|
|
|
|
|
2016-09-30 06:06:07 +02:00
|
|
|
def resetTime(test_case, timestamp=DEFAULT_TIMESTAMP):
|
|
|
|
iso_time = time.mktime(timestamp.timetuple())
|
|
|
|
patcher = mock.patch('time.time')
|
|
|
|
patcher.start().return_value = iso_time
|
|
|
|
test_case.addCleanup(patcher.stop)
|
|
|
|
|
|
|
|
patcher = mock.patch('lbrynet.core.utils.now')
|
|
|
|
patcher.start().return_value = timestamp
|
|
|
|
test_case.addCleanup(patcher.stop)
|
|
|
|
|
|
|
|
patcher = mock.patch('lbrynet.core.utils.utcnow')
|
|
|
|
patcher.start().return_value = timestamp
|
|
|
|
test_case.addCleanup(patcher.stop)
|