|
@@ -7,36 +7,36 @@ from EditorialModel.backend.json_backend import EmBackendJson
|
7
|
7
|
class TypeTestCase(unittest.TestCase):
|
8
|
8
|
|
9
|
9
|
def setUp(self):
|
10
|
|
- self.me = Model(EmBackendJson('EditorialModel/test/me.json'))
|
11
|
|
- self.rubrique = self.me.component(14)
|
12
|
|
- self.article = self.me.component(5)
|
13
|
|
- self.personne = self.me.component(6)
|
14
|
|
- self.soustitre_field = self.me.component(7)
|
15
|
|
- self.age_field = self.me.component(18)
|
16
|
|
- self.nom_field = self.me.component(9)
|
17
|
|
- self.numero = self.me.component(19)
|
18
|
|
- self.gens_group = self.me.component(17)
|
19
|
|
- self.info_group = self.me.component(3)
|
20
|
|
- self.couleur_group = self.me.component(20)
|
21
|
|
- self.couleur_field = self.me.component(21)
|
|
10
|
+ self.model = Model(EmBackendJson('EditorialModel/test/me.json'))
|
|
11
|
+ self.rubrique = self.model.component(14)
|
|
12
|
+ self.article = self.model.component(5)
|
|
13
|
+ self.personne = self.model.component(6)
|
|
14
|
+ self.soustitre_field = self.model.component(7)
|
|
15
|
+ self.age_field = self.model.component(18)
|
|
16
|
+ self.nom_field = self.model.component(9)
|
|
17
|
+ self.numero = self.model.component(19)
|
|
18
|
+ self.gens_group = self.model.component(17)
|
|
19
|
+ self.info_group = self.model.component(3)
|
|
20
|
+ self.couleur_group = self.model.component(20)
|
|
21
|
+ self.couleur_field = self.model.component(21)
|
22
|
22
|
|
23
|
23
|
class TestSelectField(TypeTestCase):
|
24
|
24
|
|
25
|
|
- def testSelectField(self):
|
|
25
|
+ def test_select_field(self):
|
26
|
26
|
""" Testing optionnal field selection """
|
27
|
27
|
self.personne.select_field(self.age_field)
|
28
|
28
|
|
29
|
29
|
self.assertIn(self.age_field, self.personne.selected_fields())
|
30
|
30
|
self.assertIn(self.age_field.uid, self.personne.fields_list)
|
31
|
31
|
|
32
|
|
- def testUnselectField(self):
|
|
32
|
+ def test_unselect_field(self):
|
33
|
33
|
""" Testing optionnal field unselection """
|
34
|
34
|
self.article.unselect_field(self.soustitre_field)
|
35
|
35
|
|
36
|
36
|
self.assertNotIn(self.soustitre_field, self.article.selected_fields())
|
37
|
37
|
self.assertNotIn(self.soustitre_field.uid, self.article.fields_list)
|
38
|
38
|
|
39
|
|
- def testSelectFieldInvalid(self):
|
|
39
|
+ def test_select_field_invalid(self):
|
40
|
40
|
""" Testing optionnal field selection with invalid fields """
|
41
|
41
|
with self.assertRaises(ValueError):
|
42
|
42
|
self.personne.select_field(self.nom_field)
|
|
@@ -46,7 +46,7 @@ class TestSelectField(TypeTestCase):
|
46
|
46
|
|
47
|
47
|
class TestTypeHierarchy(TypeTestCase):
|
48
|
48
|
|
49
|
|
- def testAddSuperior(self):
|
|
49
|
+ def test_add_superior(self):
|
50
|
50
|
""" Testing add_superior() """
|
51
|
51
|
self.numero.add_superior(self.rubrique, EmNature.PARENT)
|
52
|
52
|
|
|
@@ -58,7 +58,7 @@ class TestTypeHierarchy(TypeTestCase):
|
58
|
58
|
self.numero.add_superior(self.rubrique, EmNature.PARENT)
|
59
|
59
|
self.assertEqual(1, len(self.numero.superiors()[EmNature.PARENT]))
|
60
|
60
|
|
61
|
|
- def testDelSuperior(self):
|
|
61
|
+ def test_del_superior(self):
|
62
|
62
|
""" Testing del_superior() """
|
63
|
63
|
|
64
|
64
|
# rubrique should be a superior of article
|
|
@@ -70,7 +70,7 @@ class TestTypeHierarchy(TypeTestCase):
|
70
|
70
|
|
71
|
71
|
# article should not have EmNature.PARENT superior anymore
|
72
|
72
|
with self.assertRaises(KeyError):
|
73
|
|
- self.article.superiors()[EmNature.PARENT]
|
|
73
|
+ _ = self.article.superiors()[EmNature.PARENT]
|
74
|
74
|
|
75
|
75
|
# article should not be in rubrique subordinates
|
76
|
76
|
self.assertNotIn(self.article, self.rubrique.subordinates()[EmNature.PARENT])
|
|
@@ -80,7 +80,7 @@ class TestTypeHierarchy(TypeTestCase):
|
80
|
80
|
|
81
|
81
|
# test preservation of superiors of other nature
|
82
|
82
|
|
83
|
|
- def testBadHierarchy(self):
|
|
83
|
+ def test_bad_hierarchy(self):
|
84
|
84
|
""" testing bad use of hierarchy """
|
85
|
85
|
|
86
|
86
|
# add a superior of different classtype
|
|
@@ -97,7 +97,7 @@ class TestTypeHierarchy(TypeTestCase):
|
97
|
97
|
|
98
|
98
|
class TestTypesMisc(TypeTestCase):
|
99
|
99
|
|
100
|
|
- def testFieldgroups(self):
|
|
100
|
+ def test_fieldgroups(self):
|
101
|
101
|
|
102
|
102
|
# should not send empty fieldgroups
|
103
|
103
|
self.assertNotIn(self.couleur_group, self.article.fieldgroups())
|
|
@@ -113,17 +113,17 @@ class TestTypesMisc(TypeTestCase):
|
113
|
113
|
|
114
|
114
|
class TestDeleteTypes(TypeTestCase):
|
115
|
115
|
|
116
|
|
- def testDeleteTypes(self):
|
|
116
|
+ def test_delete_types(self):
|
117
|
117
|
""" Testing EmType deletion """
|
118
|
118
|
|
119
|
119
|
# should be okay to delete article
|
120
|
120
|
article_id = self.article.uid
|
121
|
|
- self.assertTrue(self.me.delete_component(self.article.uid))
|
|
121
|
+ self.assertTrue(self.model.delete_component(self.article.uid))
|
122
|
122
|
|
123
|
123
|
# and it should not exist anymore
|
124
|
|
- self.assertFalse(self.me.component(article_id))
|
|
124
|
+ self.assertFalse(self.model.component(article_id))
|
125
|
125
|
# relations with other type should be deleted
|
126
|
126
|
self.assertNotIn(self.article, self.rubrique.subordinates()[EmNature.PARENT])
|
127
|
127
|
|
128
|
128
|
# rubrique has subordinates, should not be okay to delete
|
129
|
|
- self.assertFalse(self.me.delete_component(self.rubrique.uid))
|
|
129
|
+ self.assertFalse(self.model.delete_component(self.rubrique.uid))
|