aboutsummaryrefslogtreecommitdiff
path: root/python/pip_install/tools/wheel_installer/wheel_installer_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/pip_install/tools/wheel_installer/wheel_installer_test.py')
-rw-r--r--python/pip_install/tools/wheel_installer/wheel_installer_test.py84
1 files changed, 52 insertions, 32 deletions
diff --git a/python/pip_install/tools/wheel_installer/wheel_installer_test.py b/python/pip_install/tools/wheel_installer/wheel_installer_test.py
index 8758b67..6eacd1f 100644
--- a/python/pip_install/tools/wheel_installer/wheel_installer_test.py
+++ b/python/pip_install/tools/wheel_installer/wheel_installer_test.py
@@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import json
import os
import shutil
import tempfile
import unittest
from pathlib import Path
-from python.pip_install.tools.wheel_installer import wheel_installer
+from python.pip_install.tools.wheel_installer import wheel, wheel_installer
class TestRequirementExtrasParsing(unittest.TestCase):
@@ -54,30 +55,6 @@ class TestRequirementExtrasParsing(unittest.TestCase):
)
-class BazelTestCase(unittest.TestCase):
- def test_generate_entry_point_contents(self):
- got = wheel_installer._generate_entry_point_contents("sphinx.cmd.build", "main")
- want = """#!/usr/bin/env python3
-import sys
-from sphinx.cmd.build import main
-if __name__ == "__main__":
- sys.exit(main())
-"""
- self.assertEqual(got, want)
-
- def test_generate_entry_point_contents_with_shebang(self):
- got = wheel_installer._generate_entry_point_contents(
- "sphinx.cmd.build", "main", shebang="#!/usr/bin/python"
- )
- want = """#!/usr/bin/python
-import sys
-from sphinx.cmd.build import main
-if __name__ == "__main__":
- sys.exit(main())
-"""
- self.assertEqual(got, want)
-
-
class TestWhlFilegroup(unittest.TestCase):
def setUp(self) -> None:
self.wheel_name = "example_minimal_package-0.0.1-py3-none-any.whl"
@@ -90,18 +67,61 @@ class TestWhlFilegroup(unittest.TestCase):
def test_wheel_exists(self) -> None:
wheel_installer._extract_wheel(
- self.wheel_path,
+ Path(self.wheel_path),
installation_dir=Path(self.wheel_dir),
extras={},
- pip_data_exclude=[],
enable_implicit_namespace_pkgs=False,
- repo_prefix="prefix_",
+ platforms=[],
+ )
+
+ want_files = [
+ "metadata.json",
+ "site-packages",
+ self.wheel_name,
+ ]
+ self.assertEqual(
+ sorted(want_files),
+ sorted(
+ [
+ str(p.relative_to(self.wheel_dir))
+ for p in Path(self.wheel_dir).glob("*")
+ ]
+ ),
+ )
+ with open("{}/metadata.json".format(self.wheel_dir)) as metadata_file:
+ metadata_file_content = json.load(metadata_file)
+
+ want = dict(
+ version="0.0.1",
+ name="example-minimal-package",
+ deps=[],
+ deps_by_platform={},
+ entry_points=[],
+ )
+ self.assertEqual(want, metadata_file_content)
+
+
+class TestWheelPlatform(unittest.TestCase):
+ def test_wheel_os_alias(self):
+ self.assertEqual("OS.osx", str(wheel.OS.osx))
+ self.assertEqual(str(wheel.OS.darwin), str(wheel.OS.osx))
+
+ def test_wheel_arch_alias(self):
+ self.assertEqual("Arch.x86_64", str(wheel.Arch.x86_64))
+ self.assertEqual(str(wheel.Arch.amd64), str(wheel.Arch.x86_64))
+
+ def test_wheel_platform_alias(self):
+ give = wheel.Platform(
+ os=wheel.OS.darwin,
+ arch=wheel.Arch.amd64,
+ )
+ alias = wheel.Platform(
+ os=wheel.OS.osx,
+ arch=wheel.Arch.x86_64,
)
- self.assertIn(self.wheel_name, os.listdir(self.wheel_dir))
- with open("{}/BUILD.bazel".format(self.wheel_dir)) as build_file:
- build_file_content = build_file.read()
- self.assertIn("filegroup", build_file_content)
+ self.assertEqual("osx_x86_64", str(give))
+ self.assertEqual(str(alias), str(give))
if __name__ == "__main__":