From 7bcad5e26dfea49a37ffed718a9ce27107228e86 Mon Sep 17 00:00:00 2001
From: Dan Jones <dan.jones@noc.ac.uk>
Date: Fri, 20 Jan 2023 15:35:52 +0000
Subject: [PATCH] feat: add post install setup for python

---
 README.md     | 31 +++++++++++++++++++++++++++++--
 copy_tests.py | 25 +++++++++++++++++++++++++
 setup.cfg     |  3 +++
 setup.py      |  2 +-
 4 files changed, 58 insertions(+), 3 deletions(-)
 create mode 100644 copy_tests.py
 create mode 100644 setup.cfg

diff --git a/README.md b/README.md
index 88d1c4e..ddb70bc 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,36 @@ should be run against all language ports of the adapter
 
 A set of fixtures to be used to configure the tests.
 
-### Implementations 
+## Implementations 
 
 You can see existing implementations of the test suite here 
 
 - [JS-Cucumber](https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-javascript) 
-Step definitions are in `test/cucumber`
\ No newline at end of file
+Step definitions are in `test/cucumber`
+
+## Installing
+
+The intention is to install a tagged version of the testsuite into each adapter so that if we develop 
+the testsuite existing adapter implementations won't break. 
+
+### NPM 
+
+```bash
+npm install --saveDev git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-testsuite.git#[tag|branch|commit]
+```
+
+### Yarn 
+
+```bash
+yarn add --dev git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-testsuite.git#[tag|branch|commit]
+```
+
+### PIP 
+
+```bash
+echo
+"git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-testsuite.git@[tag|branch|commit]#egg=backbone-adapter-testsuite" >> requirements.txt 
+pip install -r reqiurements.txt
+# copy features and fixtures into test directory
+copy_tests
+```
diff --git a/copy_tests.py b/copy_tests.py
new file mode 100644
index 0000000..631c831
--- /dev/null
+++ b/copy_tests.py
@@ -0,0 +1,25 @@
+import os
+from shutil import copytree
+import site 
+
+
+def copy_directory(src, dest, directory):
+    copytree(os.path.join(src, directory), os.path.join(dest, directory))
+
+
+def copy(): 
+    here = os.getcwd();
+    package_locations = site.getsitepackages()
+
+    for root_path in package_locations:
+        dirs = [x[0] for x in os.walk(root_path)]
+        for dirx in dirs: 
+            if dirx.endswith('testsuite'):
+                src = dirx
+                dest = os.path.join(here, 'test')
+                copy_directory(src, dest, 'features')
+                copy_directory(src, dest, 'fixtures') 
+
+
+if __name__ == '__main__':
+    copy()
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..a8aeb66
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,3 @@
+[options.entry_points]
+console_scripts=
+    copy_tests = testsuite.copy_tests:copy
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 6e8bc2e..b025934 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
 
 
 setup(
-    name='backbone-adapter-testsuite',
+    name='backbone_adapter_testsuite',
     packages=['testsuite'],
     package_dir={
         'testsuite': '.',
-- 
GitLab