Added date-matching support for list_considering (#7306)

added date-matching support for list_considering, fixes #7296

Co-authored-by: Michael Deyaso <mdeyaso@fusioniq.io>
This commit is contained in:
Michael Deyaso 2023-02-01 13:32:53 +03:00 committed by GitHub
parent 8046d6f575
commit 8af9eb47c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -164,8 +164,12 @@ class Archives(abc.MutableMapping):
sort_by=args.sort_by.split(","), sort_by=args.sort_by.split(","),
consider_checkpoints=consider_checkpoints, consider_checkpoints=consider_checkpoints,
match=args.match_archives, match=args.match_archives,
first=args.first, first=getattr(args, "first", None),
last=args.last, last=getattr(args, "last", None),
older=getattr(args, "older", None),
newer=getattr(args, "newer", None),
oldest=getattr(args, "oldest", None),
newest=getattr(args, "newest", None),
) )
def set_raw_dict(self, d): def set_raw_dict(self, d):

View File

@ -40,6 +40,32 @@ class ArchiverTestCase(ArchiverTestCaseBase):
self.assert_in("test-1 comment 1" + os.linesep, output_3) self.assert_in("test-1 comment 1" + os.linesep, output_3)
self.assert_in("test-2 comment 2" + os.linesep, output_3) self.assert_in("test-2 comment 2" + os.linesep, output_3)
def test_date_matching(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
earliest_ts = "2022-11-20T23:59:59"
ts_in_between = "2022-12-18T23:59:59"
self.create_src_archive("archive1", ts=earliest_ts)
self.create_src_archive("archive2", ts=ts_in_between)
self.create_src_archive("archive3")
output = self.cmd(f"--repo={self.repository_location}", "rlist", "-v", "--oldest=23e", exit_code=2)
output = self.cmd(f"--repo={self.repository_location}", "rlist", "-v", "--oldest=1m", exit_code=0)
self.assert_in("archive1", output)
self.assert_in("archive2", output)
self.assert_not_in("archive3", output)
output = self.cmd(f"--repo={self.repository_location}", "rlist", "-v", "--newest=1m", exit_code=0)
self.assert_in("archive3", output)
self.assert_not_in("archive2", output)
self.assert_not_in("archive1", output)
output = self.cmd(f"--repo={self.repository_location}", "rlist", "-v", "--newer=1d", exit_code=0)
self.assert_in("archive3", output)
self.assert_not_in("archive1", output)
self.assert_not_in("archive2", output)
output = self.cmd(f"--repo={self.repository_location}", "rlist", "-v", "--older=1d", exit_code=0)
self.assert_in("archive1", output)
self.assert_in("archive2", output)
self.assert_not_in("archive3", output)
def test_rlist_consider_checkpoints(self): def test_rlist_consider_checkpoints(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
self.cmd(f"--repo={self.repository_location}", "create", "test1", src_dir) self.cmd(f"--repo={self.repository_location}", "create", "test1", src_dir)