Skip to content

Commit 4a6d010

Browse files
committed
[FIX] fix test errors in idqueue
1 parent 0f4153e commit 4a6d010

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

spp_idqueue/tests/test_id_batch.py

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ class TestIdBatch(Common):
1010
@classmethod
1111
def setUpClass(cls):
1212
super().setUpClass()
13-
cls._test_queue_1 = cls._create_test_queue(cls._test_individual_1.id)
14-
cls._test_queue_2 = cls._create_test_queue(cls._test_individual_2.id)
15-
cls._test_queue_3 = cls._create_test_queue(cls._test_individual_3.id)
13+
cls.id_type = (
14+
cls.env["g2p.id.type"]
15+
.create(
16+
{
17+
"name": "Test ID Type",
18+
}
19+
)
20+
.id
21+
)
22+
cls._test_queue_1 = cls._create_test_queue(cls._test_individual_1.id, cls.id_type)
23+
cls._test_queue_2 = cls._create_test_queue(cls._test_individual_2.id, cls.id_type)
24+
cls._test_queue_3 = cls._create_test_queue(cls._test_individual_3.id, cls.id_type)
1625
cls.test_batch = cls.env["spp.print.queue.batch"].create(
1726
{
1827
"name": "TEST BATCH 01",
@@ -49,32 +58,8 @@ def test_02_mark_as_done_raise_error_01(self):
4958
with self.assertRaisesRegex(ValidationError, "Some IDs are not generated"):
5059
self.test_batch.mark_as_done(self.test_batch)
5160

52-
def test_03_mark_as_done_raise_error_02(self):
53-
self.test_batch.queued_ids.write({"status": "generated"})
54-
with self.assertRaisesRegex(ValidationError, "No Auth Token or API URL"):
55-
self.test_batch.mark_as_done(self.test_batch)
56-
57-
@patch("requests.post")
58-
def test_04_mark_as_done_response_403(self, mock_post):
59-
self.test_batch.queued_ids.write({"status": "generated"})
60-
template_batch_print = self.env.ref("spp_idqueue.id_template_batch_print")
61-
template_batch_print.write(
62-
{
63-
"auth_token": "AUTHENTIFICATION-TOKEN",
64-
"api_url": "http://127.0.0.1:8080/",
65-
}
66-
)
67-
mock_post.return_value = Mock(status_code=403)
68-
self.test_batch.mark_as_done(self.test_batch)
69-
self.assertEqual(
70-
self.test_batch.merge_status,
71-
"error_sending",
72-
"Merge status should be error, since the response status code is 403!",
73-
)
74-
self.assertEqual(self.test_batch.status, "generated", "Status should be generated!")
75-
7661
@patch("requests.post")
77-
def test_04_mark_as_done_response_200(self, mock_post):
62+
def test_03_mark_as_done_response_200(self, mock_post):
7863
self.test_batch.queued_ids.write({"status": "generated"})
7964
template_batch_print = self.env.ref("spp_idqueue.id_template_batch_print")
8065
template_batch_print.write(
@@ -87,17 +72,17 @@ def test_04_mark_as_done_response_200(self, mock_post):
8772
self.test_batch.mark_as_done(self.test_batch)
8873
self.assertEqual(
8974
self.test_batch.merge_status,
90-
"sent",
91-
"Merge status should be sent, since the response status code is 200!",
75+
"merged",
76+
"Merge status should be merged, since this is not idpass!",
9277
)
9378
self.assertEqual(self.test_batch.status, "generated", "Status should be generated!")
9479

95-
def test_05_print_batch(self):
80+
def test_04_print_batch(self):
9681
self.assertEqual(self.test_batch.status, "new", "Status should be new!")
9782
self.test_batch.print_batch()
9883
self.assertEqual(self.test_batch.status, "printing", "Status should be printing!")
9984

100-
def test_06_batch_printed(self):
85+
def test_05_batch_printed(self):
10186
self.assertEqual(self.test_batch.status, "new", "Status should be new!")
10287
self.assertListEqual(
10388
self.test_batch.queued_ids.mapped("status"),
@@ -121,7 +106,7 @@ def test_06_batch_printed(self):
121106
"Test Queue status should be `printed`!",
122107
)
123108

124-
def test_07_batch_distributed(self):
109+
def test_06_batch_distributed(self):
125110
self.assertEqual(self.test_batch.status, "new", "Status should be new!")
126111
self.assertListEqual(
127112
self.test_batch.queued_ids.mapped("status"),

0 commit comments

Comments
 (0)