def test_to_string(self): page1 = fomod.Page() page1.append(fomod.Group()) page1.name = "boop" text = page1.to_string() page2 = fomod.Page() self.pages.extend([page1, page2]) expected = textwrap.dedent("""\ <installSteps order="Explicit"> {} </installSteps>""".format( textwrap.indent(text, " " * 4 + " "))) assert self.pages.to_string() == expected
def test_installerpage(): test_page = fomod.Page() test_page.name = "name" installer_mock = Mock(spec=installer.Installer) installer_mock._order_list.return_value = ["test1", "test2", "test3"] inst_page = installer.InstallerPage(installer_mock, test_page) assert inst_page.name == "name" assert list(inst_page) == ["test1", "test2", "test3"]
def test_next(self): test_root = fomod.Root() test_installer = installer.Installer(test_root) assert test_installer.next() is None test_root.pages.append(fomod.Page()) test_group = fomod.Group() test_group.append(fomod.Option()) test_group[0].flags["flag"] = "value" test_group.append(fomod.Option()) test_root.pages[0].append(test_group) assert test_installer.next()._object is test_root.pages[0] test_group.type = fomod.GroupType.ALL with pytest.raises(installer.InvalidSelection): test_installer.next() test_group.type = fomod.GroupType.ATLEASTONE with pytest.raises(installer.InvalidSelection): test_installer.next() test_group.type = fomod.GroupType.EXACTLYONE with pytest.raises(installer.InvalidSelection): test_installer.next() test_group.type = fomod.GroupType.ATMOSTONE with pytest.raises(installer.InvalidSelection): test_installer.next([ installer.InstallerOption(test_installer, test_group[0]), installer.InstallerOption(test_installer, test_group[1]), ]) test_group[0].type = fomod.OptionType.REQUIRED with pytest.raises(installer.InvalidSelection): test_installer.next() test_group[0].type = fomod.OptionType.NOTUSABLE with pytest.raises(installer.InvalidSelection): test_installer.next( [installer.InstallerOption(test_installer, test_group[0])]) test_root.pages.append(fomod.Page()) test_root.pages[1].conditions["flag"] = "other" test_root.pages.append(fomod.Page()) assert test_installer.next()._object is test_root.pages[2] assert test_installer.next() is None
def test_validate(self): expected = fomod.ValidationWarning( "Empty Installer", "This fomod is empty, nothing will be installed.", self.root, ) assert expected in self.root.validate() page = fomod.Page() page.conditions["boop"] = "beep" page.append(fomod.Group()) self.root.pages.append(page) expected = fomod.ValidationWarning( "Impossible Flags", 'The flag "boop" is never created or set.', page.conditions, ) assert expected in self.root.validate()
def test_previous(self): installer_mock = Mock(spec=installer.Installer) test_page = fomod.Page() test_option = fomod.Option() installer_mock._has_finished = True installer_mock._previous_pages = OrderedDict([(test_page, [test_option])]) installer_mock._current_page = None result = installer.Installer.previous(installer_mock) assert result[0]._object is test_page assert result[1] == [test_option] assert not installer_mock._has_finished assert not installer_mock._previous_pages assert installer_mock._current_page is test_page installer_mock._previous_pages = OrderedDict() assert installer.Installer.previous(installer_mock) is None assert installer_mock._current_page is None
def test_validate(self): expected = warnings.ValidationWarning( "Empty Fomod Tree", "This fomod is empty, nothing will be installed.", self.root, ) assert expected in self.root.validate() page = fomod.Page() page.conditions["boop"] = "beep" page.append(fomod.Group()) self.root.pages.append(page) expected = warnings.ValidationWarning( "Impossible Flag", "The flag 'boop' is never created or set.", page.conditions, critical=True, ) assert expected in self.root.validate()
def setup_method(self): self.page = fomod.Page()