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_no_password_config(self): github_config = GithubConfig(self.no_password_config) self.assertEqual(self.no_password_config["organization"], github_config.organization) self.assertEqual(self.no_password_config["login"], github_config.login) self.assertEqual("", github_config.password)
def test_valid_config(self): github_config = GithubConfig(self.valid_config) self.assertEqual(self.valid_config["organization"], github_config.organization) self.assertEqual(self.valid_config["login"], github_config.login) self.assertEqual(self.valid_config["password"], github_config.password)
def test_no_login_config(self): with self.assertRaises(InvalidRLIConfiguration) as context: GithubConfig(self.no_login_config) # Don't forget the space at the end self.assertEqual("InvalidRLIConfiguration has been raised: Github login was not provided.", str(context.exception))
def test_no_organization_config(self): with self.assertRaises(InvalidRLIConfiguration) as context: GithubConfig(self.no_organization_config) self.assertEqual( "InvalidRLIConfiguration has been raised: Github organization was not provided. ", str(context.exception), )
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): 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 setUp(self): self.valid_github_config = GithubConfig({ "organization": "some_org", "login": "******", "password": "******" }) self.create_repo_args = ("some name", "some description", "true") self.mock_create_repo = Mock() self.mock_get_user = Mock() self.mock_get_user.create_repo = self.mock_create_repo self.rli_github = RLIGithub(self.valid_github_config)
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 setUp(self): self.repo_name = "some name" self.repo_desc = "some description" self.repo_private = "true" self.github_config = GithubConfig({ "organization": "some_org", "login": "******", "password": "******" }) self.mock_rli_config = Mock() self.mock_rli_config.github_config = self.github_config self.mock_github = Mock() self.mock_logging_info = Mock() github.Github = self.mock_github cmd_github.get_config_or_exit = self.mock_rli_config cmd_github.logging.info = self.mock_logging_info
def setUp(self): self.repo_name = "some-name" self.public_key = "1PjwOt4yg9yZsEQLUOCPqZRigVMPA4g+6cuGc2ssS1c=" self.public_key_id = "09835109" self.secret_name = "A_SECRET" self.secret_value = "AKDJFLS" self.valid_github_config = GithubConfig({ "organization": "some_org", "login": "******", "password": "******", }) self.create_repo_args = ("some name", "some description", "true") self.mock_create_repo = Mock() self.mock_get_user = Mock() self.mock_get_user.create_repo = self.mock_create_repo self.mock_response_return = { "key": self.public_key, "key_id": self.public_key_id, } self.mock_requests_get = Mock() self.mock_requests_get.return_value = MockResponse( 200, self.mock_response_return) github.requests.get = self.mock_requests_get self.mock_requests_put = Mock() self.mock_requests_put.return_value = MockResponse( 204, self.mock_response_return) github.requests.put = self.mock_requests_put self.rli_github = RLIGithub(self.valid_github_config)