Skip to content

Commit

Permalink
fix testcase
Browse files Browse the repository at this point in the history
Signed-off-by: stonezdj <[email protected]>
  • Loading branch information
stonezdj committed Feb 17, 2025
1 parent ba1d863 commit 0dcefef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tests/apitests/python/library/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class Purge(base.Base):
def __init__(self):
super(Purge, self).__init__(api_type="purge")

def create_purge_schedule(self, type, cron, dry_run=True, audit_retention_hour=24, include_operations="create,delete,pull", expect_status_code=201, expect_response_body=None, **kwargs):
def create_purge_schedule(self, type, cron, dry_run=True, audit_retention_hour=24, include_event_types="create_artifact,delete_artifact,pull_artifact", expect_status_code=201, expect_response_body=None, **kwargs):
scheduleObj = v2_swagger_client.ScheduleObj(type=type)
if cron is not None:
scheduleObj.cron = cron
parameters = {
"audit_retention_hour": audit_retention_hour,
"include_operations": include_operations,
"include_event_types": include_event_types,
"dry_run": dry_run
}
schedule = v2_swagger_client.Schedule(schedule=scheduleObj, parameters=parameters)
Expand All @@ -30,11 +30,11 @@ def create_purge_schedule(self, type, cron, dry_run=True, audit_retention_hour=2
return
base._assert_status_code(expect_status_code, status_code)

def update_purge_schedule(self, type, cron, audit_retention_hour=24, include_operations="create,delete,pull", expect_status_code=200, expect_response_body=None, **kwargs):
def update_purge_schedule(self, type, cron, audit_retention_hour=24, include_event_types="create_artifact,delete_artifact,pull_artifact", expect_status_code=200, expect_response_body=None, **kwargs):
scheduleObj = v2_swagger_client.ScheduleObj(type=type, cron=cron)
parameters = {
"audit_retention_hour": audit_retention_hour,
"include_operations": include_operations,
"include_event_types": include_event_types,
"dry_run": False
}
schedule = v2_swagger_client.Schedule(schedule=scheduleObj, parameters=parameters)
Expand Down
16 changes: 8 additions & 8 deletions tests/apitests/python/test_log_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ def testLogRotation(self):
schedule_type = "Weekly"
schedule_cron = "0 0 0 * * 0"
audit_retention_hour = 24
include_operations = "create,delete,pull"
self.purge.create_purge_schedule(type=schedule_type, cron=schedule_cron, dry_run=False, audit_retention_hour=audit_retention_hour, include_operations=include_operations)
include_event_types = "create,delete,pull"
self.purge.create_purge_schedule(type=schedule_type, cron=schedule_cron, dry_run=False, audit_retention_hour=audit_retention_hour, include_event_types=include_event_types)
# 8. Verify schedule
self.verifySchedule(schedule_type, schedule_cron, audit_retention_hour, include_operations)
self.verifySchedule(schedule_type, schedule_cron, audit_retention_hour, include_event_types)
# 9. Update schedule
schedule_type = "Custom"
schedule_cron = "0 15 10 ? * *"
audit_retention_hour = 12
include_operations = "create,delete"
self.purge.update_purge_schedule(type=schedule_type, cron=schedule_cron, audit_retention_hour=audit_retention_hour, include_operations=include_operations)
include_event_types = "create,delete"
self.purge.update_purge_schedule(type=schedule_type, cron=schedule_cron, audit_retention_hour=audit_retention_hour, include_event_types=include_event_types)
# 10. Verify schedule
self.verifySchedule(schedule_type, schedule_cron, audit_retention_hour, include_operations)
self.verifySchedule(schedule_type, schedule_cron, audit_retention_hour, include_event_types)

def testLogRotationAPIPermission(self):
"""
Expand Down Expand Up @@ -125,13 +125,13 @@ def testLogRotationAPIPermission(self):
# 9. User(UA) should not have permission to update purge schedule API
self.purge.update_purge_schedule(type="Custom", cron="0 15 10 ? * *", expect_status_code=expect_status_code, expect_response_body=expect_response_body, **USER_CLIENT)

def verifySchedule(self, schedule_type, schedule_cron, audit_retention_hour, include_operations):
def verifySchedule(self, schedule_type, schedule_cron, audit_retention_hour, include_event_types):
purge_schedule = self.purge.get_purge_schedule()
job_parameters = json.loads(purge_schedule.job_parameters)
self.assertEqual(purge_schedule.schedule.type, schedule_type)
self.assertEqual(purge_schedule.schedule.cron, schedule_cron)
self.assertEqual(job_parameters["audit_retention_hour"], audit_retention_hour)
self.assertEqual(job_parameters["include_operations"], include_operations)
self.assertEqual(job_parameters["include_event_types"], include_event_types)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tests/apitests/python/test_system_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def call(self):
purge_audit_payload = {
"parameters": {
"audit_retention_hour": 24,
"include_operations": "create,delete,pull",
"include_event_types": "create_artifact,delete_artifact,pull_artifact",
"dry_run": True
},
"schedule": {
Expand Down
2 changes: 1 addition & 1 deletion tests/robot-cases/Group1-Nightly/Schedule.robot
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Test Case - Log Rotation Schedule Job
Should Be Equal As Strings ${log["job_status"]} Success
Should Be Equal As Strings ${log["job_parameters"]["audit_retention_hour"]} 48
Should Be Equal As Strings ${log["job_parameters"]["dry_run"]} False
Should Not Contain Any ${log["job_parameters"]["include_operations"]} @{exclude_operations} ignore_case=True
Should Not Contain Any ${log["job_parameters"]["include_event_types"]} @{exclude_operations} ignore_case=True
END
Should Be True ${len} > 3 and ${len} < 6
Close Browser
Expand Down

0 comments on commit 0dcefef

Please sign in to comment.