]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/test_massimport.py
Create an administrative interface
[djsite.git] / quotes / test_massimport.py
index 0a9fb4f70fafe6ea0ceb622b59f4904ae4dcfb81..fb5ea368aca5f93de9d033cbd5e7a87d4995ac57 100644 (file)
@@ -11,7 +11,7 @@ class Test_MassImport():
         return q1
 
     @pytest.mark.django_db
-    def test_massimport_1(self, q1, c):
+    def test_massimport_1(self, q1, c_adm):
         allquotes = """\
 Ich bin ein Berliner
 ---
@@ -42,7 +42,7 @@ Romeo and Juliet
 tag1, tag555
 ==="""
 
-        results = c.postPage('massimport/', {'quotes': allquotes})
+        results = c_adm.postPage('massimport/', {'quotes': allquotes})
 
         assert "rejected" not in results
 
@@ -58,10 +58,10 @@ tag1, tag555
         assert hamlet.author == Author.objects.get(name="William Shakespeare")
 
         for quote in Quote.objects.all():
-            assert c.getPage(quote.get_absolute_url())
+            assert c_adm.getPage(quote.get_absolute_url())
 
     @pytest.mark.django_db
-    def test_massimport_2(self, q1, c):
+    def test_massimport_2(self, q1, c_adm):
         allquotes = """\
 <script>somethingevil()</script>
 A rose by any other name...
@@ -73,13 +73,13 @@ Romeo and Juliet
 tag1, tag555
 ==="""
 
-        results = c.postPage('massimport/', {'quotes': allquotes})
+        results = c_adm.postPage('massimport/', {'quotes': allquotes})
         assert "<script>" not in results
         with pytest.raises(Quote.DoesNotExist):
             Quote.objects.get(text__contains="<script>")
 
     @pytest.mark.django_db
-    def test_massimport_3(self, c):
+    def test_massimport_3(self, c_adm):
         """Whitespace and stuff"""
         allquotes = """\
 A rose by any other name...
@@ -106,7 +106,7 @@ Hamlet
 
 """
 
-        results = c.postPage('massimport/', {'quotes': allquotes})
+        results = c_adm.postPage('massimport/', {'quotes': allquotes})
         assert "rejected" not in results
         assert Quote.objects.get(text="<p>A rose by any other name...</p>")
         assert Author.objects.get(name="William Shakespeare")
@@ -119,3 +119,6 @@ Hamlet
         assert tirade.work.author.name == "William Shakespeare"
         assert Author.objects.filter(name__contains="Shakespeare").count() == 1
 
+    def test_massimport_noaccess(self, c):
+        c.getPage('massimport/', exp_status=302)
+        c.postPage('massimport/', {}, exp_status=302)