Create route and domain method for creating a subscription
This commit is contained in:
@@ -777,3 +777,40 @@ def test_handle_update_member_with_error(set_g, monkeypatch, mock_logger):
|
||||
handle_update_member(application.id, app_role.id, form_data)
|
||||
|
||||
assert mock_logger.messages[-1] == exception
|
||||
|
||||
|
||||
def test_create_subscription_success(client, user_session):
|
||||
environment = EnvironmentFactory.create()
|
||||
|
||||
user_session(environment.portfolio.owner)
|
||||
response = client.post(
|
||||
url_for("applications.create_subscription", environment_id=environment.id),
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
"applications.settings",
|
||||
application_id=environment.application.id,
|
||||
_external=True,
|
||||
fragment="application-environments",
|
||||
_anchor="application-environments",
|
||||
)
|
||||
|
||||
|
||||
def test_create_subscription_failure(client, user_session, monkeypatch):
|
||||
environment = EnvironmentFactory.create()
|
||||
|
||||
def _raise_csp_exception(*args, **kwargs):
|
||||
raise GeneralCSPException("An error occurred.")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"atst.domain.csp.cloud.MockCloudProvider.create_subscription",
|
||||
_raise_csp_exception,
|
||||
)
|
||||
|
||||
user_session(environment.portfolio.owner)
|
||||
response = client.post(
|
||||
url_for("applications.create_subscription", environment_id=environment.id),
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
|
Reference in New Issue
Block a user