From 003d4d0c5a84b7272c621412882c61a051eae704 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: May 16 2020 01:20:14 +0000 Subject: Add various IoT tests (v. similar to modular) Signed-off-by: Adam Williamson --- diff --git a/tests/test_event.py b/tests/test_event.py index cba903b..5c91133 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -168,6 +168,16 @@ class TestEventFedfind: assert isinstance(event.ff_release, fedfind.release.ModularCompose) assert isinstance(event.ff_release_images, fedfind.release.ModularCompose) + @mock.patch("fedfind.release.IoTNightly.exists", True) + @mock.patch("fedfind.release.IoTNightly.all_images", ["foo"]) + def test_candidate_ff_release_iot(self): + """Straightforward ff_release test case for an IoT 'nightly' + compose. + """ + event = wikitcms.event.NightlyEvent(self.site, "33", "RC", "20200513.0", dist="Fedora-IoT") + assert isinstance(event.ff_release, fedfind.release.IoTNightly) + assert isinstance(event.ff_release_images, fedfind.release.IoTNightly) + @pytest.mark.usefixtures("fakemwp") @mock.patch("wikitcms.page.Page.save", autospec=True) @@ -427,6 +437,17 @@ class TestEventOther: assert fakesave.call_args[0][2] == "relval: update to current event" assert fakesave.call_args[1]["createonly"] is None assert fakesave.call_args[0][0].name == "Template:CurrentFedora-ModularCompose" + # IoT 'nightly' + event = wikitcms.event.NightlyEvent(self.site, "33", "RC", "20200513.0", dist="Fedora-IoT") + event.update_current() + assert fakesave.call_args[0][1] == ( + "{{tempdoc}}\n{{#switch: {{{1|full}}}\n| full = 33 RC 20200513.0" + "\n| release = 33\n| milestone = RC\n| compose =\n| date = 20200513.0\n" + "}}\n[[Category: Fedora Templates]]" + ) + assert fakesave.call_args[0][2] == "relval: update to current event" + assert fakesave.call_args[1]["createonly"] is None + assert fakesave.call_args[0][0].name == "Template:CurrentFedora-IoTCompose" def test_event_from_page(self, fakemwp): """Test for from_page classmethod.""" @@ -439,6 +460,11 @@ class TestEventOther: ev = wikitcms.event.NightlyEvent.from_page(pg) assert ev.version == "27 Branched 20171123.n.1" assert ev.dist == "Fedora-Modular" + # IoT + pg = self.site.pages["Test Results:Fedora-IoT 33 RC 20200513.0 General"] + ev = wikitcms.event.NightlyEvent.from_page(pg) + assert ev.version == "33 RC 20200513.0" + assert ev.dist == "Fedora-IoT" def test_event_category_page(self, fakemwp): """Test for category_page property.""" @@ -462,6 +488,10 @@ class TestEventOther: ) cat = event.category_page assert cat.checkname == "Category:Fedora-Modular 27 Nightly Test Results" + # IoT + event = wikitcms.event.NightlyEvent(self.site, "33", "RC", "20200513.0", dist="Fedora-IoT") + cat = event.category_page + assert cat.checkname == "Category:Fedora-IoT 33 Nightly Test Results" # yes, I looked up the correct date. don't make fun of me! @mock.patch("wikitcms.page.ComposePage.creation_date", "20170922") diff --git a/tests/test_listing.py b/tests/test_listing.py index d7e27f0..8d6eb97 100644 --- a/tests/test_listing.py +++ b/tests/test_listing.py @@ -112,6 +112,10 @@ class TestListing: pg = self.site.pages["Test Results:Fedora-Modular 27 Branched 20171123.n.1 Server"] assert isinstance(pg, wikitcms.page.NightlyPage) assert pg.dist == "Fedora-Modular" + # IoT + pg = self.site.pages["Test Results:Fedora-IoT 33 RC 20200513.0 General"] + assert isinstance(pg, wikitcms.page.NightlyPage) + assert pg.dist == "Fedora-IoT" # summary should fall through to an mwclient Page pg = self.site.pages["Test_Results:Fedora_32_Branched_20200322.n.0_Summary"] assert not isinstance(pg, wikitcms.page.Page) @@ -251,6 +255,13 @@ class TestListing: assert pg.summary == ( "Relval bot-created validation result category page for Fedora-Modular 27" ) + # top level, IoT + pg = self.site.pages["Category:Fedora-IoT 33 Test Results"] + assert isinstance(pg, wikitcms.listing.ValidationCategory) + assert pg.seedtext == "{{Validation results milestone category|release=33|dist=IoT}}" + assert pg.summary == ( + "Relval bot-created validation result category page for Fedora-IoT 33" + ) # milestone level pg = self.site.pages["Category:Fedora 32 Beta Test Results"] assert isinstance(pg, wikitcms.listing.ValidationCategory) @@ -288,6 +299,16 @@ class TestListing: "Relval bot-created validation result category page for Fedora-" "Modular 27 nightly results" ) + # nightly level, IoT + pg = self.site.pages["Category:Fedora-IoT 33 Nightly Test Results"] + assert isinstance(pg, wikitcms.listing.ValidationCategory) + assert pg.seedtext == ( + "{{Validation results milestone category|release=33|nightly=true|dist=IoT}}" + ) + assert pg.summary == ( + "Relval bot-created validation result category page for Fedora-" + "IoT 33 nightly results" + ) @mock.patch("mwclient.listing.GeneratorList.__next__") def test_pages_testday_category(self, fakenext): diff --git a/tests/test_page.py b/tests/test_page.py index 3a2d9d4..41c138c 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -182,6 +182,11 @@ class TestValidationPages: modcandidate = wikitcms.page.ComposePage( self.site, "27", "Server", "Beta", "1.5", dist="Fedora-Modular" ) + + # IoT 'nightly' + iotnightly = wikitcms.page.NightlyPage( + self.site, "33", "General", "RC", "20200513.0", dist="Fedora-IoT" + ) assert nightly.release == "32" assert nightly.milestone == "Rawhide" assert nightly.compose == "20200122.n.0" @@ -275,6 +280,28 @@ class TestValidationPages: "|compose=1.5}}" ) + assert iotnightly.release == "33" + assert iotnightly.milestone == "RC" + assert iotnightly.compose == "20200513.0" + assert iotnightly.version == "33 RC 20200513.0" + assert iotnightly.testtype == "General" + assert iotnightly.dist == "Fedora-IoT" + assert iotnightly.checkname == "Test Results:Fedora-IoT 33 RC 20200513.0 General" + assert iotnightly.summary == ( + "Relval bot-created General validation results page for Fedora-IoT 33 RC 20200513.0" + ) + assert iotnightly.results_separators == ( + "Test Matri", + "Test Areas", + "An unsupported test or configuration. No testing is required.", + ) + assert iotnightly.sortname == "33 6000 20200513.0 General" + assert iotnightly.sorttuple == (33, 800, Decimal("20200513.0"), "General") + assert iotnightly.seedtext == ( + "{{subst:IoT validation results|testtype=General|release=33|milestone=RC" + "|date=20200513.0}}" + ) + def test_results_sections(self, fakeapisections): """Test the results_sections property.""" # we aren"t using fakepages here so this doesn"t really matter @@ -380,6 +407,18 @@ class TestValidationPages: assert args[1] == "#REDIRECT [[Test Results:Fedora-Modular 32 Beta 1.1 Server]]" assert args[2] == "relval: update to current event" + # IoT case + page = wikitcms.page.NightlyPage( + self.site, "33", "General", "RC", "20200513.0", dist="Fedora-IoT" + ) + page.update_current() + assert fakesave.call_count == 3 + args = fakesave.call_args[0] + # this is the Page instance itself + assert args[0].name == "Test Results:Current IoT General Test" + assert args[1] == "#REDIRECT [[Test Results:Fedora-IoT 33 RC 20200513.0 General]]" + assert args[2] == "relval: update to current event" + @pytest.mark.usefixtures("fakemwp", "fakepages") class TestAddResults: @@ -652,7 +691,7 @@ class TestSummaryPage: assert isinstance(summ, wikitcms.page.SummaryPage) assert summ.checkname == "Test Results:Fedora-Modular 27 Beta 1.5 Summary" assert summ.summary == ( - "Relval bot-created validation results summary for " "Fedora-Modular 27 Beta 1.5" + "Relval bot-created validation results summary for Fedora-Modular 27 Beta 1.5" ) # let's not test the whole goddamned thing again assert summ.seedtext.startswith("Fedora-Modular 27 Beta 1.5 [[") @@ -665,6 +704,25 @@ class TestSummaryPage: assert args[2] == "relval: update to current event" fakesave.reset_mock() + # IoT checks + iotevent = wikitcms.event.NightlyEvent(site, "33", "RC", "20200513.0", dist="Fedora-IoT") + summ = iotevent.summary_page + assert isinstance(summ, wikitcms.page.SummaryPage) + assert summ.checkname == "Test Results:Fedora-IoT 33 RC 20200513.0 Summary" + assert summ.summary == ( + "Relval bot-created validation results summary for Fedora-IoT 33 RC 20200513.0" + ) + # let's not test the whole goddamned thing again + assert summ.seedtext.startswith("Fedora-IoT 33 RC 20200513.0 [[") + summ.update_current() + assert fakesave.call_count == 1 + args = fakesave.call_args[0] + # this is the Page instance itself + assert args[0].name == "Test Results:Current IoT Summary" + assert args[1] == "#REDIRECT [[Test Results:Fedora-IoT 33 RC 20200513.0 Summary]]" + assert args[2] == "relval: update to current event" + fakesave.reset_mock() + @pytest.mark.usefixtures("fakemwp", "fakepages", "fakeimages") class TestDownloadPage: @@ -701,6 +759,13 @@ class TestDownloadPage: assert page.summary == "Relval bot-created download page for Fedora-Modular 27 Beta 1.5" # that's all we need to check for modular + # IoT checks + iotevent = wikitcms.event.NightlyEvent(site, "33", "RC", "20200513.0", dist="Fedora-IoT") + page = iotevent.download_page + assert page.checkname == "Template:Fedora-IoT 33 RC 20200513.0 Download" + assert page.summary == "Relval bot-created download page for Fedora-IoT 33 RC 20200513.0" + # that's all we need to check for IoT + @pytest.mark.usefixtures("fakemwp", "fakepages", "fakeimages") class TestAMIPage: diff --git a/tests/test_wiki.py b/tests/test_wiki.py index 0179876..54f2696 100644 --- a/tests/test_wiki.py +++ b/tests/test_wiki.py @@ -182,6 +182,8 @@ class TestWiki: assert list(self.site.walk_category(fakecat1)) == [fakepg1, fakepg2, fakepg3] @mock.patch("fedfind.release.Compose.exists", return_value=True) + @mock.patch("fedfind.release.IoTNightly.label", "RC-20200513.0") + @mock.patch("fedfind.release.IoTNightly.cid", "Fedora-IoT-33-20200513.0") @mock.patch("fedfind.release.Production.label", "RC-1.6") @mock.patch("fedfind.release.Production.cid", "Fedora-27-20171105.0") @mock.patch("fedfind.helpers.get_current_release", autospec=True, return_value=27) @@ -254,6 +256,12 @@ class TestWiki: fakecompose.assert_called_with( self.site, "27", "RC", "1.6", dist="Fedora", cid="Fedora-27-20171105.0" ) + # IoT compose: these are technically productions but quack and + # walk like nightlies, with dates in the labels; we intend to + # treat them as nightlies and create nightly events + fakegetcurr.return_value = 32 + self.site.get_validation_event(cid="Fedora-IoT-33-20200513.0", dist="Fedora-IoT") + fakenightly.assert_called_with(self.site, "33", "RC", "20200513.0", dist="Fedora-IoT") with pytest.raises(ValueError): # Non-nightly compose but no milestone