Added tests for additional utilities of `pip_install` and `pip_parse` (#524)

diff --git a/examples/pip_install/BUILD b/examples/pip_install/BUILD
index c863292..8aa4ef7 100644
--- a/examples/pip_install/BUILD
+++ b/examples/pip_install/BUILD
@@ -2,6 +2,8 @@
 load("@bazel_skylib//rules:write_file.bzl", "write_file")
 load(
     "@pip//:requirements.bzl",
+    "data_requirement",
+    "dist_info_requirement",
     "entry_point",
     "requirement",
 )
@@ -55,18 +57,28 @@
     actual = entry_point("yamllint"),
 )
 
-py_test(
-    name = "entry_point_test",
-    srcs = ["entry_point_test.py"],
-    data = [":yamllint"],
-)
-
 # Check that our compiled requirements are up-to-date
 compile_pip_requirements(
     name = "requirements",
     extra_args = ["--allow-unsafe"],
 )
 
+# Test the use of all pip_install utilities in a single py_test
+py_test(
+    name = "pip_install_test",
+    srcs = ["pip_install_test.py"],
+    data = [
+        ":yamllint",
+        data_requirement("s3cmd"),
+        dist_info_requirement("boto3"),
+    ],
+    env = {
+        "WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")),
+        "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("boto3")),
+        "WHEEL_ENTRY_POINT": "$(rootpath :yamllint)",
+    },
+)
+
 # Assert that tags are present on resulting py_library,
 # which is useful for tooling that needs to reflect on the dep graph
 # to determine the packages it was built from.
diff --git a/examples/pip_install/entry_point_test.py b/examples/pip_install/entry_point_test.py
deleted file mode 100644
index b6b589a..0000000
--- a/examples/pip_install/entry_point_test.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python3
-
-from pathlib import Path
-import subprocess
-import unittest
-
-
-class PipParseEntryPointTest(unittest.TestCase):
-    def test_output(self):
-        self.maxDiff = None
-
-        entry_point = Path("external/pip/pypi__yamllint/rules_python_wheel_entry_point_yamllint")
-        self.assertTrue(entry_point.exists())
-
-        proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
-
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/examples/pip_install/pip_install_test.py b/examples/pip_install/pip_install_test.py
new file mode 100644
index 0000000..c5bffe9
--- /dev/null
+++ b/examples/pip_install/pip_install_test.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+from pathlib import Path
+import os
+import subprocess
+import unittest
+
+
+class PipInstallTest(unittest.TestCase):
+    maxDiff = None
+
+    def test_entry_point(self):
+        env = os.environ.get("WHEEL_ENTRY_POINT")
+        self.assertIsNotNone(env)
+
+        entry_point = Path(env)
+        self.assertTrue(entry_point.exists())
+
+        proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
+
+    def test_data(self):
+        env = os.environ.get("WHEEL_DATA_CONTENTS")
+        self.assertIsNotNone(env)
+        self.assertListEqual(
+            env.split(" "),
+            [
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/INSTALL.md",
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/LICENSE",
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/NEWS",
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/README.md",
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/data/share/man/man1/s3cmd.1",
+                "external/pip/pypi__s3cmd/s3cmd-2.1.0.data/scripts/s3cmd",
+            ],
+        )
+
+    def test_dist_info(self):
+        env = os.environ.get("WHEEL_DIST_INFO_CONTENTS")
+        self.assertIsNotNone(env)
+        self.assertListEqual(
+            env.split(" "),
+            [
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/DESCRIPTION.rst",
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/METADATA",
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/RECORD",
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/WHEEL",
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/metadata.json",
+                "external/pip/pypi__boto3/boto3-1.14.51.dist-info/top_level.txt",
+            ],
+        )
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/examples/pip_install/requirements.in b/examples/pip_install/requirements.in
index 6ecac0d..7d188ff 100644
--- a/examples/pip_install/requirements.in
+++ b/examples/pip_install/requirements.in
@@ -1,2 +1,3 @@
 boto3==1.14.51
 yamllint==1.26.3
+s3cmd==2.1.0 
diff --git a/examples/pip_install/requirements.txt b/examples/pip_install/requirements.txt
index 267c370..e4d39bb 100644
--- a/examples/pip_install/requirements.txt
+++ b/examples/pip_install/requirements.txt
@@ -32,7 +32,13 @@
 python-dateutil==2.8.2 \
     --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
     --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
-    # via botocore
+    # via
+    #   botocore
+    #   s3cmd
+python-magic==0.4.24 \
+    --hash=sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626 \
+    --hash=sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf
+    # via s3cmd
 pyyaml==5.4.1 \
     --hash=sha256:08682f6b72c722394747bddaf0aa62277e02557c0fd1c42cb853016a38f8dedf \
     --hash=sha256:0f5f5786c0e09baddcd8b4b45f20a7b5d61a7e7e99846e3c799b05c7c53fa696 \
@@ -64,6 +70,10 @@
     --hash=sha256:fdc842473cd33f45ff6bce46aea678a54e3d21f1b61a7750ce3c498eedfe25d6 \
     --hash=sha256:fe69978f3f768926cfa37b867e3843918e012cf83f680806599ddce33c2c68b0
     # via yamllint
+s3cmd==2.1.0 \
+    --hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
+    --hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
+    # via -r requirements.in
 s3transfer==0.3.7 \
     --hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 \
     --hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246
