Exemplo n.º 1
0
 def test_one_issue_per_date_per_paper(self):
     descTest("Publications in the same newspaper "
              + "should not occur on the same date")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue1 = Issue(date_published=yesterday(), editor="T", newspaper=paper)
     issue2 = Issue(
         date_published=yesterday(), editor="T2", newspaper=paper)
     issue1.save()
     self.assertRaisesRegex(ValidationError, ISSUE_OVERLAP_ERROR,
                            issue2.save)
Exemplo n.º 2
0
 def test_multiple_issues_same_date_diff_paper(self):
     descTest("Publications in different newspapers "
              + "can occur on the same date")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     paper2 = Newspaper(title="hi", date_started=yesterday())
     paper2.save()
     issue1 = Issue(date_published=yesterday(), editor="T", newspaper=paper)
     issue2 = Issue(
         date_published=yesterday(), editor="T2", newspaper=paper2)
     issue1.save()
     issue2.save()
Exemplo n.º 3
0
 def test_one_issue_per_date_per_paper(self):
     descTest("Publications in the same newspaper " +
              "should not occur on the same date")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue1 = Issue(date_published=yesterday(), editor="T", newspaper=paper)
     issue2 = Issue(date_published=yesterday(),
                    editor="T2",
                    newspaper=paper)
     issue1.save()
     self.assertRaisesRegex(ValidationError, ISSUE_OVERLAP_ERROR,
                            issue2.save)
Exemplo n.º 4
0
 def test_multiple_issues_same_date_diff_paper(self):
     descTest("Publications in different newspapers " +
              "can occur on the same date")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     paper2 = Newspaper(title="hi", date_started=yesterday())
     paper2.save()
     issue1 = Issue(date_published=yesterday(), editor="T", newspaper=paper)
     issue2 = Issue(date_published=yesterday(),
                    editor="T2",
                    newspaper=paper2)
     issue1.save()
     issue2.save()
Exemplo n.º 5
0
 def test_pub_date_in_newspaper_timespan(self):
     ed = "James Jameserson"
     descTest("The publication date must be inside the newspaper's range")
     paper = Newspaper(title="hello", date_started=today())
     paper.save()
     issue = Issue(date_published=yesterday(), editor=ed, newspaper=paper)
     self.assertRaisesRegex(ValidationError, PUB_TIME_ERROR, issue.save)
Exemplo n.º 6
0
 def test_pub_date_in_newspaper_timespan(self):
     ed = "James Jameserson"
     descTest("The publication date must be inside the newspaper's range")
     paper = Newspaper(title="hello", date_started=today())
     paper.save()
     issue = Issue(date_published=yesterday(), editor=ed, newspaper=paper)
     self.assertRaisesRegex(ValidationError, PUB_TIME_ERROR, issue.save)
Exemplo n.º 7
0
 def test_start_date_not_after_end_date(self):
     descTest("The start date of a newspaper is never before the end date")
     t = "A Valid Title"
     paper = Newspaper(title=t,
                       date_started=today(),
                       date_ended=yesterday())
     self.assertRaises(ValidationError, paper.save)
Exemplo n.º 8
0
 def test_editor_is_editor(self):
     ed = "James Jameserson"
     descTest("The editor name is consistent with the one given")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue = Issue(date_published=today(), editor=ed, newspaper=paper)
     issue.save()
     self.assertEquals(issue.editor, Issue.objects.get(pk=issue.pk).editor)
Exemplo n.º 9
0
 def test_editor_is_editor(self):
     ed = "James Jameserson"
     descTest("The editor name is consistent with the one given")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue = Issue(date_published=today(), editor=ed, newspaper=paper)
     issue.save()
     self.assertEquals(issue.editor, Issue.objects.get(pk=issue.pk).editor)
Exemplo n.º 10
0
 def test_has_editor(self):
     descTest("All issues must have an editor")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue = Issue(newspaper=paper, editor='', date_published=today())
     self.assertRaises(ValidationError, issue.save)
Exemplo n.º 11
0
 def test_start_date_not_after_end_date(self):
     descTest("The start date of a newspaper is never before the end date")
     t = "A Valid Title"
     paper = Newspaper(
         title=t, date_started=today(), date_ended=yesterday())
     self.assertRaises(ValidationError, paper.save)
Exemplo n.º 12
0
 def test_has_editor(self):
     descTest("All issues must have an editor")
     paper = Newspaper(title="hello", date_started=yesterday())
     paper.save()
     issue = Issue(newspaper=paper, editor='', date_published=today())
     self.assertRaises(ValidationError, issue.save)