Add query for getting environments pending baseline creation
This commit is contained in:
parent
13861ad998
commit
c00f13de2c
@ -129,3 +129,13 @@ class Environments(object):
|
|||||||
.filter(Environment.root_user_info == text("'null'"))
|
.filter(Environment.root_user_info == text("'null'"))
|
||||||
)
|
)
|
||||||
return [environment_id for (environment_id,) in query.all()]
|
return [environment_id for (environment_id,) in query.all()]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_environments_pending_baseline_creation(cls, now) -> [str]:
|
||||||
|
query = (
|
||||||
|
cls.base_provision_query(now)
|
||||||
|
.filter(Environment.cloud_id != None)
|
||||||
|
.filter(Environment.root_user_info != text("'null'"))
|
||||||
|
.filter(Environment.baseline_info == text("'null'"))
|
||||||
|
)
|
||||||
|
return [environment_id for (environment_id,) in query.all()]
|
||||||
|
@ -214,3 +214,40 @@ class TestGetEnvironmentsPendingAtatUserCreation(EnvQueryTest):
|
|||||||
assert (
|
assert (
|
||||||
len(Environments.get_environments_pending_atat_user_creation(self.NOW)) == 0
|
len(Environments.get_environments_pending_atat_user_creation(self.NOW)) == 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestGetEnvironmentsPendingBaselineCreation(EnvQueryTest):
|
||||||
|
def test_with_provisioned_environment(self):
|
||||||
|
self.create_portfolio_with_clins(
|
||||||
|
[(self.YESTERDAY, self.TOMORROW)],
|
||||||
|
{
|
||||||
|
"cloud_id": uuid4().hex,
|
||||||
|
"root_user_info": {"foo": "bar"},
|
||||||
|
"baseline_info": {"foo": "bar"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
len(Environments.get_environments_pending_baseline_creation(self.NOW)) == 0
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_with_unprovisioned_environment(self):
|
||||||
|
self.create_portfolio_with_clins(
|
||||||
|
[(self.YESTERDAY, self.TOMORROW)],
|
||||||
|
{
|
||||||
|
"cloud_id": uuid4().hex,
|
||||||
|
"root_user_info": {"foo": "bar"},
|
||||||
|
"baseline_info": None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
len(Environments.get_environments_pending_baseline_creation(self.NOW)) == 1
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_with_unprovisioned_expired_clins_environment(self):
|
||||||
|
self.create_portfolio_with_clins(
|
||||||
|
[(self.YESTERDAY, self.YESTERDAY)],
|
||||||
|
{"cloud_id": uuid4().hex, "root_user_info": {"foo": "bar"}},
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
len(Environments.get_environments_pending_baseline_creation(self.NOW)) == 0
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user