def test_eq(self): docker_config_one = DockerConfig(self.valid_config) docker_config_two = DockerConfig(self.valid_config) self.assertEqual(docker_config_one, docker_config_two) docker_config_two = DockerConfig(self.valid_config_diff) self.assertNotEqual(docker_config_one, docker_config_two) docker_config_two = GithubConfig(self.github_config) self.assertNotEqual(docker_config_one, docker_config_two)
def test_no_login_config(self): with self.assertRaises(InvalidRLIConfiguration) as context: DockerConfig(self.no_login_config) # Don't forget the space at the end self.assertEqual("InvalidRLIConfiguration has been raised: Docker login was not provided. ", str(context.exception))
def test_no_password_config(self): with self.assertRaises(InvalidRLIConfiguration) as context: DockerConfig(self.no_password_config) self.assertEqual( "InvalidRLIConfiguration has been raised: Docker password was not provided.", str(context.exception), )
def test_neq(self, mock_open, mock_load): mock_load.return_value = self.valid_config mock_open.read_data = str(self.valid_config) rli_config = RLIConfig() docker_config = DockerConfig(self.valid_config["docker"]) self.assertNotEqual(rli_config, docker_config)
def test_get_config_or_exit_valid_config(self, mock_open, mock_load): mock_load.return_value = self.valid_config mock_open.read_data = str(self.valid_config) rli_config = get_rli_config_or_exit() docker_config = DockerConfig(self.valid_config["docker"]) github_config = GithubConfig(self.valid_config["github"]) self.assertEqual(docker_config, rli_config.docker_config) self.assertEqual(github_config, rli_config.github_config)
def test_eq(self): github_config_one = GithubConfig(self.valid_config) github_config_two = GithubConfig(self.valid_config) self.assertEqual(github_config_one, github_config_two) github_config_two = GithubConfig(self.no_password_config) self.assertNotEqual(github_config_one, github_config_two) github_config_two = DockerConfig(self.docker_config) self.assertNotEqual(github_config_one, github_config_two)
def test_valid_config(self, mock_open, mock_load): mock_load.return_value = self.valid_config mock_open.read_data = str(self.valid_config) rli_config = RLIConfig() docker_config = DockerConfig(self.valid_config["docker"]) github_config = GithubConfig(self.valid_config["github"]) self.assertEqual(docker_config, rli_config.docker_config) self.assertEqual(github_config, rli_config.github_config) mock_docker = Mock() mock_github = Mock() rli_config._docker_config = mock_docker rli_config._github_config = mock_github self.assertIs(mock_docker, rli_config.docker_config) self.assertIs(mock_github, rli_config.github_config)
def test_valid_config(self): docker_config = DockerConfig(self.valid_config) self.assertEqual(self.valid_config["registry"], docker_config.registry) self.assertEqual(self.valid_config["login"], docker_config.login) self.assertEqual(self.valid_config["password"], docker_config.password)
def test_no_registry_config(self): docker_config = DockerConfig(self.no_registry_config) self.assertEqual("", docker_config.registry) self.assertEqual(self.no_registry_config["login"], docker_config.login) self.assertEqual(self.no_registry_config["password"], docker_config.password)