Passed
Push — development/test ( 24302c...f5ca2a )
by Daniel
01:16
created

TestBasicNeeds   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 35
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestBasicNeeds.test_numbers_with_leading_zero() 0 41 3
1
import os
2
from sources.common.BasicNeeds import BasicNeeds
3
# package to facilitate multiple operation system operations
4
import unittest
5
6
7
class TestBasicNeeds(unittest.TestCase):
8
9
    def test_numbers_with_leading_zero(self):
10
        pair_values = [
11
            {
12
                'given': '1',
13
                'leading_zeros': 2,
14
                'expected': '01'
15
            },
16
            {
17
                'given': '1',
18
                'leading_zeros': 10,
19
                'expected': '0000000001'
20
            },
21
            {
22
                'given': '1',
23
                'leading_zeros': 1,
24
                'expected': '1'
25
            }
26
        ]
27
        bn = BasicNeeds()
28
        for current_pair in pair_values:
29
            
30
            value_to_assert = bn.fn_numbers_with_leading_zero(current_pair['given'],
31
                                                              current_pair['leading_zeros'])
32
            self.assertEqual(value_to_assert, current_pair['expected'],
33
                             'Provided values was "' + value_to_assert + '", Expected')
34
        pair_failing_values = [
35
            {
36
                'given': '1',
37
                'leading_zeros': 2,
38
                'expected': '02'
39
            },
40
            {
41
                'given': '1',
42
                'leading_zeros': 0,
43
                'expected': ''
44
            }
45
        ]
46
        for current_pair in pair_failing_values:
47
            value_to_assert = bn.fn_numbers_with_leading_zero(current_pair['given'],
48
                                                              current_pair['leading_zeros'])
49
            self.assertNotEqual(value_to_assert, current_pair['expected'])
50
51
52
if __name__ == '__main__':
53
    unittest.main()
54