Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/src/core_logic/ExecutionConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def __get_max_patch_publish_date(self, health_store_id):
""" Obtains implicit date ceiling for published date - converts pub_off_sku_2024.04.01 to 20240401T000000Z """
max_patch_publish_date = str()
if health_store_id is not None and health_store_id != "":
split = health_store_id.rsplit("_", 1)
if len(split) == 2 and len(split[1]) == 10:
max_patch_publish_date = "{0}T000000Z".format(split[1].replace(".", ""))
date_candidate = str(health_store_id)[-10:].replace(".", "") # last 10 characters and remove '.'
if len(date_candidate) == 8 and date_candidate.isdigit() and str(health_store_id)[-11:-10] == "_":
max_patch_publish_date = date_candidate + "T000000Z"

self.composite_logger.log_debug("[EC] Getting max patch publish date. [MaxPatchPublishDate={0}][HealthStoreId={1}]".format(str(max_patch_publish_date), str(health_store_id)))
return max_patch_publish_date
Expand Down
45 changes: 12 additions & 33 deletions src/core/tests/Test_ExecutionConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,21 @@ def setUp(self):
def tearDown(self):
pass

def test_healthstoreid_acceptable_format(self):
argument_composer = ArgumentComposer()
argument_composer.health_store_id = str("pub_off_sku_2020.09.29")
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == "20200929T000000Z")
runtime.stop()

argument_composer = ArgumentComposer()
argument_composer.health_store_id = str("pu_b_off_sk_u_2020.09.29")
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == "20200929T000000Z")
runtime.stop()

def test_healthstoreid_unacceptable_format(self):
argument_composer = ArgumentComposer()
argument_composer.health_store_id = str()
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == str())
runtime.stop()

argument_composer = ArgumentComposer()
argument_composer.health_store_id = str("pub_off_sku_20.09.29")
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == str())
runtime.stop()

argument_composer = ArgumentComposer()
argument_composer.health_store_id = str("pub_off_sku_2020.9.29")
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == str())
runtime.stop()
def test_get_max_patch_publish_date(self):
test_input_output_table = [
["pub_off_sku_2020.09.29", "20200929T000000Z"],
["pu_b_off_sk_u_2020.09.29", "20200929T000000Z"],
[str(), str()],
["pub_off_sku_20.09.29", str()],
["pub_off_sku_2020.9.29", str()],
["pub_off_sk_u2020.09.29", str()],
["x_2020.09.29", "20200929T000000Z"] # theoretically okay
]

argument_composer = ArgumentComposer()
argument_composer.health_store_id = str("pub_off_sk_u2020.09.29")
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
self.assertTrue(runtime.execution_config.max_patch_publish_date == str())
for row in test_input_output_table:
self.assertEqual(runtime.execution_config._ExecutionConfig__get_max_patch_publish_date(row[0]), row[1])
runtime.stop()


Expand Down