0.4.4: Django 3.0 support, actions.export_as_csv_action added.
[fnpdjango.git] / tests / tests / test_actions.py
diff --git a/tests/tests/test_actions.py b/tests/tests/test_actions.py
new file mode 100644 (file)
index 0000000..b7d19d3
--- /dev/null
@@ -0,0 +1,26 @@
+from django.test import TestCase
+from django.contrib.auth.models import User
+from ..models import SomeModel
+
+
+class ActionsTests(TestCase):
+    def test_csv(self):
+        u = User(username='user', is_superuser=True, is_staff=True)
+        u.set_password('test')
+        u.save()
+
+        SomeModel.objects.create()
+
+        self.client.login(username='user', password='test')
+
+        response = self.client.post(
+            '/admin/tests/somemodel/',
+            {
+                'action': 'export_as_csv',
+                '_selected_action': '1',
+            }
+        )
+        self.assertEqual(
+            response.content,
+            b"id,attachment\r\n1,\r\n")
+