def test_setInitialContentParsesMarkdown(self): mockedTicketProvider = Mock() mockedData='## Upcoming developments ##\n03-02-2015\n\n' \ '* [DBA-3](http://some.url) DBA2 ticket that references \n' \ '* [DBA-4](http://some.url) DBA1 ticket that references \n' \ '## 1.0.2.0 ##\n02-02-2015\n\n' \ '* [DBA-2](http://some.url) DBA2 ticket that references [#DBA-1](http://some.url/DBA-1), reported by test user\n' \ '* [DBA-1](http://some.url) DBA1 ticket that references [#DBA-2](http://some.url/DBA-2), reported by test user\n' \ '## 1.0.0.1 ##\n01-02-2015\n\n' \ '* [DBA-3](http://some.url) DBA2 ticket that references \n' \ '* [DBA-4](http://some.url) DBA1 ticket that references \n' writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) output = writer.setInitialContent(mockedData) self.assertEqual(2, len(output)) self.assertEqual(["## 1.0.2.0 ##", "02-02-2015", '', "* [DBA-2](http://some.url) DBA2 ticket that references [#DBA-1](http://some.url/DBA-1), reported by test user", "* [DBA-1](http://some.url) DBA1 ticket that references [#DBA-2](http://some.url/DBA-2), reported by test user" ], output["1.0.2.0"]) self.assertEqual(['## 1.0.0.1 ##', '01-02-2015', '', '* [DBA-3](http://some.url) DBA2 ticket that references ', '* [DBA-4](http://some.url) DBA1 ticket that references ', '' ], output["1.0.0.1"])
def test_printVersionBlockReturnsWhateverIsPresentInitially(self): mockedTicketProvider = Mock() mockedData='## 1.0.0.1 ##\n' \ 'SomeCustomStuff' \ 'possibly even unstructured\n some comments etc\n' writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) output = writer.setInitialContent(mockedData) self.assertEqual(1, len(output)) self.assertEqual(mockedData, writer.printVersionBlock(None, "1.0.0.1", None, None))
def test_givenUnicodeCharacterInTheInitialContent_DoesntFail(self): conf = {} conf["Source"] = {} conf["Source"]["OldestCommitToProcess"] = "ef334212ab2323a32323" promotedVersions = {} ticketProvider = Mock() ticketProvider.extractTicketsFromMessage = MagicMock( return_value=["TCKT-1"]) ticketProvider.getTicketInfo = MagicMock( return_value={ "issue_type_icon": "None", "html_url": None, "ticket": "TCKT-1", "title": "TCKT-1 Summary", "embedded_link": {}, "reporter": "rnowosielski" }) writer = MarkdownWriter.MarkdownWriter(ticketProvider) mockedData='## Upcoming developments ##\n03-02-2015\n\n' \ '* [DBA-3](http://some.url) DBA2 ticket that references \n' \ '* [DBA-4](http://some.url) DBA1 ticket that references \n' \ '## 1.0.1.2 ##\n02-02-2015\n\n' \ '* [DBA-2](http://some.url) DBA2ı ticket that references [#DBA-1](http://some.url/DBA-1), reported by test user\n' \ '* [DBA-1](http://some.url) DBA1 ticket ıthat references [#DBA-2](http://some.url/DBA-2), reported by test user\n' \ '## 1.0.1.1 ##\n01-02-2015\n\n' \ '* [DBA-3](http://some.url) DBA2 ticket that references \n' \ '* [DBA-4](http://some.url) DBA1 ticket that references \n' writer.setInitialContent(mockedData) repo = Mock() repo.gitCommitsList = ["ef334212ab2323a32323", "as5d4a5sd4a5sd4a5sd4"] repo.versionsByGitHash = { "ef334212ab2323a32323": "1.0.1.2", "as5d4a5sd4a5sd4a5sd4": "1.0.1.1" } repo.gitHistoryByVersion = { "1.0.1.2": ["ef334212ab2323a32323"], "1.0.1.1": ["as5d4a5sd4a5sd4a5sd4"] } repo.gitCommitMessagesByHash = { "ef334212ab2323a32323": "Someting about TCKT-1", "as5d4a5sd4a5sd4a5sd4": "Something about TCKT-0" } repo.gitDatesByHash = { "ef334212ab2323a32323": datetime.strptime("2015-12-12 12:12:12", "%Y-%m-%d %H:%M:%S").toordinal(), "as5d4a5sd4a5sd4a5sd4": datetime.strptime("2015-11-11 11:11:11", "%Y-%m-%d %H:%M:%S").toordinal() } releaseNotes = JustReleaseNotes.releaseNotes.ReleaseNotes( conf, ticketProvider, repo, promotedVersions) output = releaseNotes.generateReleaseNotesByPromotedVersions(writer)
def test_printVersionBlockHandlesIntDate(self): mockedTicketProvider = Mock() mockedTicketProvider.getTicketInfo = self.ticket_side_effect writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) deps = {"ANY": "SomeComponent1: 2.3.*; SomeComponent2: 1.0.0"} version = "1.0.2.0" date = 1422798811 tickets = ["DBA-1", "DBA-2"] output = writer.printVersionBlock(deps, version, date, tickets) self.assertEqual( "## 1.0.2.0 ##\n2015-02-01\n\n* [DBA-2](http://some.url) DBA2 ticket, *reported by* **test user**\n* [DBA-1](http://some.url) DBA1 ticket, *reported by* **test user**\n", output)
def test_givenFairlyCompleteTicketMarkdownBlockIsGenerated(self): mockedTicketProvider = Mock() mockedTicketProvider.getTicketInfo = self.ticket_side_effect writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) deps = {"ANY": "SomeComponent1: 2.3.*; SomeComponent2: 1.0.0"} version = "1.0.2.0" date = "01-02-2015" tickets = ["DBA-1", "DBA-2"] output = writer.printVersionBlock(deps, version, date, tickets) self.assertEqual( '## 1.0.2.0 ##\n01-02-2015\n\n* [DBA-2](http://some.url) DBA2 ticket\n*' ' [DBA-1](http://some.url) DBA1 ticket, reported by test user\n', output)
def test_embeddedLinkProvided_ReplacesContentWithLink(self): mockedTicketProvider = Mock() mockedTicketProvider.getTicketInfo = self.ticket_side_effect_with_embedded_link writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) deps = {"ANY": "SomeComponent1: 2.3.*; SomeComponent2: 1.0.0"} version = "1.0.2.0" date = "01-02-2015" tickets = ["DBA-1", "DBA-2"] output = writer.printVersionBlock(deps, version, date, tickets) self.assertEqual( '## 1.0.2.0 ##\n01-02-2015\n\n* [DBA-2](http://some.url) DBA2 ticket that references' ' [#DBA-1](http://some.url/DBA-1), *reported by* **test user**\n* [DBA-1](http://some.url) DBA1 ticket that references ' '[#DBA-2](http://some.url/DBA-2), *reported by* **test user**\n', output)
def test_givenFairlyCompleteTicketMarkdownBlockIsGenerated(self): mockedTicketProvider = Mock() writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) self.assertEqual("![Icon](http://icon.url/image.png)", writer.getImageBlock("http://icon.url/image.png"))
def test_versionHeaderParsingAndGenerationAreCompatible(self): mockedTicketProvider = Mock() writer = MarkdownWriter.MarkdownWriter(mockedTicketProvider) self.assertEqual( "1.2.3", writer.parseVersionHeader(writer.getVersionHeader("1.2.3")))
def test_returnsMdExtension(self): writer = MarkdownWriter.MarkdownWriter(None) self.assertEqual(".md", writer.getExtension())