def test_main_get_domain(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v3/domains/3a5d3d89-3f89-4f05-8188-8a2b298c79d5", HTTPStatus.OK, None, "v3", "domains", "GET_{id}_response.json") main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_list_service_bindings(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = mock_response( '/v2/service_bindings', OK, None, 'v2', 'service_bindings', 'GET_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_list_apps(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v2/apps", HTTPStatus.OK, None, "v2", "apps", "GET_response.json") main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_list_tasks(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v3/tasks?names=task_name", HTTPStatus.OK, None, "v3", "tasks", "GET_response.json") main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_delete_apps(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.delete.return_value = self.mock_response( "/v2/apps/906775ea-622e-4bc7-af5d-9aab3b652f81", HTTPStatus.NO_CONTENT, None) main.main() self.client.delete.assert_called_with( self.client.delete.return_value.url)
def test_main_list_organizations(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = self.mock_response( '/v3/organizations', HTTPStatus.OK, None, 'v3', 'organizations', 'GET_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_delete_service_plan_visibility(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.delete.return_value = self.mock_response( '/v2/service_plan_visibilities/906775ea-622e-4bc7-af5d-9aab3b652f81', HTTPStatus.NO_CONTENT, None) main.main() self.client.delete.assert_called_with( self.client.delete.return_value.url)
def test_main_get_spaces(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = self.mock_response( '/v2/spaces/2d745a4b-67e3-4398-986e-2adbcf8f7ec9', HTTPStatus.OK, None, 'v2', 'spaces', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_create_service_plan_visibility(self): with patch("cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.post.return_value = self.mock_response( "/v2/service_plan_visibilities", HTTPStatus.CREATED, None, "v2", "service_plan_visibilities", "POST_response.json" ) main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=dict(service_plan_guid="service-plan-id", organization_guid="organization-id"), )
def test_main_get_service_binding(self): with patch('cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = self.mock_response( '/v2/service_bindings/eaabd042-8f5c-44a2-9580-1e114c36bdcb', HTTPStatus.OK, None, 'v2', 'service_bindings', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with(self.client.get.return_value.url)
def test_main_get_service_plan_visibility(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = self.mock_response( '/v2/service_plan_visibilities/a353104b-1290-418c-bc03-0e647afd0853', HTTPStatus.OK, None, 'v2', 'service_plan_visibilities', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_get_service_plan(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = self.mock_response( '/v2/service_plans/5d8f3b0f-6b5b-487f-8fed-4c2d9b812a72', HTTPStatus.OK, None, 'v2', 'service_plans', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_restage_app(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.post.return_value = self.mock_response( '/v2/apps/906775ea-622e-4bc7-af5d-9aab3b652f81/restage', HTTPStatus.CREATED, None, 'v2', 'apps', 'POST_{id}_restage_response.json') main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=None)
def test_main_get_service_instance(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = mock_response( '/v2/service_instances/df52420f-d5b9-4b86-a7d3-6d7005d1ce96', HTTPStatus.OK, None, 'v2', 'service_instances', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_get_service_key(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = mock_response( '/v2/service_keys/67755c27-28ed-4087-9688-c07d92f3bcc9', HTTPStatus.OK, None, 'v2', 'service_keys', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_create_task(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.post.return_value = mock_response( '/v3/apps/app_id/tasks', CREATED, None, 'v3', 'tasks', 'POST_response.json') main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=dict(command='rake db:migrate', name='example'))
def test_main_delete_service_key(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.delete.return_value = mock_response( '/v2/service_keys/67755c27-28ed-4087-9688-c07d92f3bcc9', HTTPStatus.NO_CONTENT, None) main.main() self.client.delete.assert_called_with( self.client.delete.return_value.url) main.main()
def test_main_get_service_broker(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = mock_response( '/v2/service_brokers/ade9730c-4ee5-4290-ad37-0b15cecd2ca6', HTTPStatus.OK, None, 'v2', 'service_brokers', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_get_service(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.get.return_value = mock_response( '/v2/services/2c883dbb-a726-4ecf-a0b7-d65588897e7f', HTTPStatus.OK, None, 'v2', 'services', 'GET_{id}_response.json') main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_push(self): class FakeOperation(object): def __init__(self): self.push = MagicMock() client = object() push_operation = FakeOperation() with patch('cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: client), \ patch('cloudfoundry_client.main.operation_commands.PushOperation', new=lambda c: push_operation): main.main() push_operation.push.assert_called_with('space_id', get_fixtures_path('fake', 'manifest_main.yml'))
def test_main_create_service_key(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.post.return_value = mock_response( '/v2/service_keys', HTTPStatus.CREATED, None, 'v2', 'service_keys', 'POST_response.json') main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=dict(service_instance_guid='service_instance_id', name='name-127'))
def test_main_get_buildpack(self): with patch("cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v3/buildpacks/6e72c33b-dff0-4020-8603-bcd8a4eb05e4", HTTPStatus.OK, None, "v3", "buildpacks", "GET_{id}_response.json", ) main.main() self.client.get.assert_called_with(self.client.get.return_value.url)
def test_main_create_service_plan_visibility(self): with patch( 'cloudfoundry_client.main.main.build_client_from_configuration', new=lambda: self.client): self.client.post.return_value = self.mock_response( '/v2/service_plan_visibilities', HTTPStatus.CREATED, None, 'v2', 'service_plan_visibilities', 'POST_response.json') main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=dict(service_plan_guid='service-plan-id', organization_guid='organization-id'))
def test_main_create_service_key(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.post.return_value = self.mock_response( "/v2/service_keys", HTTPStatus.CREATED, None, "v2", "service_keys", "POST_response.json") main.main() self.client.post.assert_called_with( self.client.post.return_value.url, json=dict(service_instance_guid="service_instance_id", name="name-127"))
def test_create_task(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.post.return_value = self.mock_response( "/v3/apps/app_id/tasks", HTTPStatus.CREATED, None, "v3", "tasks", "POST_response.json") main.main() self.client.post.assert_called_with( self.client.post.return_value.url, files=None, json=dict(command="rake db:migrate", name="example"))
def test_main_get_organization_quotas(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v3/organization_quotas/1d3bf0ec-5806-43c4-b64e-8364dba1086a", HTTPStatus.OK, None, "v3", "organization_quotas", "GET_{id}_response.json", ) main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_main_get_organizations(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.get.return_value = self.mock_response( "/v3/organizations/24637893-3b77-489d-bb79-8466f0d88b52", HTTPStatus.OK, None, "v3", "organizations", "GET_{id}_response.json", ) main.main() self.client.get.assert_called_with( self.client.get.return_value.url)
def test_cancel_task(self): with patch( "cloudfoundry_client.main.main.build_client_from_configuration", new=lambda: self.client): self.client.post.return_value = self.mock_response( "/v3/tasks/task_id/actions/cancel", HTTPStatus.CREATED, None, "v3", "tasks", "POST_{id}_actions_cancel_response.json", ) main.main() self.client.post.assert_called_with( self.client.post.return_value.url, files=None, json=None)