Path: blob/develop/tests/unit/customizations/s3/__init__.py
1569 views
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12import os131415class FakeTransferFuture(object):16def __init__(self, result=None, exception=None, meta=None):17self._result = result18self._exception = exception19self.meta = meta2021def result(self):22if self._exception:23raise self._exception24return self._result252627class FakeTransferFutureMeta(object):28def __init__(self, size=None, call_args=None, transfer_id=None):29self.size = size30self.call_args = call_args31self.transfer_id = transfer_id323334class FakeTransferFutureCallArgs(object):35def __init__(self, **kwargs):36for kwarg, val in kwargs.items():37setattr(self, kwarg, val)383940def make_loc_files(file_creator, size=None):41"""42This sets up the test by making a directory named some_directory. It43has the file text1.txt and the directory another_directory inside. Inside44of another_directory it creates the file text2.txt.45"""46if size:47body = "*" * size48else:49body = 'This is a test.'5051filename1 = file_creator.create_file(52os.path.join('some_directory', 'text1.txt'), body)5354filename2 = file_creator.create_file(55os.path.join('some_directory', 'another_directory', 'text2.txt'), body)56filename1 = str(filename1)57filename2 = str(filename2)58return [filename1, filename2, os.path.dirname(filename2),59os.path.dirname(filename1)]606162def clean_loc_files(file_creator):63"""64Removes all of the local files made.65"""66file_creator.remove_all()676869def compare_files(self, result_file, ref_file):70"""71Ensures that the FileStat's properties are what they72are suppose to be.73"""74self.assertEqual(result_file.src, ref_file.src)75self.assertEqual(result_file.dest, ref_file.dest)76self.assertEqual(result_file.compare_key, ref_file.compare_key)77self.assertEqual(result_file.size, ref_file.size)78self.assertEqual(result_file.last_update, ref_file.last_update)79self.assertEqual(result_file.src_type, ref_file.src_type)80self.assertEqual(result_file.dest_type, ref_file.dest_type)81self.assertEqual(result_file.operation_name, ref_file.operation_name)828384