def test_must_unzip(self, verify_external_attributes): self._reset(verify_external_attributes) with self._create_zip(self.files_with_external_attr, verify_external_attributes) as zip_file_name: with self._temp_dir() as extract_dir: unzip(zip_file_name, extract_dir) for root, dirs, files in os.walk(extract_dir): for file in files: self._verify_file(extract_dir, file, root, verify_external_attributes) self._verify_file_count(verify_external_attributes)
def do_extract_and_merge_schemas_code(download_location, output_dir, project_name, template_location): """ Unzips schemas generated code and merge it with cookiecutter genertaed source. :param download_location: :param output_dir: :param project_name: :param template_location: """ click.echo("Merging code bindings...") cookiecutter_json_path = os.path.join(template_location, "cookiecutter.json") with open(cookiecutter_json_path, "r") as cookiecutter_json: cookiecutter_json_data = cookiecutter_json.read() cookiecutter_json = json.loads(cookiecutter_json_data) function_name = cookiecutter_json["function_name"] copy_location = os.path.join(output_dir, project_name, function_name) unzip(download_location, copy_location)
def test_must_unzip(self, check_permissions): with self._create_zip(self.files_with_permissions, check_permissions) as zip_file_name: with self._temp_dir() as extract_dir: unzip(zip_file_name, extract_dir) for root, dirs, files in os.walk(extract_dir): for file in files: filepath = os.path.join(extract_dir, root, file) perm = oct(stat.S_IMODE(os.stat(filepath).st_mode)) key = os.path.relpath(filepath, extract_dir) expected_permission = oct(self.files_with_permissions[key]) self.assertIn(key, self.files_with_permissions) if check_permissions: self.assertEquals(expected_permission, perm, "File {} has wrong permission {}".format(key, perm))