def test_to_string(self): group1 = fomod.Group() group1.append(fomod.Option()) text = group1.to_string() group2 = fomod.Group() self.page.extend([group1, group2]) self.page.name = "boop" self.page.order = fomod.Order.ASCENDING expected = textwrap.dedent("""\ <installStep name="boop"> <optionalFileGroups order="Ascending"> {} </optionalFileGroups> </installStep>""".format(textwrap.indent(text, " " * 5))) assert self.page.to_string() == expected
def test_installergroup(): test_group = fomod.Group() test_group.name = "name" test_group.type = fomod.GroupType.ALL installer_mock = Mock(spec=installer.Installer) installer_mock._order_list.return_value = ["test1", "test2", "test3"] inst_group = installer.InstallerGroup(installer_mock, test_group) assert inst_group.name == "name" assert inst_group.type is fomod.GroupType.ALL assert list(inst_group) == ["test1", "test2", "test3"]
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_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_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 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 setup_method(self): self.group = fomod.Group()