def test_expand_repo_def(): """ Checks results from expand_repo_def """ source_type = "deb" source_uri = "http://cdn-aws.deb.debian.org/debian/" source_line = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" source_file = "/etc/apt/sources.list" # Valid source repo = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" sanitized = aptpkg.expand_repo_def(repo=repo, file=source_file) assert isinstance(sanitized, dict) assert "uri" in sanitized # Make sure last character in of the URI is still a / assert sanitized["uri"][-1] == "/" # Pass the architecture and make sure it is added the the line attribute repo = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" sanitized = aptpkg.expand_repo_def(repo=repo, file=source_file, architectures="amd64") # Make sure line is in the dict assert isinstance(sanitized, dict) assert "line" in sanitized # Make sure the architecture is in line assert ( sanitized["line"] == "deb [arch=amd64] http://cdn-aws.deb.debian.org/debian/ stretch main")
def test_expand_repo_def(self): """ Checks results from expand_repo_def """ source_type = "deb" source_uri = "http://cdn-aws.deb.debian.org/debian/" source_line = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" source_file = "/etc/apt/sources.list" mock_source = MockSourceEntry(source_uri, source_type, source_line, False, file=source_file) # Valid source with patch("salt.modules.aptpkg._check_apt", MagicMock(return_value=True)): with patch("salt.modules.aptpkg.sourceslist", MagicMock(), create=True): with patch( "salt.modules.aptpkg.sourceslist.SourceEntry", MagicMock(return_value=mock_source), create=True, ): repo = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" sanitized = aptpkg.expand_repo_def(repo=repo, file=source_file) assert isinstance(sanitized, dict) self.assertIn("uri", sanitized) # Make sure last character in of the URI is still a / self.assertEqual(sanitized["uri"][-1], "/")
def test_expand_repo_def(self): """ Checks results from expand_repo_def """ source_type = "deb" source_uri = "http://cdn-aws.deb.debian.org/debian/" source_line = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" source_file = "/etc/apt/sources.list" # Valid source with patch("salt.modules.aptpkg._check_apt", MagicMock(return_value=True)): repo = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" sanitized = aptpkg.expand_repo_def(repo=repo, file=source_file) assert isinstance(sanitized, dict) self.assertIn("uri", sanitized) # Make sure last character in of the URI is still a / self.assertEqual(sanitized["uri"][-1], "/") # Pass the architecture and make sure it is added the the line attribute repo = "deb http://cdn-aws.deb.debian.org/debian/ stretch main\n" sanitized = aptpkg.expand_repo_def(repo=repo, file=source_file, architectures="amd64") # Make sure line is in the dict assert isinstance(sanitized, dict) self.assertIn("line", sanitized) # Make sure the architecture is in line self.assertEqual( sanitized["line"], "deb [arch=amd64] http://cdn-aws.deb.debian.org/debian/ stretch main", )
def test_expand_repo_def(): """ Test aptpkg.expand_repo_def when the repo exists. """ test_repo, comps = get_current_repo() ret = aptpkg.expand_repo_def(repo=test_repo) for key in [ "comps", "dist", "uri", "line", "architectures", "file", "type", ]: assert key in ret assert pathlib.Path(ret["file"]).is_file() assert ret["dist"] in ret["line"] if isinstance(ret["comps"], list): for comp in ret["comps"]: assert comp in ret["line"] else: assert ret["comps"] in ret["line"]