aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/resources/tests
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/resources/tests')
-rw-r--r--pydis_site/apps/resources/tests/test_to_kebabcase.py19
-rw-r--r--pydis_site/apps/resources/tests/test_views.py17
-rw-r--r--pydis_site/apps/resources/tests/testing_resources/testing/_category_info.yaml1
-rw-r--r--pydis_site/apps/resources/tests/testing_resources/testing/foobar/_category_info.yaml1
-rw-r--r--pydis_site/apps/resources/tests/testing_resources/testing/foobar/resource_test.yaml1
-rw-r--r--pydis_site/apps/resources/tests/testing_resources/testing/my_resource.yaml1
6 files changed, 25 insertions, 15 deletions
diff --git a/pydis_site/apps/resources/tests/test_to_kebabcase.py b/pydis_site/apps/resources/tests/test_to_kebabcase.py
new file mode 100644
index 00000000..a141143d
--- /dev/null
+++ b/pydis_site/apps/resources/tests/test_to_kebabcase.py
@@ -0,0 +1,19 @@
+from django.test import TestCase
+
+from pydis_site.apps.resources.templatetags.to_kebabcase import _to_kebabcase
+
+
+class TestToKebabcase(TestCase):
+ """Tests for the `as_css_class` template tag."""
+
+ def test_to_kebabcase(self):
+ """Test the to_kebabcase utility and template tag."""
+ weird_input = (
+ "_-_--_A_LEm0n?in&¤'the##trEE£$@€@€@@£is-NOT----QUITE//"
+ "as#good! as one __IN-YOUR|||HaND"
+ )
+
+ self.assertEqual(
+ _to_kebabcase(weird_input),
+ "a-lem0n-in-the-tree-is-not-quite-as-good-as-one-in-your-hand",
+ )
diff --git a/pydis_site/apps/resources/tests/test_views.py b/pydis_site/apps/resources/tests/test_views.py
index 3ad0b958..a2a203ce 100644
--- a/pydis_site/apps/resources/tests/test_views.py
+++ b/pydis_site/apps/resources/tests/test_views.py
@@ -1,5 +1,4 @@
from pathlib import Path
-from unittest.mock import patch
from django.conf import settings
from django.test import TestCase
@@ -17,18 +16,14 @@ class TestResourcesView(TestCase):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
-
-class TestResourcesListView(TestCase):
- @patch("pydis_site.apps.resources.views.resources_list.RESOURCES_PATH", TESTING_RESOURCES_PATH)
- def test_valid_resource_list_200(self):
- """Check does site return code 200 when visiting valid resource list."""
- url = reverse("resources:resources", args=("testing",))
+ def test_resources_with_valid_argument(self):
+ """Check that you can resolve the resources when passing a valid argument."""
+ url = reverse("resources:index", kwargs={"resource_type": "book"})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
- @patch("pydis_site.apps.resources.views.resources_list.RESOURCES_PATH", TESTING_RESOURCES_PATH)
- def test_invalid_resource_list_404(self):
- """Check does site return code 404 when trying to visit invalid resource list."""
- url = reverse("resources:resources", args=("invalid",))
+ def test_resources_with_invalid_argument(self):
+ """Check that you can resolve the resources when passing an invalid argument."""
+ url = reverse("resources:index", kwargs={"resource_type": "urinal-cake"})
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
diff --git a/pydis_site/apps/resources/tests/testing_resources/testing/_category_info.yaml b/pydis_site/apps/resources/tests/testing_resources/testing/_category_info.yaml
deleted file mode 100644
index bae17ea3..00000000
--- a/pydis_site/apps/resources/tests/testing_resources/testing/_category_info.yaml
+++ /dev/null
@@ -1 +0,0 @@
-name: Testing
diff --git a/pydis_site/apps/resources/tests/testing_resources/testing/foobar/_category_info.yaml b/pydis_site/apps/resources/tests/testing_resources/testing/foobar/_category_info.yaml
deleted file mode 100644
index eaac32d9..00000000
--- a/pydis_site/apps/resources/tests/testing_resources/testing/foobar/_category_info.yaml
+++ /dev/null
@@ -1 +0,0 @@
-name: Foobar
diff --git a/pydis_site/apps/resources/tests/testing_resources/testing/foobar/resource_test.yaml b/pydis_site/apps/resources/tests/testing_resources/testing/foobar/resource_test.yaml
deleted file mode 100644
index 22835090..00000000
--- a/pydis_site/apps/resources/tests/testing_resources/testing/foobar/resource_test.yaml
+++ /dev/null
@@ -1 +0,0 @@
-name: Resource Test
diff --git a/pydis_site/apps/resources/tests/testing_resources/testing/my_resource.yaml b/pydis_site/apps/resources/tests/testing_resources/testing/my_resource.yaml
deleted file mode 100644
index 61df6173..00000000
--- a/pydis_site/apps/resources/tests/testing_resources/testing/my_resource.yaml
+++ /dev/null
@@ -1 +0,0 @@
-name: My Resource