3
from pytest.Tiab import TiabTest
4
from armoryengine.ALL import *
5
from announcefetch import AnnounceDataFetcher
9
forceTestURL = 'https://s3.amazonaws.com/bitcoinarmory-testing/testannounce.txt'
10
fetchDump = './fetchedFiles'
12
class AnnouncementTester(TiabTest):
20
def testNoStart(self):
21
adf = AnnounceDataFetcher(forceTestURL, fetchDir=fetchDump)
22
adf.setFetchInterval(20)
24
self.assertFalse(adf.isDisabled())
25
self.assertFalse(adf.atLeastOneSuccess())
28
adf = AnnounceDataFetcher(forceTestURL, fetchDir=fetchDump)
29
adf.setFetchInterval(20)
32
print ' Running:', adf.isRunning(),
33
print ' OneSuccess:', adf.atLeastOneSuccess(),
34
print ' #Files',adf.numFiles()
36
print 'Attempting to fetch before ADF is started'
37
d = adf.getAnnounceFile('notify')
39
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
41
print 'Attempting to fetch before ADF is started (forced)'
42
d = adf.getAnnounceFile('notify', forceCheck=True)
44
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
54
print ' Running:', adf.isRunning(),
55
print ' OneSuccess:', adf.atLeastOneSuccess(),
56
print ' #Files',adf.numFiles()
58
if 10<t<11 or 14<t<15:
60
d = adf.getAnnounceFile('notify')
62
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
64
print 'took %0.6f seconds' % (RightNow() - s)
66
if 30<t<31 or 34<t<35:
68
d = adf.getAnnounceFile('notify', forceCheck=True)
70
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
72
print 'took %0.6f seconds' % (RightNow() - s)
77
if not adf.isRunning():
78
print 'Attempting to fetch after shutdown'
79
d = adf.getAnnounceFile('notify')
81
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
83
print 'Attempting to fetch after shutdown (forced)'
84
d = adf.getAnnounceFile('notify', forceCheck=True)
86
print 'LENGTH OF NOTIFY FILE:', (len(d) if d else 0)
90
except KeyboardInterrupt:
94
# Running tests with "python <module name>" will NOT work for any Armory tests
95
# You must run tests with "python -m unittest <module name>" or run all tests with "python -m unittest discover"
96
# if __name__ == "__main__":