summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift
diff options
context:
space:
mode:
authorJason DeTiberus <detiber@gmail.com>2017-01-18 16:33:16 -0500
committerGitHub <noreply@github.com>2017-01-18 16:33:16 -0500
commitf185fa6ce66a25b8f44c81aa963e0c27e2742586 (patch)
tree09ea4643ef8e295e327b0d5509685d7678224a3d /roles/lib_openshift
parente23e9bf557c883d294462e76bdd9399520b01ebc (diff)
parentb6576d28ec21411f8da58cedab7a6c6c57dc172b (diff)
downloadopenshift-f185fa6ce66a25b8f44c81aa963e0c27e2742586.tar.gz
openshift-f185fa6ce66a25b8f44c81aa963e0c27e2742586.tar.bz2
openshift-f185fa6ce66a25b8f44c81aa963e0c27e2742586.tar.xz
openshift-f185fa6ce66a25b8f44c81aa963e0c27e2742586.zip
Merge pull request #3107 from kwoodson/generate_tox_test
Adding tox tests for generated module code.
Diffstat (limited to 'roles/lib_openshift')
-rwxr-xr-xroles/lib_openshift/src/generate.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/roles/lib_openshift/src/generate.py b/roles/lib_openshift/src/generate.py
index 8451d99ab..6daade108 100755
--- a/roles/lib_openshift/src/generate.py
+++ b/roles/lib_openshift/src/generate.py
@@ -10,6 +10,7 @@ import six
OPENSHIFT_ANSIBLE_PATH = os.path.dirname(os.path.realpath(__file__))
OPENSHIFT_ANSIBLE_SOURCES_PATH = os.path.join(OPENSHIFT_ANSIBLE_PATH, 'sources.yml') # noqa: E501
+LIBRARY = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/')
class GenerateAnsibleException(Exception):
@@ -42,22 +43,29 @@ def generate(parts):
return data
-def main():
- ''' combine the necessary files to create the ansible module '''
- args = parse_args()
+def get_sources():
+ '''return the path to the generate sources'''
+ return yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- library = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/')
- sources = yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- for fname, parts in sources.items():
+def verify():
+ '''verify if the generated code matches the library code'''
+ for fname, parts in get_sources().items():
data = generate(parts)
- fname = os.path.join(library, fname)
- if args.verify:
- if not open(fname).read() == data.getvalue():
- raise GenerateAnsibleException('Generated content does not match for %s' % fname)
+ fname = os.path.join(LIBRARY, fname)
+ if not open(fname).read() == data.getvalue():
+ raise GenerateAnsibleException('Generated content does not match for %s' % fname)
+
- continue
+def main():
+ ''' combine the necessary files to create the ansible module '''
+ args = parse_args()
+ if args.verify:
+ verify()
+ for fname, parts in get_sources().items():
+ data = generate(parts)
+ fname = os.path.join(LIBRARY, fname)
with open(fname, 'w') as afd:
afd.seek(0)
afd.write(data.getvalue())