def test_save_stories_only(patched_for_save): save_mock, origin, target = patched_for_save r = ReprintRevision(origin=origin, target=target) r.save() save_mock.assert_called_once_with() assert r.origin == origin assert r.target == target assert r.origin_issue == origin.issue assert r.target_issue == target.issue
def test_save_target_mismatch(patched_for_save): save_mock, origin, target = patched_for_save r = ReprintRevision(origin=origin, target=target, target_issue=origin.issue) with pytest.raises(ValueError) as exc_info: r.save() v = str(exc_info.value) assert "target story and issue do not match" in v expected = "issue: '%s'; Issue: '%s'" % (target.issue, origin.issue) assert expected in v assert not save_mock.called
def test_save_stories_and_issues_only(patched_for_save): save_mock, origin, target = patched_for_save r = ReprintRevision(origin=origin, origin_issue=origin.issue, target=target, target_issue=target.issue) r.save() save_mock.assert_called_once_with() # make sure nothing got changed. assert r.origin == origin assert r.target == target assert r.origin_issue == origin.issue assert r.target_issue == target.issue
def test_save_target_rev_issue_mismatch(patched_for_save): save_mock, origin, target = patched_for_save r = ReprintRevision(origin=origin, origin_issue=origin.issue, origin_revision=StoryRevision(story=origin, issue=origin.issue), target=None, target_issue=origin.issue, target_revision=StoryRevision(story=target)) with pytest.raises(ValueError) as exc_info: r.save() assert not save_mock.called v = str(exc_info.value) assert "target story revision issue and target issue do not agree" in v assert ("'%s'; Issue: '%s'" % (r.target_revision.issue, r.target_issue)) in v
def test_save_origin_rev_story_mismatch(patched_for_save): save_mock, origin, target = patched_for_save r = ReprintRevision(origin=origin, origin_issue=origin.issue, origin_revision=StoryRevision(story=None, issue=origin.issue), target=target, target_issue=target.issue, target_revision=StoryRevision(story=target, issue=target.issue)) with pytest.raises(ValueError) as exc_info: r.save() assert not save_mock.called v = str(exc_info.value) assert "origin story revision and origin story do not agree" in v assert ("'%s'; Story: '%s'" % (r.origin_revision.story, r.origin)) in v