From 62ed4f81ef80440550633eaaaa962a4f9383c2d3 Mon Sep 17 00:00:00 2001 From: Timur Alperovich Date: Tue, 14 Jul 2015 16:56:44 -0700 Subject: [PATCH] Add two functional tests for delimiter. The first test verifies that a delimiter will trim entries beyond the first matching instance of delimiter (after the given matching prefix, if any) and squash duplicates. So, when setting the delimiter to "-", given blobs "test", "test-foo" and "test-bar-baz", we expect only "test" (no matching delim) and "test-" (trim all characters after the first "-", and squash duplicates). The second test verifies that when a prefix is provided, the delimiter will trim entries beyond the first matching instance of the delimiter *after the given prefix*. So "bar, "bazar" which both match the prefix "ba" will be returned as "bar" (no delimiter after the matching prefix) and "baza" (after matching the prefix the remainder after the the *next* matching delimiter "a" is trimmed). Change-Id: I49a2aa8722f83e87b7d211e5c26827e93963d92a --- test/functional/tests.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/functional/tests.py b/test/functional/tests.py index f6fe875374..67be27b380 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -439,6 +439,34 @@ class TestContainer(Base): for file_item in files: self.assert_(file_item.startswith(prefix)) + def testListDelimiter(self): + cont = self.env.account.container(Utils.create_name()) + self.assert_(cont.create()) + + delimiter = '-' + files = ['test', delimiter.join(['test', 'bar']), + delimiter.join(['test', 'foo'])] + for f in files: + file_item = cont.file(f) + self.assert_(file_item.write_random()) + + results = cont.files() + results = cont.files(parms={'delimiter': delimiter}) + self.assertEqual(results, ['test', 'test-']) + + def testListDelimiterAndPrefix(self): + cont = self.env.account.container(Utils.create_name()) + self.assert_(cont.create()) + + delimiter = 'a' + files = ['bar', 'bazar'] + for f in files: + file_item = cont.file(f) + self.assert_(file_item.write_random()) + + results = cont.files(parms={'delimiter': delimiter, 'prefix': 'ba'}) + self.assertEqual(results, ['bar', 'baza']) + def testCreate(self): cont = self.env.account.container(Utils.create_name()) self.assert_(cont.create())