Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jul 28, 2024
1 parent a2ee180 commit a02ac26
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions src/mxmake/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def test_PloneSite_all_defaults(self, tempdir):
TRUTHY = frozenset(("t", "true", "y", "yes", "on", "1"))
def asbool(value: str|bool|None) -> bool:
def asbool(value: str | bool | None) -> bool:
"""Return the boolean value ``True`` if the case-lowered value of string
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the
boolean values ``True`` or ``False``, return it.
Expand All @@ -889,7 +889,14 @@ def asbool(value: str|bool|None) -> bool:
return value.strip().lower() in TRUTHY
PLONE_SITE_PURGE = asbool(os.getenv("PLONE_SITE_PURGE"))
PLONE_SITE_PURGE = asbool(os.getenv("PLONE_SITE_PURGE", "false"))
PLONE_SITE_PURGE_FAIL_IF_NOT_EXISTS = asbool(
os.getenv("PLONE_SITE_PURGE_FAIL_IF_NOT_EXISTS", "true")
)
PLONE_SITE_CREATE = asbool(os.getenv("PLONE_SITE_CREATE", "true"))
PLONE_SITE_CREATE_FAIL_IF_EXISTS = asbool(
os.getenv("PLONE_SITE_CREATE_FAIL_IF_EXISTS", "true")
)
config = {
"site_id": "Plone",
Expand All @@ -913,18 +920,33 @@ def asbool(value: str|bool|None) -> bool:
app.manage_delObjects([config["site_id"]])
transaction.commit()
app._p_jar.sync()
print(f"Existing site with id={config['site_id']} purged!")
if not PLONE_SITE_CREATE:
print("Done.")
exit(0)
else:
print(f"Site with id {config['site_id']} does not exist!")
exit(0)
if config["site_id"] in app.objectIds():
print(f"Site with id {config['site_id']} already exists!")
exit(1)
site = create(app, "", config)
transaction.commit()
app._p_jar.sync()
print(f"Site with id={config['site_id']} does not exist!")
if PLONE_SITE_PURGE_FAIL_IF_NOT_EXISTS:
print("...failure!")
exit(1)
if not PLONE_SITE_CREATE:
print("Done.")
exit(0)
if PLONE_SITE_CREATE:
if config["site_id"] in app.objectIds():
print(f"Site with id={config['site_id']} already exists!")
if PLONE_SITE_CREATE_FAIL_IF_EXISTS:
print("...failure!")
exit(1)
print("Done.")
exit(0)
site = create(app, "", config)
transaction.commit()
app._p_jar.sync()
print(f"New site with id={config['site_id']} created!")
print("Done.")
''',
f.read(),
)

0 comments on commit a02ac26

Please sign in to comment.