summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-11-10 17:33:03 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:19 +0100
commit3bc41ea0cc14a52ee2fa5786cbe897577fb18ec1 (patch)
tree717b5d58300812622a74f5c58dfd29528944013d /archaeological_finds/tests.py
parent7d363ece174d5c814ef043e24ccc9a32ee1b2079 (diff)
downloadIshtar-3bc41ea0cc14a52ee2fa5786cbe897577fb18ec1.tar.bz2
Ishtar-3bc41ea0cc14a52ee2fa5786cbe897577fb18ec1.zip
Tests: find basket modification
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index e273069b8..df891e57e 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -1463,6 +1463,67 @@ class FindSearchTest(FindInit, TestCase, SearchText):
)
+class FindBasketWizardModificationTest(WizardTest, FindInit, TestCase):
+ fixtures = WAREHOUSE_FIXTURES
+ url_name = "find_basket_modification"
+ wizard_name = "find_basket_edit_wizard"
+ steps = views.basket_modification_steps
+ redirect_url = "/find_basket_modification/selec-find_basket_modification?"\
+ "open_item={last_id}"
+ model = models.FindBasket
+ form_datas = [
+ FormData(
+ "Basket modification",
+ form_datas={
+ "selec-find_basket_modification": {"pk": ""},
+ "basket-find_basket_modification": {
+ "label": "Super OK",
+ "slug": "super-ok",
+ "comment": "No",
+ "shared_with": [],
+ "shared_write_with": [],
+ },
+ },
+ )
+ ]
+
+ def pre_wizard(self):
+ self.basket = models.FindBasket.objects.create(
+ label="OK",
+ user=IshtarUser.objects.get(pk=self.user.pk),
+ )
+ self.basket_number = models.FindBasket.objects.count()
+ user1 = User.objects.create_user(
+ "user1", "nomail@nomail.com", "user1"
+ )
+ self.ishtar_user1 = IshtarUser.objects.get(user_ptr=user1)
+ user2 = User.objects.create_user(
+ "user2", "nomail@nomail.com", "user2"
+ )
+ self.ishtar_user2 = IshtarUser.objects.get(user_ptr=user2)
+
+ data = self.form_datas[0].form_datas
+ data["selec-find_basket_modification"]["pk"] = self.basket.pk
+ data["basket-find_basket_modification"]["shared_with"] = [self.ishtar_user1.pk]
+ data["basket-find_basket_modification"]["shared_write_with"] = [
+ self.ishtar_user2.pk, self.ishtar_user1.pk
+ ]
+ super().pre_wizard()
+
+ def post_wizard(self):
+ # no creation
+ self.assertEqual(models.FindBasket.objects.count(), self.basket_number)
+ basket = models.FindBasket.objects.get(pk=self.basket.pk)
+ self.assertEqual(
+ list(basket.shared_with.values_list("pk", flat=True)),
+ [self.ishtar_user1.pk]
+ )
+ self.assertEqual(
+ list(basket.shared_write_with.values_list("pk", flat=True)),
+ [self.ishtar_user1.pk, self.ishtar_user2.pk]
+ )
+
+
class FindAutocompleteTest(FindInit, TestCase):
fixtures = WAREHOUSE_FIXTURES
model = models.Find