diff options
-rw-r--r-- | python-discovery-client/.coveragerc | 21 | ||||
-rw-r--r-- | python-discovery-client/discovery_client/discovery.py | 4 | ||||
-rw-r--r-- | python-discovery-client/pom.xml | 16 | ||||
-rw-r--r-- | python-discovery-client/tests/test_discovery.py | 6 | ||||
-rw-r--r-- | python-discovery-client/tox.ini | 3 | ||||
-rw-r--r-- | python-dockering/.coveragerc | 21 | ||||
-rw-r--r-- | python-dockering/dockering/core.py | 2 | ||||
-rw-r--r-- | python-dockering/pom.xml | 18 | ||||
-rw-r--r-- | python-dockering/tox.ini | 3 |
9 files changed, 60 insertions, 34 deletions
diff --git a/python-discovery-client/.coveragerc b/python-discovery-client/.coveragerc new file mode 100644 index 0000000..088c2da --- /dev/null +++ b/python-discovery-client/.coveragerc @@ -0,0 +1,21 @@ +# .coveragerc to control coverage.py +[run] +branch = True + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: diff --git a/python-discovery-client/discovery_client/discovery.py b/python-discovery-client/discovery_client/discovery.py index 180e933..51b5897 100644 --- a/python-discovery-client/discovery_client/discovery.py +++ b/python-discovery-client/discovery_client/discovery.py @@ -222,9 +222,7 @@ def _resolve_name(lookup_func, service_name): # TODO: Need a better way to identify CDAP apps. Really need to make this # better. - if "platform-" in service_name: - return "{0}:{1}".format(ip, port) - elif "cdap" in service_name: + if "cdap" in service_name: redirectish_url = "http://{0}:{1}/application/{2}".format(ip, port, service_name) diff --git a/python-discovery-client/pom.xml b/python-discovery-client/pom.xml index 39b5da5..d6a87f8 100644 --- a/python-discovery-client/pom.xml +++ b/python-discovery-client/pom.xml @@ -26,27 +26,21 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. <version>1.0.0-SNAPSHOT</version> </parent> <groupId>org.onap.dcaegen2.utils</groupId> - <artifactId>onap-dcae-discovery-client</artifactId> + <artifactId>python-discovery-client</artifactId> <name>dcaegen2-utils-python-discovery-client</name> <version>1.0.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <sonar.sources>.</sonar.sources> - <!-- customize the SONARQUBE URL --> - <!-- sonar.host.url>http://localhost:9000</sonar.host.url --> - <!-- below are language dependent --> - <!-- for Python --> + <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> + <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> <sonar.language>py</sonar.language> <sonar.pluginName>Python</sonar.pluginName> <sonar.inclusions>**/*.py</sonar.inclusions> - <!-- for JavaScaript --> - <!-- - <sonar.language>js</sonar.language> - <sonar.pluginName>JS</sonar.pluginName> - <sonar.inclusions>**/*.js</sonar.inclusions> - --> + <sonar.exclusions>tests/*</sonar.exclusions> </properties> <build> <finalName>${project.artifactId}-${project.version}</finalName> diff --git a/python-discovery-client/tests/test_discovery.py b/python-discovery-client/tests/test_discovery.py index 00f1b5e..36817af 100644 --- a/python-discovery-client/tests/test_discovery.py +++ b/python-discovery-client/tests/test_discovery.py @@ -17,7 +17,7 @@ # # ECOMP is a trademark and service mark of AT&T Intellectual Property. -import json, logging +import six, json, logging # http://stackoverflow.com/questions/9623114/check-if-two-unordered-lists-are-equal from collections import Counter from functools import partial @@ -65,8 +65,8 @@ def test_get_connection_types(): assert Counter(expected) == Counter(actual) # Force strings to be unicode, test for Python2 compatibility - config = { "x": "say something".decode("utf-8"), "y": 123, - "z": "{{some-analytics}}".decode("utf-8") } + config = { "x": six.u("say something"), "y": 123, + "z": six.u("{{some-analytics}}") } expected = [(("z", ), "some-analytics"), ] actual = dis._get_connection_types(config) assert Counter(expected) == Counter(actual) diff --git a/python-discovery-client/tox.ini b/python-discovery-client/tox.ini index 987b009..5b492c9 100644 --- a/python-discovery-client/tox.ini +++ b/python-discovery-client/tox.ini @@ -4,8 +4,7 @@ envlist = py27,py35 [testenv] deps= - -rrequirements.txt pytest coverage pytest-cov -commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir} --cov-report=xml +commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir}/discovery_client --cov-report=xml diff --git a/python-dockering/.coveragerc b/python-dockering/.coveragerc new file mode 100644 index 0000000..088c2da --- /dev/null +++ b/python-dockering/.coveragerc @@ -0,0 +1,21 @@ +# .coveragerc to control coverage.py +[run] +branch = True + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: diff --git a/python-dockering/dockering/core.py b/python-dockering/dockering/core.py index 9ef1ae3..d82e346 100644 --- a/python-dockering/dockering/core.py +++ b/python-dockering/dockering/core.py @@ -104,7 +104,7 @@ def start_container(client, container): # TODO: Have logic to inspect response and through NonRecoverableError # when start fails. Docker-py docs don't quickly tell me what the # response looks like. - response = client.start(container=container["Id"]) + client.start(container=container["Id"]) utils.logger.info("Container started: {0}".format(container["Id"])) # TODO: Maybe check stats? diff --git a/python-dockering/pom.xml b/python-dockering/pom.xml index afc39a8..0933bcb 100644 --- a/python-dockering/pom.xml +++ b/python-dockering/pom.xml @@ -26,27 +26,21 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. <version>1.0.0-SNAPSHOT</version> </parent> <groupId>org.onap.dcaegen2.utils</groupId> - <artifactId>onap-dcae-dockering</artifactId> + <artifactId>python-dockering</artifactId> <name>dcaegen2-utils-python-dockering</name> <version>1.0.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <sonar.skip>true</sonar.skip> - <!-- customize the SONARQUBE URL --> - <!-- sonar.host.url>http://localhost:9000</sonar.host.url --> - <!-- below are language dependent --> - <!-- for Python --> + + <sonar.sources>.</sonar.sources> + <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> + <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> <sonar.language>py</sonar.language> <sonar.pluginName>Python</sonar.pluginName> <sonar.inclusions>**/*.py</sonar.inclusions> - <!-- for JavaScaript --> - <!-- - <sonar.language>js</sonar.language> - <sonar.pluginName>JS</sonar.pluginName> - <sonar.inclusions>**/*.js</sonar.inclusions> - --> + <sonar.exclusions>tests/*</sonar.exclusions> </properties> <build> <finalName>${project.artifactId}-${project.version}</finalName> diff --git a/python-dockering/tox.ini b/python-dockering/tox.ini index 987b009..280cf78 100644 --- a/python-dockering/tox.ini +++ b/python-dockering/tox.ini @@ -4,8 +4,7 @@ envlist = py27,py35 [testenv] deps= - -rrequirements.txt pytest coverage pytest-cov -commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir} --cov-report=xml +commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir}/dockering --cov-report=xml |