def test_parse_targets(self): """ Test to parses the input to pkg.install and returns back the package(s) to be installed. Returns a list of packages, as well as a string noting whether the packages are to come from a repository or a binary package. """ with patch.dict(pkg_resource.__grains__, {"os": "A"}): self.assertEqual(pkg_resource.parse_targets(pkgs="a", sources="a"), (None, None)) with patch.object(pkg_resource, "_repack_pkgs", return_value=False): self.assertEqual(pkg_resource.parse_targets(pkgs="a"), (None, None)) with patch.object(pkg_resource, "_repack_pkgs", return_value="A"): self.assertEqual(pkg_resource.parse_targets(pkgs="a"), ("A", "repository")) with patch.dict(pkg_resource.__grains__, {"os": "MacOS1"}): with patch.object(pkg_resource, "pack_sources", return_value=False): self.assertEqual(pkg_resource.parse_targets(sources="s"), (None, None)) with patch.object(pkg_resource, "pack_sources", return_value={"A": "/a"}): with patch.dict( pkg_resource.__salt__, {"config.valid_fileproto": MagicMock(return_value=False)}, ): self.assertEqual(pkg_resource.parse_targets(sources="s"), (["/a"], "file")) with patch.object(pkg_resource, "pack_sources", return_value={"A": "a"}): with patch.dict( pkg_resource.__salt__, {"config.valid_fileproto": MagicMock(return_value=False)}, ): self.assertEqual( pkg_resource.parse_targets(name="n"), ({ "n": None }, "repository"), ) self.assertEqual(pkg_resource.parse_targets(), (None, None))
def test_parse_targets(self): ''' Test to parses the input to pkg.install and returns back the package(s) to be installed. Returns a list of packages, as well as a string noting whether the packages are to come from a repository or a binary package. ''' with patch.dict(pkg_resource.__grains__, {'os': 'A'}): self.assertEqual(pkg_resource.parse_targets(pkgs='a', sources='a'), (None, None)) with patch.object(pkg_resource, '_repack_pkgs', return_value=False): self.assertEqual(pkg_resource.parse_targets(pkgs='a'), (None, None)) with patch.object(pkg_resource, '_repack_pkgs', return_value='A'): self.assertEqual(pkg_resource.parse_targets(pkgs='a'), ('A', 'repository')) with patch.dict(pkg_resource.__grains__, {'os': 'MacOS1'}): with patch.object(pkg_resource, 'pack_sources', return_value=False): self.assertEqual(pkg_resource.parse_targets(sources='s'), (None, None)) with patch.object(pkg_resource, 'pack_sources', return_value={'A': '/a'}): with patch.dict( pkg_resource.__salt__, {'config.valid_fileproto': MagicMock(return_value=False)}): self.assertEqual(pkg_resource.parse_targets(sources='s'), (['/a'], 'file')) with patch.object(pkg_resource, 'pack_sources', return_value={'A': 'a'}): with patch.dict( pkg_resource.__salt__, {'config.valid_fileproto': MagicMock(return_value=False)}): self.assertEqual(pkg_resource.parse_targets(name='n'), ({ 'n': None }, 'repository')) self.assertEqual(pkg_resource.parse_targets(), (None, None))
def test_parse_targets(self): ''' Test to parses the input to pkg.install and returns back the package(s) to be installed. Returns a list of packages, as well as a string noting whether the packages are to come from a repository or a binary package. ''' with patch.dict(pkg_resource.__grains__, {'os': 'A'}): self.assertEqual(pkg_resource.parse_targets(pkgs='a', sources='a'), (None, None)) with patch.object(pkg_resource, '_repack_pkgs', return_value=False): self.assertEqual(pkg_resource.parse_targets(pkgs='a'), (None, None)) with patch.object(pkg_resource, '_repack_pkgs', return_value='A'): self.assertEqual(pkg_resource.parse_targets(pkgs='a'), ('A', 'repository')) with patch.dict(pkg_resource.__grains__, {'os': 'MacOS1'}): with patch.object(pkg_resource, 'pack_sources', return_value=False): self.assertEqual(pkg_resource.parse_targets(sources='s'), (None, None)) with patch.object(pkg_resource, 'pack_sources', return_value={'A': '/a'}): with patch.dict(pkg_resource.__salt__, {'config.valid_fileproto': MagicMock(return_value=False)}): self.assertEqual(pkg_resource.parse_targets(sources='s'), (['/a'], 'file')) with patch.object(pkg_resource, 'pack_sources', return_value={'A': 'a'}): with patch.dict(pkg_resource.__salt__, {'config.valid_fileproto': MagicMock(return_value=False)}): self.assertEqual(pkg_resource.parse_targets(name='n'), ({'n': None}, 'repository')) self.assertEqual(pkg_resource.parse_targets(), (None, None))