diff options
author | Michael Hwang <mhwang@research.att.com> | 2017-09-21 12:19:32 -0400 |
---|---|---|
committer | Michael Hwang <mhwang@research.att.com> | 2017-09-21 17:04:39 -0400 |
commit | e11be5dc15e6800ed6111b7773b9e44571343207 (patch) | |
tree | ab5b973d7239b8942ab27c3ee04455533d6a4f23 /python-discovery-client | |
parent | 2200894f54019231bfe1a62845dda03e9bb87bd1 (diff) |
Fix tox to give more accurate coverage reports
* Also attempted to get sonar working
* Fixed minor things along the way
Change-Id: I434c0d791140e75cd5997be0cc3fefce7ccc292f
Issue-Id: DCAEGEN2-60
Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'python-discovery-client')
-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 |
5 files changed, 31 insertions, 19 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 |