def test_add_role_assignment_fails(self): role = 'Owner' sp = '1234567' with mock.patch('azure.cli.command_modules.role.custom.create_role_assignment') as create_role_assignment: resp = mock.Mock() resp.status_code = 500 resp.content = 'Internal Error' err = CloudError(resp) err.message = 'Internal Error' create_role_assignment.side_effect = err ok = _add_role_assignment(role, sp, delay=0, output=False) create_role_assignment.assert_called_with(role, sp) self.assertFalse(ok, 'Expected _add_role_assignment to fail')
def test_add_role_assignment_exists(self): role = 'Owner' sp = '1234567' with mock.patch('azure.cli.command_modules.role.custom.create_role_assignment') as create_role_assignment: resp = mock.Mock() resp.status_code = 409 resp.content = 'Conflict' err = CloudError(resp) err.message = 'The role assignment already exists.' create_role_assignment.side_effect = err ok = _add_role_assignment(role, sp, delay=0, output=False) create_role_assignment.assert_called_with(role, sp) self.assertTrue(ok, 'Expected _add_role_assignment to succeed')
def test_add_role_assignment_fails(self): role = 'Owner' sp = '1234567' with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = mock.Mock() resp.status_code = 500 resp.content = 'Internal Error' err = CloudError(resp) err.message = 'Internal Error' create_role_assignment.side_effect = err ok = _add_role_assignment(role, sp, delay=0, output=False) create_role_assignment.assert_called_with(role, sp) self.assertFalse(ok, 'Expected _add_role_assignment to fail')
def test_add_role_assignment_exists(self): role = 'Owner' sp = '1234567' with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = mock.Mock() resp.status_code = 409 resp.content = 'Conflict' err = CloudError(resp) err.message = 'The role assignment already exists.' create_role_assignment.side_effect = err ok = _add_role_assignment(role, sp, delay=0, output=False) create_role_assignment.assert_called_with(role, sp) self.assertTrue(ok, 'Expected _add_role_assignment to succeed')
def test_add_role_assignment_fails(self): role = 'Owner' sp = '1234567' cli_ctx = mock.MagicMock() with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = requests.Response() resp.status_code = 500 resp._content = b'Internal Error' err = CloudError(resp) err.message = 'Internal Error' create_role_assignment.side_effect = err ok = _add_role_assignment(cli_ctx, role, sp, delay=0) create_role_assignment.assert_called_with(cli_ctx, role, sp, True, scope=None) self.assertFalse(ok, 'Expected _add_role_assignment to fail')
def test_add_role_assignment_exists(self): role = 'Owner' sp = '1234567' cli_ctx = mock.MagicMock() with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = requests.Response() resp.status_code = 409 resp._content = b'Conflict' err = CloudError(resp) err.message = 'The role assignment already exists.' create_role_assignment.side_effect = err ok = _add_role_assignment(cli_ctx, role, sp, delay=0) create_role_assignment.assert_called_with(cli_ctx, role, sp, True, scope=None) self.assertTrue(ok, 'Expected _add_role_assignment to succeed')
def test_add_role_assignment_fails(self): role = 'Owner' sp = '1234567' cli_ctx = mock.MagicMock() with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = requests.Response() resp.status_code = 500 resp._content = b'Internal Error' err = CloudError(resp) err.message = 'Internal Error' create_role_assignment.side_effect = err ok = _add_role_assignment(cli_ctx, role, sp, delay=0) create_role_assignment.assert_called_with(cli_ctx, role, sp) self.assertFalse(ok, 'Expected _add_role_assignment to fail')
def test_add_role_assignment_exists(self): role = 'Owner' sp = '1234567' cli_ctx = mock.MagicMock() with mock.patch( 'azure.cli.command_modules.acs.custom.create_role_assignment') as create_role_assignment: resp = requests.Response() resp.status_code = 409 resp._content = b'Conflict' err = CloudError(resp) err.message = 'The role assignment already exists.' create_role_assignment.side_effect = err ok = _add_role_assignment(cli_ctx, role, sp, delay=0) create_role_assignment.assert_called_with(cli_ctx, role, sp) self.assertTrue(ok, 'Expected _add_role_assignment to succeed')