def test_get_apps_for_org_should_raise_a_failed_activity_exception_when_no_apps_found(call_api, mock_get_org_by_name): call_api.return_value = responses.FakeResponse(status_code=200, text=None, json=lambda: {'total_results': 0}) org_name = responses.org['entity']['name'] with pytest.raises(FailedActivity) as exception: get_apps_for_org(org_name, config.config, secrets.secrets) assert "apps for organization name {o} not found".format(o=org_name) in str(exception)
def test_get_app_by_name_expect_fullname(call_api): apps = responses.apps.copy() apps['total_results'] = 0 apps['resources'] = [] call_api.return_value = responses.FakeResponse( status_code=200, text=None, json=lambda: apps) with pytest.raises(FailedActivity) as ex: get_app_by_name("my-", config.config, secrets.secrets)
def test_get_apps_for_org(call_api, mock_get_org_by_name): call_api.return_value = responses.FakeResponse(status_code=200, text=None, json=lambda: responses.apps) org_name = responses.org['entity']['name'] org_guid = responses.org['metadata']['guid'] result = get_apps_for_org(org_name, config.config, secrets.secrets) mock_get_org_by_name.assert_has_calls([call(org_name, config.config, secrets.secrets)]) query = {"q": ['organization_guid:' + org_guid]} call_api.assert_has_calls([call("/v2/apps", config.config, secrets.secrets, query=query)]) assert result == responses.apps
def test_list_apps(call_api): call_api.return_value = responses.FakeResponse( status_code=200, text=None, json=lambda: responses.apps) apps = list_apps(config.config, secrets.secrets) assert apps["total_results"] == 1
def test_get_app_by_name_returns_the_app_with_exact_name(call_api): call_api.return_value = responses.FakeResponse( status_code=200, text=None, json=lambda: responses.apps) app = get_app_by_name("my-app", config.config, secrets.secrets) assert app["entity"]["name"] == "my-app"