From a0b277a9c909d143cbadcf18384c02392de6aee3 Mon Sep 17 00:00:00 2001
From: Nick Coghlan <ncoghlan@gmail.com>
Date: Sep 25 2017 07:11:02 +0000
Subject: Issue #50: Automate test environment setup


- uses pipenv for test environment management
- enables system site-packages for RPM-only deps

---

diff --git a/Pipfile b/Pipfile
new file mode 100644
index 0000000..f28ad76
--- /dev/null
+++ b/Pipfile
@@ -0,0 +1,10 @@
+[[source]]
+url = "https://pypi.python.org/simple"
+verify_ssl = true
+
+[dev-packages]
+pytest = "*"
+six = "*"
+
+[packages]
+"fedmod" = {editable = true, path = "."}
\ No newline at end of file
diff --git a/Pipfile.lock b/Pipfile.lock
new file mode 100644
index 0000000..aecbada
--- /dev/null
+++ b/Pipfile.lock
@@ -0,0 +1,163 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "a6176d82ed4cb9cea75035faf0b129a2b280fa41f9dfcf4fa8a4eb7c5cf8730c"
+        },
+        "host-environment-markers": {
+            "implementation_name": "cpython",
+            "implementation_version": "3.6.2",
+            "os_name": "posix",
+            "platform_machine": "x86_64",
+            "platform_python_implementation": "CPython",
+            "platform_release": "4.12.13-300.fc26.x86_64",
+            "platform_system": "Linux",
+            "platform_version": "#1 SMP Thu Sep 14 16:00:38 UTC 2017",
+            "python_full_version": "3.6.2",
+            "python_version": "3.6",
+            "sys_platform": "linux"
+        },
+        "pipfile-spec": 6,
+        "requires": {},
+        "sources": [
+            {
+                "url": "https://pypi.python.org/simple",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {
+        "beanbag": {
+            "hashes": [
+                "sha256:c6aa1e90ad229a6352e4e5f2d468b9cbf3522d74f7a6ac963e88cba769aaf780"
+            ],
+            "version": "==1.9.2"
+        },
+        "certifi": {
+            "hashes": [
+                "sha256:54a07c09c586b0e4c619f02a5e94e36619da8e2b053e20f594348c0611803704",
+                "sha256:40523d2efb60523e113b44602298f0960e900388cf3bb6043f645cf57ea9e3f5"
+            ],
+            "version": "==2017.7.27.1"
+        },
+        "chardet": {
+            "hashes": [
+                "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691",
+                "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"
+            ],
+            "version": "==3.0.4"
+        },
+        "dockerfile-parse": {
+            "hashes": [
+                "sha256:6a739e5a69443383aab2dcdd5b1d55e99735a6345f9175c56f8becfed188cc7f",
+                "sha256:50a38c49f0f0c4d6fcb911fdaa2f22c064ab8c6365093a9f470e78be6e393423"
+            ],
+            "version": "==0.0.7"
+        },
+        "fedmod": {
+            "editable": true,
+            "path": "."
+        },
+        "idna": {
+            "hashes": [
+                "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4",
+                "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f"
+            ],
+            "version": "==2.6"
+        },
+        "modulemd": {
+            "hashes": [
+                "sha256:a305510e11087c939bd3b00a5ef2aa4d07fd101808e5fedbb33a7720376db041"
+            ],
+            "version": "==1.3.1"
+        },
+        "pdc-client": {
+            "hashes": [
+                "sha256:af3d6e520858fd54c0f3e74c136462f75f3ad2f5938dbb0605a813e91bdfeb64"
+            ],
+            "version": "==1.7.0"
+        },
+        "pykerberos": {
+            "hashes": [
+                "sha256:60f84e1b606d58cc457b186914c195072ebebf5d5a05e75c0136541808e06523"
+            ],
+            "version": "==1.1.14"
+        },
+        "python-dateutil": {
+            "hashes": [
+                "sha256:95511bae634d69bc7329ba55e646499a842bc4ec342ad54a8cdb65645a0aad3c",
+                "sha256:891c38b2a02f5bb1be3e4793866c8df49c7d19baabf9c1bad62547e0b4866aca"
+            ],
+            "version": "==2.6.1"
+        },
+        "pyyaml": {
+            "hashes": [
+                "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
+                "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
+                "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269",
+                "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
+                "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
+                "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
+                "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
+                "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",
+                "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",
+                "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",
+                "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",
+                "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",
+                "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",
+                "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7"
+            ],
+            "version": "==3.12"
+        },
+        "requests": {
+            "hashes": [
+                "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b",
+                "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"
+            ],
+            "version": "==2.18.4"
+        },
+        "requests-kerberos": {
+            "hashes": [
+                "sha256:6c1dc3c7c0774ac104487112fc564525a838aa507982b7c4785e41e5cb6893c9",
+                "sha256:ae734f71f46a7b205a74fb90e160c7ba4cc4e0dff2d4f3129cf74806b51b94ba"
+            ],
+            "version": "==0.11.0"
+        },
+        "six": {
+            "hashes": [
+                "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",
+                "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
+            ],
+            "version": "==1.11.0"
+        },
+        "urllib3": {
+            "hashes": [
+                "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",
+                "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"
+            ],
+            "version": "==1.22"
+        }
+    },
+    "develop": {
+        "py": {
+            "hashes": [
+                "sha256:2ccb79b01769d99115aa600d7eed99f524bf752bba8f041dc1c184853514655a",
+                "sha256:0f2d585d22050e90c7d293b6451c83db097df77871974d90efd5a30dc12fcde3"
+            ],
+            "version": "==1.4.34"
+        },
+        "pytest": {
+            "hashes": [
+                "sha256:b84f554f8ddc23add65c411bf112b2d88e2489fd45f753b1cae5936358bdf314",
+                "sha256:f46e49e0340a532764991c498244a60e3a37d7424a532b3ff1a6a7653f1a403a"
+            ],
+            "version": "==3.2.2"
+        },
+        "six": {
+            "hashes": [
+                "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",
+                "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
+            ],
+            "version": "==1.11.0"
+        }
+    }
+}
diff --git a/README.md b/README.md
index 1e04f70..6907e90 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,61 @@
 # Modularity-tools
 
-## Requirements
-Following packages are required:
- * python2-pytest
+## Local development
+
+### Runtime dependencies
+
+The currently preferred means of installation is local installation with pip.
+
+    $ pip install .
+
+This will pull in the required Python level dependencies from PyPI.
+
+Some tests aren't currently available from PyPI, and will need to be installed
+system-wide (exact list TBD).
+
+Note that the CLI name, the distribution package name, and the import package
+name are all currently still subject to revision: https://pagure.io/modularity/modularity-tools/issue/49
+
+### How to run tests
+
+To start a shell that's correctly configured to run the tests with the library
+and all necessary dependencies installed:
+
+    $ pipenv --three --site-packages
+    $ pipenv install --dev
+    $ pipenv shell
+
+The tests can then be run in the launched subshell with:
+
+    $ pytest tests
+
+Note: the tests will currently fail. Fixing that is a work in progress :)
+
+### Reviewing dependencies
+
+To see the Python level dependencies graph:
+
+    $ pew toggleglobalsitepackages
+    $ pipenv graph
+
+(If you don't turn off global site-packages access first, you'll get the
+dependency graph of all the system Python components as well)
+
 
 ## modtools docker2openshift
 
 The tool is used for generation OpenShift template from Dockerfile and from [https://github.com/container-images/container-image-template/blob/master/openshift-template.yml](openshift-template.yml) already prepared by Modularity team.
 As Dockerfile as openshift-template.yml have to exist in the directory.
- 
+
 ### How to use modtools docker2openshift
 Run the command with following parameters:
- 
+
  `./modtools docker2openshift --dockerfile <full_path_to_Dockerfile> IMAGENAME`
- 
+
  where parameters mean:
  * dockerfile ... means full path to Dockerfile
  * IMAGENAME ... means image name in register. Can be taken from command `docker images` or from some other registry.
- 
+
 The output of **modtools docker2openshift** command is OpenShift template stored in temporary directory
 
 Example usage:
@@ -43,12 +81,6 @@ Run the command with following parameters:
  * modulemd.yaml - path to the modulemd file
 
 
-## How to run tests
-
-In order to run tests, run command:
-
-`py.test-2.7 tests/`
-
 ## Modulemd creation
 
 modtools rpm2module script creates modulemd file from package names. Output is written in modulemd-output.yaml
diff --git a/setup.py b/setup.py
index 83a1353..d232ee2 100644
--- a/setup.py
+++ b/setup.py
@@ -23,5 +23,10 @@ setup(
             'modtools=modularity.cli.ModtoolsCliHelper.run'
         ]
     },
+    install_requires=[
+        'modulemd',
+        'pdc-client',
+        'dockerfile-parse',
+    ],
     packages=find_packages(),
 )
diff --git a/tests/test_module_generator.py b/tests/test_module_generator.py
index 7c1056c..49662bf 100644
--- a/tests/test_module_generator.py
+++ b/tests/test_module_generator.py
@@ -1,6 +1,6 @@
 import pytest
 import os.path
-from contrib.modtools import ModtoolsCLI
+from modularity.cli import ModtoolsCLI
 from modularity.module_generator import ModuleGenerator
 
 
diff --git a/tests/test_oc_template.py b/tests/test_oc_template.py
index e5b7d70..6391d6b 100644
--- a/tests/test_oc_template.py
+++ b/tests/test_oc_template.py
@@ -8,7 +8,7 @@ import os
 import six
 import urllib
 
-from contrib.modtools import ModtoolsCLI
+from modularity.cli import ModtoolsCLI
 from modularity.oc_template import OpenShiftTemplateGenerator
 from modularity.oc_template import VOLUME, ENV, EXPOSE, LABEL
 

