Passed
Push — master ( 7418b1...fb1c6a )
by Dave
01:00
created

tests.test_service   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 49
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A TestService.test_pool_3() 0 4 1
A TestService.test_pool_2() 0 4 1
A TestService.test_pool_service_get() 0 3 1
A TestService.test_configuration() 0 4 1
A TestService.test_telegram() 0 6 1
A TestService.test_pool_service() 0 9 1
A TestService.test_pool_1() 0 4 1
A TestService.test_pool_service_findpool() 0 3 1
A TestService.test_configuration_isenabled() 0 5 1
1
import unittest
2
import backend.fcmservice as service
3
import domain.mining as mining
4
5
class TestService(unittest.TestCase):
6
    def test_pool_service(self):
7
        svc = service.PoolService(None, None)
8
        miner = mining.Miner('test')
9
        dto = svc.serialize(miner)
10
        self.assertTrue(dto)
11
        pool = mining.Pool('','','','',1)
12
        dto = svc.serialize(pool)
13
        self.assertTrue(dto)
14
        self.assertFalse(svc.serialize('x'))
15
16
    def test_pool_service_get(self):
17
        svc = service.PoolService(None, None)
18
        self.assertTrue(svc.get_all_pools())
19
20
    def test_pool_service_findpool(self):
21
        svc = service.PoolService(None, None)
22
        self.assertFalse(svc.findpool(mining.MinerCurrentPool(None)))
23
24
    def test_pool_1(self):
25
        svc = service.PoolService(None, None)
26
        env = svc.createmessageenvelope()
27
        self.assertTrue(env)
28
29
    def test_pool_2(self):
30
        svc = service.PoolService(None, None)
31
        env = svc.createmessageenvelope()
32
        self.assertTrue(svc.serializemessageenvelope(env))
33
34
    def test_pool_3(self):
35
        svc = service.PoolService(None, None)
36
        env = svc.createmessageenvelope()
37
        self.assertTrue(svc.deserializemessageenvelope(svc.serializemessageenvelope(env)))
38
39
    def test_configuration(self):
40
        config = service.Configuration({'a':'b'})
41
        self.assertTrue(config.get('a'))
42
        self.assertFalse(config.get('x'))
43
44
    def test_configuration_isenabled(self):
45
        config = service.Configuration({'true.enabled':'true','false.enabled':'false'})
46
        self.assertTrue(config.is_enabled('true'))
47
        self.assertFalse(config.is_enabled('false'))
48
        self.assertFalse(config.is_enabled('x'))
49
50
    def test_telegram(self):
51
        config = service.Configuration({'true.enabled':'true','false.enabled':'false'})
52
        tele = service.Telegram(config, None)
53
        self.assertTrue(tele)
54
        tele.sendmessage('x')
55
        tele.sendphoto('x')
56
57
if __name__ == '__main__':
58
    unittest.main()
59