From 85bd7d622e70a17dfabf4f4b7172aa41d368a6e0 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 7 Aug 2014 12:52:18 +0530 Subject: [PATCH] Add a swiftonfile specific functional test Test whether files created over mountpoint can be accessed over Swift using GET. Signed-off-by: Prashanth Pai --- test/functional/swift_on_file_tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/functional/swift_on_file_tests.py b/test/functional/swift_on_file_tests.py index c864a6a..3537c2f 100644 --- a/test/functional/swift_on_file_tests.py +++ b/test/functional/swift_on_file_tests.py @@ -135,3 +135,26 @@ class TestSwiftOnFile(Base): md5_returned = hashlib.md5(data_read_from_mountP).hexdigest() self.assertEquals(md5_returned, file_info['etag']) fhOnMountPoint.close() + + def test_GET_on_file_created_over_mountpoint(self): + file_name = Utils.create_name() + + # Create a file over mountpoint + file_path = os.path.join(self.env.root_dir, + 'AUTH_' + self.env.account.name, + self.env.container.name, file_name) + + data = "I'm whatever Gotham needs me to be." + data_hash = hashlib.md5(data).hexdigest() + + with open(file_path, 'w') as f: + f.write(data) + + # Access the file over Swift as an object + object_item = self.env.container.file(file_name) + self.assert_(data == object_item.read()) + self.assert_status(200) + + # Confirm that Etag is present in response headers + self.assert_(data_hash == object_item.info()['etag']) + self.assert_status(200)