def test_defining_custom_structure(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) item = self.__makeFile(tempdir, "file1") p.add(item) p.add(item, "directory1/file1") p.add(item, "directory2/file1") p.add(item, "directory2/subdir1/file1") p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(7, len(package_contents)) self.assertIn("file1", package_contents) self.assertIn("directory1/", package_contents) self.assertIn("directory2/", package_contents) self.assertIn("directory1/file1", package_contents) self.assertIn("directory2/file1", package_contents) self.assertIn("directory2/subdir1/", package_contents) self.assertIn("directory2/subdir1/file1", package_contents)
def test_defining_custom_structure(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) item = self.__makeFile(tempdir,"file1") p.add(item) p.add(item, "directory1/file1") p.add(item, "directory2/file1") p.add(item, "directory2/subdir1/file1") p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(7, len(package_contents)) self.assertIn("file1", package_contents) self.assertIn("directory1/", package_contents) self.assertIn("directory2/", package_contents) self.assertIn("directory1/file1", package_contents) self.assertIn("directory2/file1", package_contents) self.assertIn("directory2/subdir1/", package_contents) self.assertIn("directory2/subdir1/file1", package_contents)
def test_adding_single_file(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir,"file1")) p.package() self.assertTrue(os.path.exists(package_file)) self.assertIn("file1", self.__packageContents(package_file))
def test_relative_paths(self): with TempDirectory(os.getcwd()) as tempdir: relative_path = os.path.basename(tempdir) package_file = os.path.join(relative_path,"package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir,"file1")) p.package() self.assertTrue(os.path.exists(package_file)) self.assertIn("file1", self.__packageContents(package_file))
def test_adding_directories(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) directory = self.__makeDirectory(tempdir,"dir1") self.__makeFile(directory,"file1") p.add(directory) p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(2, len(package_contents)) self.assertIn("dir1/", package_contents) self.assertIn("dir1/file1", package_contents)
def package(self): ipa = Packager(self.ipa_path) # Include App ipa.add(self.app_path, "Payload/%s.app" % self.app_name) # Include WatchKit Binary if self.__should_include_watchkit(): ipa.add(self.watchkit_binary, "WatchKitSupport/WK") # Include Swift Libraries swift_libs_to_include = self.__swift_libs_to_copy() for lib in swift_libs_to_include: lib_path = os.path.join(self.os_libs_path, lib) ipa.add(lib_path, "SwiftSupport/%s" % os.path.basename(lib)) ipa.package()
def test_adding_single_file(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir, "file1")) p.package() self.assertTrue(os.path.exists(package_file)) self.assertIn("file1", self.__packageContents(package_file))
def test_adding_multiple_file(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir, "file1")) p.add(self.__makeFile(tempdir, "file2")) p.add(self.__makeFile(tempdir, "file3")) p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(3, len(package_contents)) self.assertIn("file1", package_contents) self.assertIn("file2", package_contents) self.assertIn("file3", package_contents)
def test_relative_paths(self): with TempDirectory(os.getcwd()) as tempdir: relative_path = os.path.basename(tempdir) package_file = os.path.join(relative_path, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir, "file1")) p.package() self.assertTrue(os.path.exists(package_file)) self.assertIn("file1", self.__packageContents(package_file))
def test_adding_multiple_file(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) p.add(self.__makeFile(tempdir,"file1")) p.add(self.__makeFile(tempdir,"file2")) p.add(self.__makeFile(tempdir,"file3")) p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(3, len(package_contents)) self.assertIn("file1", package_contents) self.assertIn("file2", package_contents) self.assertIn("file3", package_contents)
def test_adding_directories(self): with TempDirectory() as tempdir: package_file = os.path.join(tempdir, "package.zip") p = Packager(package_file) self.assertFalse(os.path.exists(package_file)) directory = self.__makeDirectory(tempdir, "dir1") self.__makeFile(directory, "file1") p.add(directory) p.package() self.assertTrue(os.path.exists(package_file)) package_contents = self.__packageContents(package_file) self.assertEqual(2, len(package_contents)) self.assertIn("dir1/", package_contents) self.assertIn("dir1/file1", package_contents)
def package(self): ipa = Packager(self.ipa_path) # Include App ipa.add(self.app_path, "Payload/%s.app" % self.app_name) # Include WatchKit Binary if needed if self.__should_include_watchkit_support(): ipa.add(self.watchkit_support_binary, "WatchKitSupport/WK") # Include watchOS 2 WatchKit Binary if needed if self.__should_include_watchkit2_support(): ipa.add(self.watchkit2_support_binary, "WatchKitSupport2/WK") # Include Swift Libraries swift_libs_to_include = self.__swift_libs_to_copy() for lib in swift_libs_to_include: lib_path = os.path.join(self.os_libs_path, lib) ipa.add(lib_path, "SwiftSupport/%s" % os.path.basename(lib)) ipa.package()