Browse Source

Add extra tests, add tests for asset deletion

rafalp 6 years ago
parent
commit
8fdf291cbf
2 changed files with 13 additions and 3 deletions
  1. 12 2
      misago/admin/themes/tests/conftest.py
  2. 1 1
      misago/admin/themes/views.py

+ 12 - 2
misago/admin/themes/tests/conftest.py

@@ -17,6 +17,11 @@ def theme(db):
 
 
 
 
 @pytest.fixture
 @pytest.fixture
+def other_theme(db):
+    return Theme.objects.create(name="Other theme")
+
+
+@pytest.fixture
 def nonexisting_theme(mocker, default_theme):
 def nonexisting_theme(mocker, default_theme):
     return mocker.Mock(pk=default_theme.pk + 1)
     return mocker.Mock(pk=default_theme.pk + 1)
 
 
@@ -33,13 +38,18 @@ def css(admin_client, theme):
 
 
 
 
 @pytest.fixture
 @pytest.fixture
+def css_link(admin_client, theme):
+    return theme.css.create(name="CSS link", url="https://somecdn/somefont.css")
+
+
+@pytest.fixture
 def media(admin_client, theme):
 def media(admin_client, theme):
     url = reverse(
     url = reverse(
         "misago:admin:appearance:themes:upload-media", kwargs={"pk": theme.pk}
         "misago:admin:appearance:themes:upload-media", kwargs={"pk": theme.pk}
     )
     )
     with open(os.path.join(TESTS_DIR, "images", "test.svg")) as fp:
     with open(os.path.join(TESTS_DIR, "images", "test.svg")) as fp:
         admin_client.post(url, {"assets": [fp]})
         admin_client.post(url, {"assets": [fp]})
-    return theme.media.last()
+    return theme.media.get(name="test.svg")
 
 
 
 
 @pytest.fixture
 @pytest.fixture
@@ -49,4 +59,4 @@ def image(admin_client, theme):
     )
     )
     with open(os.path.join(TESTS_DIR, "images", "test.png"), "rb") as fp:
     with open(os.path.join(TESTS_DIR, "images", "test.png"), "rb") as fp:
         admin_client.post(url, {"assets": [fp]})
         admin_client.post(url, {"assets": [fp]})
-    return theme.media.last()
+    return theme.media.get(name="test.png")

+ 1 - 1
misago/admin/themes/views.py

@@ -143,7 +143,7 @@ class DeleteThemeAssets(ThemeAssetsActionAdmin, generic.TargetedView):
 
 
     def clean_items_list(self, request):
     def clean_items_list(self, request):
         try:
         try:
-            return {int(i) for i in request.POST.getlist("item")}
+            return {int(i) for i in request.POST.getlist("item")[:20]}
         except (ValueError, TypeError):
         except (ValueError, TypeError):
             pass
             pass