diff --git a/examples/pip_parse/BUILD b/examples/pip_parse/BUILD
index 617527d..624336f 100644
--- a/examples/pip_parse/BUILD
+++ b/examples/pip_parse/BUILD
@@ -1,4 +1,10 @@
-load("@pip_parsed_deps//:requirements.bzl", "entry_point", "requirement")
+load(
+    "@pip_parsed_deps//:requirements.bzl",
+    "data_requirement",
+    "dist_info_requirement",
+    "entry_point",
+    "requirement",
+)
 load("@rules_python//python:defs.bzl", "py_binary", "py_test")
 load("@rules_python//python:pip.bzl", "compile_pip_requirements")
 
@@ -54,12 +60,6 @@
     ),
 )
 
-py_test(
-    name = "entry_point_test",
-    srcs = ["entry_point_test.py"],
-    data = [":yamllint"],
-)
-
 # This rule adds a convenient way to update the requiremenst file.
 compile_pip_requirements(
     name = "requirements",
@@ -67,3 +67,19 @@
     requirements_in = "requirements.txt",
     requirements_txt = "requirements_lock.txt",
 )
+
+# Test the use of all pip_parse utilities in a single py_test
+py_test(
+    name = "pip_parse_test",
+    srcs = ["pip_parse_test.py"],
+    data = [
+        ":yamllint",
+        data_requirement("s3cmd"),
+        dist_info_requirement("requests"),
+    ],
+    env = {
+        "WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")),
+        "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("requests")),
+        "WHEEL_ENTRY_POINT": "$(rootpath :yamllint)",
+    },
+)
diff --git a/examples/pip_parse/entry_point_test.py b/examples/pip_parse/entry_point_test.py
deleted file mode 100644
index 7d22343..0000000
--- a/examples/pip_parse/entry_point_test.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python3
-
-from pathlib import Path
-import subprocess
-import unittest
-
-
-class PipParseEntryPointTest(unittest.TestCase):
-    def test_output(self):
-        self.maxDiff = None
-
-        entry_point = Path("external/pip_parsed_deps_pypi__yamllint/rules_python_wheel_entry_point_yamllint")
-        self.assertTrue(entry_point.exists())
-
-        proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
-
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/examples/pip_parse/pip_parse_test.py b/examples/pip_parse/pip_parse_test.py
new file mode 100644
index 0000000..0a686b5
--- /dev/null
+++ b/examples/pip_parse/pip_parse_test.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+
+from pathlib import Path
+import os
+import subprocess
+import unittest
+
+
+class PipInstallTest(unittest.TestCase):
+    maxDiff = None
+
+    def test_entry_point(self):
+        env = os.environ.get("WHEEL_ENTRY_POINT")
+        self.assertIsNotNone(env)
+
+        entry_point = Path(env)
+        self.assertTrue(entry_point.exists())
+
+        proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
+
+    def test_data(self):
+        env = os.environ.get("WHEEL_DATA_CONTENTS")
+        self.assertIsNotNone(env)
+        self.assertListEqual(
+            env.split(" "),
+            [
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/INSTALL.md",
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/LICENSE",
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/NEWS",
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/data/share/doc/packages/s3cmd/README.md",
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/data/share/man/man1/s3cmd.1",
+                "external/pip_parsed_deps_pypi__s3cmd/s3cmd-2.1.0.data/scripts/s3cmd",
+            ],
+        )
+
+    def test_dist_info(self):
+        env = os.environ.get("WHEEL_DIST_INFO_CONTENTS")
+        self.assertIsNotNone(env)
+        self.assertListEqual(
+            env.split(" "),
+            [
+                "external/pip_parsed_deps_pypi__requests/requests-2.25.1.dist-info/LICENSE",
+                "external/pip_parsed_deps_pypi__requests/requests-2.25.1.dist-info/METADATA",
+                "external/pip_parsed_deps_pypi__requests/requests-2.25.1.dist-info/RECORD",
+                "external/pip_parsed_deps_pypi__requests/requests-2.25.1.dist-info/WHEEL",
+                "external/pip_parsed_deps_pypi__requests/requests-2.25.1.dist-info/top_level.txt",
+            ],
+        )
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/examples/pip_parse/requirements.txt b/examples/pip_parse/requirements.txt
index 019562a..1e3ceda 100644
--- a/examples/pip_parse/requirements.txt
+++ b/examples/pip_parse/requirements.txt
@@ -1,2 +1,3 @@
 requests==2.25.1
 yamllint==1.26.3
+s3cmd==2.1.0 
diff --git a/examples/pip_parse/requirements_lock.txt b/examples/pip_parse/requirements_lock.txt
index dd29e95..568dc13 100644
--- a/examples/pip_parse/requirements_lock.txt
+++ b/examples/pip_parse/requirements_lock.txt
@@ -20,6 +20,14 @@
     --hash=sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a \
     --hash=sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1
     # via yamllint
+python-dateutil==2.8.2 \
+    --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
+    --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
+    # via s3cmd
+python-magic==0.4.24 \
+    --hash=sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626 \
+    --hash=sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf
+    # via s3cmd
 pyyaml==5.4.1 \
     --hash=sha256:08682f6b72c722394747bddaf0aa62277e02557c0fd1c42cb853016a38f8dedf \
     --hash=sha256:0f5f5786c0e09baddcd8b4b45f20a7b5d61a7e7e99846e3c799b05c7c53fa696 \
@@ -55,6 +63,14 @@
     --hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
     --hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
     # via -r requirements.txt
+s3cmd==2.1.0 \
+    --hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
+    --hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
+    # via -r requirements.txt
+six==1.16.0 \
+    --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
+    --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
+    # via python-dateutil
 urllib3==1.26.5 \
     --hash=sha256:753a0374df26658f99d826cfe40394a686d05985786d946fbe4165b5148f5a7c \
     --hash=sha256:a7acd0977125325f516bda9735fa7142b909a8d01e8b2e4c8108d0984e6e0098