def test_TwoAcceptedReleaseOneWithTagOnePendingRelease_LatestHasTwoReleasesOneWithTheTag( self): p = test_project() r1 = test_release(project=p, dateTime=timezone.make_aware( datetime(1970, 1, 1), timezone.get_current_timezone())) r1.tags.add("test") for response in r1.responses: response.response = ResponseCodes.Accept response.save() r2 = test_release(project=p, number="newnumber", dateTime=timezone.make_aware( datetime(1970, 1, 2), timezone.get_current_timezone())) for response in r2.responses: response.response = ResponseCodes.Accept response.save() test_release(project=p, number="pendingnumber", dateTime=timezone.make_aware( datetime(1970, 1, 3), timezone.get_current_timezone())) self.assertEqual(2, len(p.latest)) self.assertEqual(r2, p.latest[0]["release"]) self.assertEqual(r1, p.latest[1]["release"]) self.assertEqual("test", p.latest[1]["tag"].slug)
def test_ProjectHasMultipleReleases_ReleasesContainsAllReleasesInReverseDateOrder( self): p = test_project() r1 = test_release(project=p) r2 = test_release(project=p, dateTime=DEFAULT_TIME + timedelta(1), number="2") self.assertEqual([r2, r1], list(p.releases))
def test_CreateRelease_PreviousAcceptedReleasesAreUnaffected(self): p = test_project() r = test_release(project=p) for res in r.responses: res.response = ResponseCodes.Accept res.save() test_release(project=p, number="2") self.assertTrue(r.accepted)
def test_CreateRelease_PreviousAcceptedReleasesAreUnaffected(self): p = test_project() r = test_release(project=p) for res in r.responses: res.response = ResponseCodes.Accept res.save() test_release(project=p, number="2") self.assertTrue(r.accepted)
def test_ThreeReleaseFirstIsAccepted_ReturnsTwoRecentReleases(self): p = test_project() r1 = test_release(project=p) for res in r1.responses: res.response = ResponseCodes.Accept res.save() r2 = test_release(project=p, number="2") r3 = test_release(project=p, number="3") self.assertEqual([r3, r2], r3.since_last_accepted)
def test_ThreeReleaseFirstIsAccepted_ReturnsTwoRecentReleases(self): p = test_project() r1 = test_release(project=p) for res in r1.responses: res.response = ResponseCodes.Accept res.save() r2 = test_release(project=p, number="2") r3 = test_release(project=p, number="3") self.assertEqual([r3, r2], r3.since_last_accepted)
def test_CreateRelease_NewReleaseAuthIsCalled(self): with patch("accounts.emails.new_release_auth", MagicMock()): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) accounts.emails.new_release_auth.assert_called_once_with(r)
def test_CreateRelease_NewReleaseAuthIsCalled(self): with patch("accounts.emails.new_release_auth", MagicMock()): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) accounts.emails.new_release_auth.assert_called_once_with(r)
def test_ManyReleasesSomeAreAcceptedCheckAnAcceptedInTheMiddle_ReturnsUntilThePreviousSaved( self): p = test_project() r1 = test_release(project=p) for res in r1.responses: res.response = ResponseCodes.Accept res.save() r2 = test_release(project=p, number="2") r3 = test_release(project=p, number="3") r4 = test_release(project=p, number="4") for res in r4.responses: res.response = ResponseCodes.Accept res.save() r5 = test_release(project=p, number="5") r6 = test_release(project=p, number="6") for res in r6.responses: res.response = ResponseCodes.Accept res.save() r7 = test_release(project=p, number="7") self.assertEqual([r6, r5], r6.since_last_accepted)
def test_OnlyOneAcceptedReleaseWithNoTag_LatestHasOneRelease(self): p = test_project() r = test_release(project=p) for response in r.responses: response.response = ResponseCodes.Accept response.save() self.assertEqual(1, len(p.latest)) self.assertEqual(r, p.latest[0]["release"])
def test_CreateRelease_NewReleaseTeamIsCalled(self): with patch("accounts.emails.new_release_team", MagicMock()): u1 = test_user(username="******") u2 = test_user(username="******") t = test_team(members=[u1, u2]) p = test_project(team=t) r = test_release(project=p) accounts.emails.new_release_team.assert_called_once_with(r)
def test_TwoAcceptedReleaseOneWithTag_LatestHasTwoReleasesOneWithTheTag(self): p = test_project() r1 = test_release(project=p, dateTime=timezone.make_aware(datetime(1970, 1, 1), timezone.get_current_timezone())) r1.tags.add("test") for response in r1.responses: response.response = ResponseCodes.Accept response.save() r2 = test_release(project=p, number="newnumber", dateTime=timezone.make_aware(datetime(1970, 1, 2), timezone.get_current_timezone())) for response in r2.responses: response.response = ResponseCodes.Accept response.save() self.assertEqual(2, len(p.latest)) self.assertEqual(r2, p.latest[0]["release"]) self.assertEqual(r1, p.latest[1]["release"]) self.assertEqual("test", p.latest[1]["tag"].slug)
def test_CreateRelease_NewReleaseTeamIsCalled(self): with patch("accounts.emails.new_release_team", MagicMock()): u1 = test_user(username="******") u2 = test_user(username="******") t = test_team(members=[u1, u2]) p = test_project(team=t) r = test_release(project=p) accounts.emails.new_release_team.assert_called_once_with(r)
def test_OnlyOneAcceptedReleaseWithNoTag_LatestHasOneRelease(self): p = test_project() r = test_release(project=p) for response in r.responses: response.response = ResponseCodes.Accept response.save() self.assertEqual(1, len(p.latest)) self.assertEqual(r, p.latest[0]["release"])
def test_CreateRelease_ResponsesAreCreatedForEachAuthoriser(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) responses = r.pending_responses self.assertEqual(2, len(responses)) self.assertTrue(responses.get(user=u1)) self.assertTrue(responses.get(user=u2))
def test_CreateRelease_ResponsesAreCreatedForEachAuthoriser(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) responses = r.pending_responses self.assertEqual(2, len(responses)) self.assertTrue(responses.get(user=u1)) self.assertTrue(responses.get(user=u2))
def test_NotRelease_NewReleaseAuthIsNotCalled(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) with patch("accounts.emails.new_release_auth", MagicMock()): r.number = "newnumber" r.save() self.assertFalse(accounts.emails.new_release_auth.called)
def test_NotRelease_NewReleaseAuthIsNotCalled(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) with patch("accounts.emails.new_release_auth", MagicMock()): r.number = "newnumber" r.save() self.assertFalse(accounts.emails.new_release_auth.called)
def test_UpdateRelease_NoNewResponsesAreCreated(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) origResponses = [res for res in r.pending_responses] r.number = "newnumber" r.save() newReleases = [res for res in r.pending_responses] self.assertEqual(origResponses, newReleases)
def test_UpdateRelease_NewReleaseTeamIsCalled(self): u1 = test_user(username="******") u2 = test_user(username="******") t = test_team(members=[u1, u2]) p = test_project(team=t) r = test_release(project=p) with patch("accounts.emails.new_release_team", MagicMock()): r.number = "newnumber" r.save() self.assertFalse(accounts.emails.new_release_team.called)
def test_OnlyOneAcceptedReleaseWithTag_LatestHasTwoReleasesOneWithTheTag(self): p = test_project() r = test_release(project=p) r.tags.add("test") for response in r.responses: response.response = ResponseCodes.Accept response.save() self.assertEqual(2, len(p.latest)) self.assertEqual(r, p.latest[0]["release"]) self.assertEqual(r, p.latest[1]["release"]) self.assertEqual("test", p.latest[1]["tag"].slug)
def test_UpdateRelease_NoNewResponsesAreCreated(self): u1 = test_user(username="******") u2 = test_user(username="******") p = test_project(authorisers=[u1, u2]) r = test_release(project=p) origResponses = [res for res in r.pending_responses] r.number = "newnumber" r.save() newReleases = [res for res in r.pending_responses] self.assertEqual(origResponses, newReleases)
def test_UpdateRelease_NewReleaseTeamIsCalled(self): u1 = test_user(username="******") u2 = test_user(username="******") t = test_team(members=[u1, u2]) p = test_project(team=t) r = test_release(project=p) with patch("accounts.emails.new_release_team", MagicMock()): r.number = "newnumber" r.save() self.assertFalse(accounts.emails.new_release_team.called)
def test_OnlyOneAcceptedReleaseWithTag_LatestHasTwoReleasesOneWithTheTag( self): p = test_project() r = test_release(project=p) r.tags.add("test") for response in r.responses: response.response = ResponseCodes.Accept response.save() self.assertEqual(2, len(p.latest)) self.assertEqual(r, p.latest[0]["release"]) self.assertEqual(r, p.latest[1]["release"]) self.assertEqual("test", p.latest[1]["tag"].slug)
def test_ProjectsHaveMultipleReleases_ReleasesContainsAllReleasesForProjectInReverseDateOrder( self): p = test_project() r1 = test_release(project=p) r2 = test_release(project=p, dateTime=DEFAULT_TIME + timedelta(1), number="2") p2 = test_project(name="foo", team=p.team) test_release(project=p2) test_release(project=p2, dateTime=DEFAULT_TIME + timedelta(1), number="2") self.assertEqual([r2, r1], list(p.releases))
def test_ManyReleasesSomeAreAcceptedCheckAnAcceptedInTheMiddle_ReturnsUntilThePreviousSaved(self): p = test_project() r1 = test_release(project=p) for res in r1.responses: res.response = ResponseCodes.Accept res.save() r2 = test_release(project=p, number="2") r3 = test_release(project=p, number="3") r4 = test_release(project=p, number="4") for res in r4.responses: res.response = ResponseCodes.Accept res.save() r5 = test_release(project=p, number="5") r6 = test_release(project=p, number="6") for res in r6.responses: res.response = ResponseCodes.Accept res.save() r7 = test_release(project=p, number="7") self.assertEqual([r6, r5], r6.since_last_accepted)
def test_OnlyOneRelease_ReturnsThatRelease(self): r = test_release() self.assertEqual([r], r.since_last_accepted)
def test_MultipleReleasesWithTagForProject_ReturnIsTheLatestRelease(self): p = test_project() r1 = test_release(project=p, tags=["foo"]) r2 = test_release(number="2", project=p, tags=["foo"]) self.assertEqual(r2, p.release_with_tag("foo"))
def test_OnlyReleaseIsPending_LatestIsEmpty(self): p = test_project() r = test_release(project=p) self.assertEqual(0, len(p.latest))
def test_TwoRelease_ReturnsThatBothRelease(self): p = test_project() r1 = test_release(project=p) r2 = test_release(project=p, number="2") self.assertEqual([r2, r1], r2.since_last_accepted)
def test_ProjectHasSingleRelease_ReleasesOnlyContainsThatRelease(self): p = test_project() r = test_release(project=p) self.assertEqual([r], list(p.releases))
def test_CreateRelease_PreviousPendingReleasesAreRejected(self): p = test_project() r = test_release(project=p) test_release(project=p, number="2") self.assertTrue(r.rejected)
def test_TwoRelease_ReturnsThatBothRelease(self): p = test_project() r1 = test_release(project=p) r2 = test_release(project=p, number="2") self.assertEqual([r2, r1], r2.since_last_accepted)
def test_CreateRelease_ReleaseTimeIsUpdatedToTheCurrentTime(self): r = test_release() self.assertNotEqual(DEFAULT_TIME, r.dateTime)
def test_OnlyOneRelease_ReturnsThatRelease(self): r = test_release() self.assertEqual([r], r.since_last_accepted)
def test_OnlyReleaseIsPending_LatestIsEmpty(self): p = test_project() r = test_release(project=p) self.assertEqual(0, len(p.latest))
def test_CreateRelease_ReleaseTimeIsUpdatedToTheCurrentTime(self): r = test_release() self.assertNotEqual(DEFAULT_TIME, r.dateTime)
def test_CreateRelease_PreviousPendingReleasesAreRejected(self): p = test_project() r = test_release(project=p) test_release(project=p, number="2") self.assertTrue(r.rejected)
def test_NoReleasesWithTagForProject_ReturnIsNone(self): p = test_project() r = test_release(project=p, tags=["bar"]) self.assertIsNone(p.release_with_tag("foo"))
def test_SingleReleasesWithTagForProject_ReturnIsTheRelease(self): p = test_project() r = test_release(project=p, tags=["foo"]) self.assertEqual(r, p.release_with_tag("foo"))