Completed
Push — master ( f4c0a2...4a0808 )
by Oleksandr
03:35
created

RegimentsTestCase.test_create_regiments()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
import unittest
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
from verboselib import use_language, drop_language
0 ignored issues
show
introduced by
Unable to import 'verboselib'
Loading history...
4
5
from il2fb.commons.organization import AirForces
0 ignored issues
show
Bug introduced by
The name commons does not seem to exist in module il2fb.
Loading history...
introduced by
Unable to import 'il2fb.commons.organization'
Loading history...
6
7
from il2fb.regiments import Regiment, Regiments, RegimentInfoLoader
0 ignored issues
show
Unused Code introduced by
Unused RegimentInfoLoader imported from il2fb.regiments
Loading history...
8
9
10
class RegimentTestCase(unittest.TestCase):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
11
12
  def tearDown(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
13
    drop_language()
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
14
15
  def test_create_regiment(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
16
    testee = Regiment(AirForces.vvs_rkka, "foo")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
17
18
    self.assertEqual(testee.air_force, AirForces.vvs_rkka)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
19
    self.assertEqual(testee.code_name, "foo")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
20
21
  def test_unknown_verbose_name(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
22
    testee = Regiment(AirForces.vvs_rkka, "foo")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
23
24
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
25
    self.assertIsNone(testee.verbose_name)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
26
27
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
28
    self.assertIsNone(testee.verbose_name)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
29
30
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
31
    self.assertIsNone(testee.verbose_name)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
32
33
  def test_valid_verbose_name(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
34
    testee = Regiment(AirForces.vvs_rkka, "1st_AE_1AR")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
35
36
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
37
    self.assertEqual(testee.verbose_name, "OIR AE of 1st AG VVS")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
38
39
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
40
    self.assertEqual(testee.verbose_name, "ОИРАЭ 1-й АГ")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
41
42
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
43
    self.assertEqual(testee.verbose_name, "OIR AE of 1st AG VVS")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
44
45
  def test_verbose_name_missing_translation(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
46
    testee = Regiment(AirForces.usn, "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
47
48
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
49
    self.assertEqual(testee.verbose_name, "VT-9 USS Essex CV-9")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
50
51
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
52
    self.assertEqual(testee.verbose_name, "VT-9 USS Essex CV-9")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
53
54
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
55
    self.assertEqual(testee.verbose_name, "VT-9 USS Essex CV-9")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
56
57
  def test_unknown_help_text(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
58
    testee = Regiment(AirForces.vvs_rkka, "foo")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
59
60
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
61
    self.assertIsNone(testee.help_text)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
62
63
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
64
    self.assertIsNone(testee.help_text)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
65
66
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
67
    self.assertIsNone(testee.help_text)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
68
69
  def test_valid_help_text(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
70
    testee = Regiment(AirForces.vvs_rkka, "1st_AE_1AR")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
71
72
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
73
    self.assertEqual(testee.help_text, "OIR AE of 1st AG VVS")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
74
75
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
76
    self.assertEqual(
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
77
      testee.help_text,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
78
      (
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
79
        "Отдельная Истребительно-Разведываетльния Авиаэскадрилья "
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
80
        "1-й Авиагруппы"
81
      ),
82
    )  # yes, there are mistakes in word 'Разведываетльния'
83
84
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
85
    self.assertEqual(testee.help_text, "OIR AE of 1st AG VVS")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
86
87
  def test_help_text_missing_translation(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
88
    testee = Regiment(AirForces.usn, "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
89
90
    self.assertEqual(
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
91
      testee.help_text,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
92
      "US Navy Torpedo Squadron 9 USS Essex CV-9",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
93
    )
94
95
    use_language("en")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
96
    self.assertEqual(
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
97
      testee.help_text,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
98
      "US Navy Torpedo Squadron 9 USS Essex CV-9",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
99
    )
100
101
    use_language("ru")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
102
    self.assertEqual(
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
103
      testee.help_text,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
104
      "US Navy Torpedo Squadron 9 USS Essex CV-9",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
105
    )
106
107
    use_language("ja")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
108
    self.assertEqual(
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
109
      testee.help_text,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
110
      "US Navy Torpedo Squadron 9 USS Essex CV-9",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation (add 2 spaces).
Loading history...
111
    )
112
113
  def test_unknown_attributes(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
114
    testee = Regiment(AirForces.usn, "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
115
    self.assertRaises(AttributeError, getattr, testee, 'abracadabra')
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
116
117
  def test_repr(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
118
    testee = Regiment(AirForces.usn, "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
119
    self.assertEqual(repr(testee), "<Regiment 'USN_VT_9B'>")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
120
121
  def test_to_primitive(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
122
    testee = Regiment(AirForces.usn, "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
123
    primitive = testee.to_primitive()
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
124
125
    self.assertEqual(primitive.pop("code_name"), "USN_VT_9B")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
126
    self.assertEqual(primitive.pop("verbose_name"), "VT-9 USS Essex CV-9")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
127
    self.assertEqual(primitive.pop("help_text"), "US Navy Torpedo Squadron 9 USS Essex CV-9")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
128
129
    air_force = primitive.pop("air_force")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
130
    self.assertEqual(air_force.pop("name"), "usn")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
131
    self.assertEqual(air_force.pop("default_flight_prefix"), "UN_NN")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
132
    self.assertEqual(air_force.pop("value"), "un")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
133
    self.assertEqual(air_force.pop("verbose_name"), "USN")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
134
    self.assertEqual(air_force.pop("help_text"), "United States Navy")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
135
136
    country = air_force.pop("country")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
137
    self.assertEqual(country.pop("name"), "us")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
138
    self.assertEqual(country.pop("verbose_name"), "United States")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
139
    self.assertIsNone(country.pop("help_text"))
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
140
141
    self.assertFalse(country)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
142
    self.assertFalse(air_force)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
143
    self.assertFalse(primitive)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
144
145
146
class RegimentsTestCase(unittest.TestCase):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
147
148
  def setUp(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
149
    self.regiments = Regiments()
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
150
151
  def test_get_by_code_name(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
152
    result = self.regiments.get_by_code_name("1GvIAP")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
153
    self.assertEqual(result.air_force, AirForces.vvs_rkka)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
154
155
  def test_get_by_code_name_is_cached(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
156
    regiment1 = self.regiments.get_by_code_name("1GvIAP")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
157
    regiment2 = self.regiments.get_by_code_name("1GvIAP")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
158
    self.assertEqual(id(regiment1), id(regiment2))
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
159
160
  def test_get_by_code_name_invalid(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
161
    self.assertRaises(ValueError, self.regiments.get_by_code_name, "foo")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
162
163
  def test_filter_by_air_force(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
164
    regiments = self.regiments.filter_by_air_force(AirForces.ala)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
165
    self.assertEqual(len(regiments), 119)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
166
167
    result = self.regiments.get_by_code_name("NN")
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
168
    self.assertEqual(regiments[0], result)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
169
170
  def test_filter_by_air_force_is_cached(self):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 4 spaces were expected, but 2 were found.
Loading history...
introduced by
Missing function or method docstring
Loading history...
171
    regiments1 = self.regiments.filter_by_air_force(AirForces.ala)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
172
    regiments2 = self.regiments.filter_by_air_force(AirForces.ala)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
173
174
    for regiment1, regiment2 in zip(regiments1, regiments2):
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 4 were found.
Loading history...
175
      self.assertEqual(id(regiment1), id(regiment2))
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 12 spaces were expected, but 6 were found.
Loading history...
176