def test_check_path_type_fail(self): # This tests the class's ability to determine whether the correct # path types have been passed for a particular command. It test every # possible combination that is incorrect for every command. cmds = {'cp': ['local', 'locallocal', 's3'], 'mv': ['local', 'locallocal', 's3'], 'rm': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'ls': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'sync': ['local', 'locallocal', 's3'], 'mb': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'rb': ['local', 'locallocal', 's3s3', 'locals3', 's3local']} s3_file = 's3://' + self.bucket + '/' + 'text1.txt' local_file = self.loc_files[0] combos = {'s3s3': [s3_file, s3_file], 's3local': [s3_file, local_file], 'locals3': [local_file, s3_file], 's3': [s3_file], 'local': [local_file], 'locallocal': [local_file, local_file]} for cmd in cmds.keys(): cmd_param = CommandParameters(self.session, cmd, {}) cmd_param.check_region(mock.Mock()) wrong_paths = cmds[cmd] for path_args in wrong_paths: with self.assertRaises(TypeError): cmd_param.check_path_type(combos[path_args])
def test_check_path_type_pass(self): # This tests the class's ability to determine whether the correct # path types have been passed for a particular command. It test every # possible combination that is correct for every command. cmds = { 'cp': ['locals3', 's3s3', 's3local'], 'mv': ['locals3', 's3s3', 's3local'], 'rm': ['s3'], 'mb': ['s3'], 'rb': ['s3'], 'sync': ['locals3', 's3s3', 's3local'] } s3_file = 's3://' + self.bucket + '/' + 'text1.txt' local_file = self.loc_files[0] combos = { 's3s3': [s3_file, s3_file], 's3local': [s3_file, local_file], 'locals3': [local_file, s3_file], 's3': [s3_file], 'local': [local_file], 'locallocal': [local_file, local_file] } for cmd in cmds.keys(): cmd_param = CommandParameters(self.session, cmd, {}) cmd_param.add_region(mock.Mock()) correct_paths = cmds[cmd] for path_args in correct_paths: cmd_param.check_path_type(combos[path_args])
def test_check_path_type_fail(self): """ This tests the class's ability to determine whether the correct path types have been passed for a particular command. It test every possible combination that is incorrect for every command. """ cmds = { 'cp': ['local', 'locallocal', 's3'], 'mv': ['local', 'locallocal', 's3'], 'rm': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'ls': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'sync': ['local', 'locallocal', 's3'], 'mb': ['local', 'locallocal', 's3s3', 'locals3', 's3local'], 'rb': ['local', 'locallocal', 's3s3', 'locals3', 's3local'] } s3_file = 's3://' + self.bucket + '/' + 'text1.txt' local_file = self.loc_files[0] combos = { 's3s3': [s3_file, s3_file], 's3local': [s3_file, local_file], 'locals3': [local_file, s3_file], 's3': [s3_file], 'local': [local_file], 'locallocal': [local_file, local_file] } for cmd in cmds.keys(): cmd_param = CommandParameters(self.session, cmd, {}) cmd_param.check_region([]) wrong_paths = cmds[cmd] for path_args in wrong_paths: with self.assertRaises(TypeError): cmd_param.check_path_type(combos[path_args])
def test_check_path_type_fail(self): """ This tests the class's ability to determine whether the correct path types have been passed for a particular command. It test every possible combination that is incorrect for every command. """ cmds = { "cp": ["local", "locallocal", "s3"], "mv": ["local", "locallocal", "s3"], "rm": ["local", "locallocal", "s3s3", "locals3", "s3local"], "ls": ["local", "locallocal", "s3s3", "locals3", "s3local"], "sync": ["local", "locallocal", "s3"], "mb": ["local", "locallocal", "s3s3", "locals3", "s3local"], "rb": ["local", "locallocal", "s3s3", "locals3", "s3local"], } s3_file = "s3://" + self.bucket + "/" + "text1.txt" local_file = self.loc_files[0] combos = { "s3s3": [s3_file, s3_file], "s3local": [s3_file, local_file], "locals3": [local_file, s3_file], "s3": [s3_file], "local": [local_file], "locallocal": [local_file, local_file], } for cmd in cmds.keys(): cmd_param = CommandParameters(self.session, cmd, {}) cmd_param.check_region([]) wrong_paths = cmds[cmd] for path_args in wrong_paths: with self.assertRaises(TypeError): cmd_param.check_path_type(combos[path_args])