Add create_user task
This commit is contained in:
@@ -16,12 +16,18 @@ from atst.jobs import (
|
||||
dispatch_create_atat_admin_user,
|
||||
dispatch_create_environment_baseline,
|
||||
create_environment,
|
||||
do_create_user,
|
||||
)
|
||||
from atst.models.utils import claim_for_update
|
||||
from atst.domain.exceptions import ClaimFailedException
|
||||
from tests.factories import EnvironmentFactory, EnvironmentRoleFactory, PortfolioFactory
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="function")
|
||||
def csp():
|
||||
return Mock(wraps=MockCloudProvider({}, with_delay=False, with_failure=False))
|
||||
|
||||
|
||||
def test_environment_job_failure(celery_app, celery_worker):
|
||||
@celery_app.task(bind=True, base=RecordEnvironmentFailure)
|
||||
def _fail_hard(self, environment_id=None):
|
||||
@@ -63,11 +69,6 @@ yesterday = now.subtract(days=1)
|
||||
tomorrow = now.add(days=1)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="function")
|
||||
def csp():
|
||||
return Mock(wraps=MockCloudProvider({}, with_delay=False, with_failure=False))
|
||||
|
||||
|
||||
def test_create_environment_job(session, csp):
|
||||
environment = EnvironmentFactory.create()
|
||||
do_create_environment(csp, environment.id)
|
||||
@@ -291,3 +292,15 @@ def test_claim_for_update(session):
|
||||
|
||||
# The claim is released
|
||||
assert environment.claimed_until is None
|
||||
|
||||
|
||||
def test_create_user(csp, session):
|
||||
environment = EnvironmentFactory.create(
|
||||
root_user_info={"credentials": MockCloudProvider({})._auth_credentials}
|
||||
)
|
||||
environment_role = EnvironmentRoleFactory.create(environment=environment)
|
||||
do_create_user(csp, environment_role_id=environment_role.id)
|
||||
|
||||
session.refresh(environment_role)
|
||||
|
||||
assert environment_role.csp_user_id
|
||||
|
Reference in New Issue
Block a user