From 0b7723e5c011d15e0772fd698bd1e8fdb13bf182 Mon Sep 17 00:00:00 2001 From: Jorik Kraaikamp Date: Fri, 10 Jun 2022 12:45:15 +0200 Subject: [PATCH] Fixed the strict filtering --- .../pdc/tests/test_product_finder.py | 296 +++++++++--------- src/open_inwoner/pdc/views.py | 2 - 2 files changed, 148 insertions(+), 150 deletions(-) diff --git a/src/open_inwoner/pdc/tests/test_product_finder.py b/src/open_inwoner/pdc/tests/test_product_finder.py index a088745ee5..34098d71e7 100644 --- a/src/open_inwoner/pdc/tests/test_product_finder.py +++ b/src/open_inwoner/pdc/tests/test_product_finder.py @@ -160,22 +160,22 @@ def test_q1_yes_q2_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 3) - self.assertEqual(len(possible_products), 9) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 7) + self.assertEqual(len(possible_products), 5) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) - self.assertNotIn(self.product6, matched_products) - self.assertIn(self.product6, possible_products) - self.assertNotIn(self.product7, matched_products) - self.assertIn(self.product7, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) + self.assertIn(self.product6, matched_products) + self.assertNotIn(self.product6, possible_products) + self.assertIn(self.product7, matched_products) + self.assertNotIn(self.product7, possible_products) self.assertNotIn(self.product8, matched_products) self.assertIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) @@ -337,26 +337,26 @@ def test_q1_yes_q2_yes_q3_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 2) - self.assertEqual(len(possible_products), 10) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) - self.assertNotIn(self.product2, matched_products) - self.assertIn(self.product2, possible_products) + self.assertEqual(len(matched_products), 9) + self.assertEqual(len(possible_products), 3) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) + self.assertIn(self.product2, matched_products) + self.assertNotIn(self.product2, possible_products) self.assertIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) - self.assertNotIn(self.product6, matched_products) - self.assertIn(self.product6, possible_products) - self.assertNotIn(self.product7, matched_products) - self.assertIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) + self.assertIn(self.product6, matched_products) + self.assertNotIn(self.product6, possible_products) + self.assertIn(self.product7, matched_products) + self.assertNotIn(self.product7, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) self.assertIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) @@ -385,18 +385,18 @@ def test_q1_yes_q2_yes_q3_no(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 5) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 3) + self.assertEqual(len(possible_products), 3) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertNotIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) @@ -433,10 +433,10 @@ def test_q1_yes_q2_no_q3_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 6) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 3) + self.assertEqual(len(possible_products), 3) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) @@ -449,10 +449,10 @@ def test_q1_yes_q2_no_q3_yes(self): self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) self.assertIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) @@ -529,8 +529,8 @@ def test_q1_no_q2_yes_q3_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 2) - self.assertEqual(len(possible_products), 6) + self.assertEqual(len(matched_products), 5) + self.assertEqual(len(possible_products), 3) self.assertNotIn(self.product1, matched_products) self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) @@ -539,16 +539,16 @@ def test_q1_no_q2_yes_q3_yes(self): self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) self.assertIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) @@ -726,28 +726,28 @@ def test_q1_yes_q2_yes_q3_yes_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 11) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) - self.assertNotIn(self.product2, matched_products) - self.assertIn(self.product2, possible_products) - self.assertNotIn(self.product3, matched_products) - self.assertIn(self.product3, possible_products) + self.assertEqual(len(matched_products), 10) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) + self.assertIn(self.product2, matched_products) + self.assertNotIn(self.product2, possible_products) + self.assertIn(self.product3, matched_products) + self.assertNotIn(self.product3, possible_products) self.assertIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) - self.assertNotIn(self.product6, matched_products) - self.assertIn(self.product6, possible_products) - self.assertNotIn(self.product7, matched_products) - self.assertIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) + self.assertIn(self.product6, matched_products) + self.assertNotIn(self.product6, possible_products) + self.assertIn(self.product7, matched_products) + self.assertNotIn(self.product7, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -779,24 +779,24 @@ def test_q1_yes_q2_yes_q3_yes_q4_no(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 7) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) - self.assertNotIn(self.product2, matched_products) - self.assertIn(self.product2, possible_products) + self.assertEqual(len(matched_products), 6) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) + self.assertIn(self.product2, matched_products) + self.assertNotIn(self.product2, possible_products) self.assertIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) - self.assertNotIn(self.product6, matched_products) - self.assertIn(self.product6, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) + self.assertIn(self.product6, matched_products) + self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) @@ -832,18 +832,18 @@ def test_q1_yes_q2_yes_q3_no_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 6) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) - self.assertNotIn(self.product2, matched_products) - self.assertIn(self.product2, possible_products) + self.assertEqual(len(matched_products), 4) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) + self.assertIn(self.product2, matched_products) + self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertNotIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) @@ -852,8 +852,8 @@ def test_q1_yes_q2_yes_q3_no_q4_yes(self): self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -885,18 +885,18 @@ def test_q1_yes_q2_yes_q3_no_q4_no(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 4) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 3) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertNotIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) @@ -938,10 +938,10 @@ def test_q1_yes_q2_no_q3_yes_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 6) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 4) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) @@ -954,12 +954,12 @@ def test_q1_yes_q2_no_q3_yes_q4_yes(self): self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -991,10 +991,10 @@ def test_q1_yes_q2_no_q3_yes_q4_no(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 4) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 2) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) @@ -1007,8 +1007,8 @@ def test_q1_yes_q2_no_q3_yes_q4_no(self): self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) @@ -1044,10 +1044,10 @@ def test_q1_yes_q2_no_q3_no_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 4) - self.assertNotIn(self.product1, matched_products) - self.assertIn(self.product1, possible_products) + self.assertEqual(len(matched_products), 2) + self.assertEqual(len(possible_products), 2) + self.assertIn(self.product1, matched_products) + self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) self.assertNotIn(self.product2, possible_products) self.assertNotIn(self.product3, matched_products) @@ -1064,8 +1064,8 @@ def test_q1_yes_q2_no_q3_no_q4_yes(self): self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -1150,8 +1150,8 @@ def test_q1_no_q2_yes_q3_yes_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 7) + self.assertEqual(len(matched_products), 6) + self.assertEqual(len(possible_products), 2) self.assertNotIn(self.product1, matched_products) self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) @@ -1160,18 +1160,18 @@ def test_q1_no_q2_yes_q3_yes_q4_yes(self): self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) - self.assertNotIn(self.product6, matched_products) - self.assertIn(self.product6, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) + self.assertIn(self.product6, matched_products) + self.assertNotIn(self.product6, possible_products) self.assertIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) - self.assertNotIn(self.product9, matched_products) - self.assertIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) + self.assertIn(self.product9, matched_products) + self.assertNotIn(self.product9, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -1203,8 +1203,8 @@ def test_q1_no_q2_yes_q3_yes_q4_no(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 4) + self.assertEqual(len(matched_products), 3) + self.assertEqual(len(possible_products), 2) self.assertNotIn(self.product1, matched_products) self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) @@ -1213,14 +1213,14 @@ def test_q1_no_q2_yes_q3_yes_q4_no(self): self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) self.assertNotIn(self.product10, matched_products) @@ -1256,8 +1256,8 @@ def test_q1_no_q2_yes_q3_no_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 0) - self.assertEqual(len(possible_products), 4) + self.assertEqual(len(matched_products), 2) + self.assertEqual(len(possible_products), 2) self.assertNotIn(self.product1, matched_products) self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) @@ -1266,8 +1266,8 @@ def test_q1_no_q2_yes_q3_no_q4_yes(self): self.assertNotIn(self.product3, possible_products) self.assertNotIn(self.product4, matched_products) self.assertNotIn(self.product4, possible_products) - self.assertNotIn(self.product5, matched_products) - self.assertIn(self.product5, possible_products) + self.assertIn(self.product5, matched_products) + self.assertNotIn(self.product5, possible_products) self.assertNotIn(self.product6, matched_products) self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) @@ -1276,8 +1276,8 @@ def test_q1_no_q2_yes_q3_no_q4_yes(self): self.assertNotIn(self.product8, possible_products) self.assertNotIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) @@ -1362,8 +1362,8 @@ def test_q1_no_q2_no_q3_yes_q4_yes(self): self.assertEqual(response.status_code, 200) matched_products = list(response.context["matched_products"]) possible_products = list(response.context["possible_products"]) - self.assertEqual(len(matched_products), 1) - self.assertEqual(len(possible_products), 4) + self.assertEqual(len(matched_products), 3) + self.assertEqual(len(possible_products), 2) self.assertNotIn(self.product1, matched_products) self.assertNotIn(self.product1, possible_products) self.assertNotIn(self.product2, matched_products) @@ -1378,12 +1378,12 @@ def test_q1_no_q2_no_q3_yes_q4_yes(self): self.assertNotIn(self.product6, possible_products) self.assertNotIn(self.product7, matched_products) self.assertNotIn(self.product7, possible_products) - self.assertNotIn(self.product8, matched_products) - self.assertIn(self.product8, possible_products) + self.assertIn(self.product8, matched_products) + self.assertNotIn(self.product8, possible_products) self.assertIn(self.product9, matched_products) self.assertNotIn(self.product9, possible_products) - self.assertNotIn(self.product10, matched_products) - self.assertIn(self.product10, possible_products) + self.assertIn(self.product10, matched_products) + self.assertNotIn(self.product10, possible_products) self.assertNotIn(self.product11, matched_products) self.assertIn(self.product11, possible_products) self.assertNotIn(self.product12, matched_products) diff --git a/src/open_inwoner/pdc/views.py b/src/open_inwoner/pdc/views.py index 30c4091c2b..2191bb773e 100644 --- a/src/open_inwoner/pdc/views.py +++ b/src/open_inwoner/pdc/views.py @@ -281,8 +281,6 @@ def filter_matched_products(self, condition_products): for _order, answer in current_answers.items(): if answer.get("answer") == YesNo.no: products = products.exclude(conditions=answer.get("condition")) - else: - products = products.filter(conditions=answer.get("condition")) return products def filter_possible_products(self, condition_products, matched):