import pytest from .models import Author, Work, Quote, QuoteTag class Test_MassImport(): @pytest.fixture(scope='function') def q1(self, db): a1 = Author.objects.create(name="JFK") w1 = Work.objects.create(name="Berlin speech", author=a1) q1 = Quote.objects.create(text="

Ich bin...

", work=w1) return q1 @pytest.mark.django_db def test_massimport_1(self, q1, c_adm): allquotes = """\ Ich bin ein Berliner --- JFK --- Berlin speech === To be or not to be, that is the question --- William Shakespeare --- Hamlet === To thine own self, be true --- William Shakespeare --- Hamlet --- tag1, tag2, tag3 === A rose by any other name... --- William Shakespeare --- Romeo and Juliet --- tag1, tag555 ===""" results = c_adm.postPage('massimport/', {'quotes': allquotes}) assert "rejected" not in results assert Quote.objects.get(text="

To thine own self, be true

") assert Quote.objects.get(text__contains="To be or not to be") assert Author.objects.get(name="JFK") assert Author.objects.get(name="William Shakespeare") assert Author.objects.all().count() == 2 hamlet = Work.objects.get(name="Hamlet") assert hamlet assert hamlet.author == Author.objects.get(name="William Shakespeare") for quote in Quote.objects.all(): assert c_adm.getPage(quote.get_absolute_url()) @pytest.mark.django_db def test_massimport_2(self, q1, c_adm): allquotes = """\ A rose by any other name... --- William Shakespeare --- Romeo and Juliet --- tag1, tag555 ===""" results = c_adm.postPage('massimport/', {'quotes': allquotes}) assert "