Passed
Push — master ( d7ec80...06362c )
by Dave
01:03
created

tests.test_app.TestApp.test_app_update_miner()   A

Complexity

Conditions 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nop 1
dl 0
loc 18
rs 9.65
c 0
b 0
f 0
1
import unittest
2
import backend.fcmutils as utils
3
#from backend.fcmapp import ApplicationService
4
from domain.mining import AvailablePool
5
from messaging.schema import AvailablePoolSchema
6
7
class TestApp(unittest.TestCase):
8
    def test_app_json_serialize(self):
9
        pool = AvailablePool('S9', None, 'url', 'user', 'x', 0)
10
        strpool = utils.jsonserialize(AvailablePoolSchema(), pool)
11
        self.assertTrue(isinstance(strpool, str))
12
        self.assertFalse(strpool.startswith('['))
13
14
    #def test_app_knownpools(self):
15
    #    app = ApplicationService(component='test')
16
    #    app.startup()
17
    #    pools = app.pools.knownpools()
18
    #    self.assertTrue(len(pools) > 0)
19
    #    for pool in pools:
20
    #        self.assertTrue(isinstance(pool, AvailablePool))
21
22
    #def test_app_no_dupe_miners(self):
23
    #    app = ApplicationService(component='test')
24
    #    app.cache.purge()
25
    #    app.startup()
26
    #    original_miners = app.knownminers()
27
    #    miner = Miner("unittest", None, "", "unitip", "unitport", "", "")
28
    #    #add the test miner
29
    #    app.updateknownminer(miner)
30
    #    miners_withtest = app.knownminers()
31
    #    #put same in cache should not increase count
32
    #    app.updateknownminer(miner)
33
    #    miners_afterputtingtwice = app.knownminers()
34
    #    self.assertTrue(len(miners_withtest) == len(miners_afterputtingtwice))
35
36
    #def test_app_update_miner(self):
37
    #    app = ApplicationService(component='test')
38
    #    app.cache.purge()
39
    #    app.startup()
40
    #    original_miners = app.knownminers()
41
    #    miner = Miner("unittest", None, "", "unitip", "unitport", "", "")
42
    #    #add the test miner
43
    #    app.updateknownminer(miner)
44
    #    miners_withtest = app.knownminers()
45
    #    #put same in cache should not increase count
46
    #    #this simulates a miner getting queries and minerid has changed
47
    #    miner_updated = Miner("unittest", None, "", "unitip", "unitport", "", "")
48
    #    miner_updated.minerid="unittest_unique"
49
    #    app.updateknownminer(miner_updated)
50
    #    miners_afterputtingtwice = app.knownminers()
51
    #    self.assertTrue(len(miners_withtest) == len(miners_afterputtingtwice))
52
    #    miner_from_cache = app.getknownminer(miner_updated)
53
    #    self.assertIsNotNone(miner_from_cache)
54
55
if __name__ == '__main__':
56
    unittest.main()
57