Filter out deleted envs in dispatch_create_environment
This commit is contained in:
parent
d6742e5169
commit
6c7667b7fc
@ -104,6 +104,7 @@ class Environments(object):
|
|||||||
.join(CLIN)
|
.join(CLIN)
|
||||||
.filter(CLIN.start_date <= now)
|
.filter(CLIN.start_date <= now)
|
||||||
.filter(CLIN.end_date > now)
|
.filter(CLIN.end_date > now)
|
||||||
|
.filter(Environment.deleted == False)
|
||||||
.filter(
|
.filter(
|
||||||
or_(
|
or_(
|
||||||
Environment.claimed_until == None,
|
Environment.claimed_until == None,
|
||||||
|
@ -102,8 +102,10 @@ def test_create_environment_baseline(csp, session):
|
|||||||
|
|
||||||
|
|
||||||
def test_dispatch_create_environment(session, monkeypatch):
|
def test_dispatch_create_environment(session, monkeypatch):
|
||||||
|
# Given that I have a portfolio with an active CLIN and two environments,
|
||||||
|
# one of which is deleted
|
||||||
portfolio = PortfolioFactory.create(
|
portfolio = PortfolioFactory.create(
|
||||||
applications=[{"environments": [{}]}],
|
applications=[{"environments": [{}, {}]}],
|
||||||
task_orders=[
|
task_orders=[
|
||||||
{
|
{
|
||||||
"create_clins": [
|
"create_clins": [
|
||||||
@ -115,13 +117,20 @@ def test_dispatch_create_environment(session, monkeypatch):
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
[e1, e2] = portfolio.applications[0].environments
|
||||||
|
e2.deleted = True
|
||||||
|
session.add(e2)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
mock = Mock()
|
mock = Mock()
|
||||||
monkeypatch.setattr("atst.jobs.create_environment", mock)
|
monkeypatch.setattr("atst.jobs.create_environment", mock)
|
||||||
environment = portfolio.applications[0].environments[0]
|
|
||||||
|
|
||||||
|
# When dispatch_create_environment is called
|
||||||
dispatch_create_environment.run()
|
dispatch_create_environment.run()
|
||||||
|
|
||||||
mock.delay.assert_called_once_with(environment_id=environment.id)
|
# It should cause the create_environment task to be called once with the
|
||||||
|
# non-deleted environment
|
||||||
|
mock.delay.assert_called_once_with(environment_id=e1.id)
|
||||||
|
|
||||||
|
|
||||||
def test_dispatch_create_atat_admin_user(session, monkeypatch):
|
def test_dispatch_create_atat_admin_user(session, monkeypatch):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user