Merge ~hloeung/ntp-charm:master into ntp-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 603452e172b89858355edb5719a59acf9e222a3b
Merged at revision: 43f8719cc2f8a8500c00c2d517a45bb019771cf8
Proposed branch: ~hloeung/ntp-charm:master
Merge into: ntp-charm:master
Diff against target: 205 lines (+82/-19)
8 files modified
.gitignore (+8/-1)
Makefile (+14/-4)
pytest.ini (+10/-0)
requirements.txt (+1/-0)
tox.ini (+29/-0)
unit_tests/requirements.txt (+6/-0)
unit_tests/test_ntp_scoring.py (+1/-1)
unit_tests/test_ntp_source_score.py (+13/-13)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+370890@code.launchpad.net

Commit message

Use tox for lint and unit test

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Stuart Bishop (stub) wrote :

Yup

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 43f8719cc2f8a8500c00c2d517a45bb019771cf8

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
index bee8a64..cdd3989 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,8 @@
1__pycache__1*.pyc
2*.swp
3*~
4.coverage
5.tox/
6.unit-state.db
7__pycache__/
8
diff --git a/Makefile b/Makefile
index 3f560da..67cab7d 100644
--- a/Makefile
+++ b/Makefile
@@ -6,11 +6,21 @@ CHARM_NAME := ntp
6CS_CHANNEL := candidate6CS_CHANNEL := candidate
7CSDEST := cs:~$(TEAM)/$(CHARM_NAME)7CSDEST := cs:~$(TEAM)/$(CHARM_NAME)
88
9test:9clean:
10 $(PYTHON) -m unittest unit_tests/test_*.py10 @echo "Cleaning files"
11 @rm -rf ./.tox
12 @rm -rf ./.pytest_cache
13 @rm -rf ./unit_tests/__pycache__ ./reactive/__pycache__ ./lib/__pycache__ ./actions/__pycache__
14 @rm -rf ./.coverage ./.unit-state.db
1115
12lint: test16test: unittest
13 @python3 -m flake8 --max-line-length=120 actions lib reactive17
18unittest:
19 @tox -e unit
20
21lint:
22 @echo "Running flake8"
23 @tox -e lint
1424
15build: lint25build: lint
16 charm build26 charm build
diff --git a/pytest.ini b/pytest.ini
17new file mode 10064427new file mode 100644
index 0000000..4b4e9c5
--- /dev/null
+++ b/pytest.ini
@@ -0,0 +1,10 @@
1[pytest]
2filterwarnings =
3 # https://github.com/juju/charm-helpers/issues/294
4 ignore:.*inspect.getargspec\(\) is deprecated.*:DeprecationWarning
5 # https://github.com/juju/charm-helpers/issues/293
6 ignore:.*dist\(\) and linux_distribution\(\) functions are deprecated:PendingDeprecationWarning
7 ignore:.*dist\(\) and linux_distribution\(\) functions are deprecated:DeprecationWarning
8
9 # distutils
10 ignore:the imp module is deprecated in favour of importlib:DeprecationWarning
diff --git a/requirements.txt b/requirements.txt
0new file mode 10064411new file mode 100644
index 0000000..8462291
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
1# Include python requirements here
diff --git a/tox.ini b/tox.ini
0new file mode 1006442new file mode 100644
index 0000000..337da3d
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,29 @@
1[tox]
2skipsdist=True
3envlist = unit
4skip_missing_interpreters = True
5
6[testenv]
7basepython = python3
8setenv =
9 PYTHONPATH = .
10
11[testenv:unit]
12commands = pytest -v --ignore {toxinidir}/tests --cov=lib --cov=reactive --cov=actions --cov-report=term-missing --cov-branch
13deps = -r{toxinidir}/unit_tests/requirements.txt
14 -r{toxinidir}/requirements.txt
15setenv =
16 PYTHONPATH={toxinidir}/lib
17 TZ=UTC
18
19[testenv:lint]
20commands = flake8
21deps = flake8
22
23[flake8]
24exclude =
25 .git,
26 __pycache__,
27 .tox,
28max-line-length = 120
29max-complexity = 11
diff --git a/unit_tests/requirements.txt b/unit_tests/requirements.txt
0new file mode 10064430new file mode 100644
index 0000000..79c71e5
--- /dev/null
+++ b/unit_tests/requirements.txt
@@ -0,0 +1,6 @@
1charmhelpers
2charms.reactive
3mock
4psutil
5pytest
6pytest-cov
diff --git a/unit_tests/test_ntp_scoring.py b/unit_tests/test_ntp_scoring.py
index dd704d3..39837b7 100644
--- a/unit_tests/test_ntp_scoring.py
+++ b/unit_tests/test_ntp_scoring.py
@@ -6,7 +6,7 @@ import sys
6import unittest6import unittest
77
8sys.path.append('lib')8sys.path.append('lib')
9import ntp_scoring9import ntp_scoring # NOQA: E402
1010
1111
12class TestNtpScoring(unittest.TestCase):12class TestNtpScoring(unittest.TestCase):
diff --git a/unit_tests/test_ntp_source_score.py b/unit_tests/test_ntp_source_score.py
index 9804955..f38280a 100644
--- a/unit_tests/test_ntp_source_score.py
+++ b/unit_tests/test_ntp_source_score.py
@@ -11,15 +11,15 @@ from ntp_source_score import (
11 get_source_delays,11 get_source_delays,
12 rms,12 rms,
13 run_cmd,13 run_cmd,
14)14) # NOQA: E402
1515
16ntpdate_output = """16ntpdate_output = """
17...17...
18reference time: dda179ee.3ec34fdd Mon, Oct 30 2017 20:14:06.24518reference time: dda179ee.3ec34fdd Mon, Oct 30 2017 20:14:06.245
19originate timestamp: dda17a5b.af7c528b Mon, Oct 30 2017 20:15:55.68519originate timestamp: dda17a5b.af7c528b Mon, Oct 30 2017 20:15:55.685
20transmit timestamp: dda17a5b.80b4dc04 Mon, Oct 30 2017 20:15:55.50220transmit timestamp: dda17a5b.80b4dc04 Mon, Oct 30 2017 20:15:55.502
21filter delay: 0.54126 0.36757 0.36655 0.36743 21filter delay: 0.54126 0.36757 0.36655 0.36743
22 0.00000 0.00000 0.00000 0.00000 22 0.00000 0.00000 0.00000 0.00000
23filter offset: 0.099523 0.012978 0.011831 0.01177023filter offset: 0.099523 0.012978 0.011831 0.011770
24 0.000000 0.000000 0.000000 0.00000024 0.000000 0.000000 0.000000 0.000000
25delay 0.36655, dispersion 0.0112625delay 0.36655, dispersion 0.01126
@@ -28,8 +28,8 @@ offset 0.011831
28reference time: dda17695.69e65b2f Mon, Oct 30 2017 19:59:49.41328reference time: dda17695.69e65b2f Mon, Oct 30 2017 19:59:49.413
29originate timestamp: dda17a5b.afcec2dd Mon, Oct 30 2017 20:15:55.68629originate timestamp: dda17a5b.afcec2dd Mon, Oct 30 2017 20:15:55.686
30transmit timestamp: dda17a5b.80bb2488 Mon, Oct 30 2017 20:15:55.50230transmit timestamp: dda17a5b.80bb2488 Mon, Oct 30 2017 20:15:55.502
31filter delay: 0.36520 0.36487 0.36647 0.36604 31filter delay: 0.36520 0.36487 0.36647 0.36604
32 0.00000 0.00000 0.00000 0.00000 32 0.00000 0.00000 0.00000 0.00000
33filter offset: 0.012833 0.013758 0.013731 0.01362933filter offset: 0.012833 0.013758 0.013731 0.013629
34 0.000000 0.000000 0.000000 0.00000034 0.000000 0.000000 0.000000 0.000000
35delay 0.36487, dispersion 0.0004935delay 0.36487, dispersion 0.00049
@@ -38,8 +38,8 @@ offset 0.013758
38reference time: dda1782c.6aec9646 Mon, Oct 30 2017 20:06:36.41738reference time: dda1782c.6aec9646 Mon, Oct 30 2017 20:06:36.417
39originate timestamp: dda17a5b.d2d04ef4 Mon, Oct 30 2017 20:15:55.82339originate timestamp: dda17a5b.d2d04ef4 Mon, Oct 30 2017 20:15:55.823
40transmit timestamp: dda17a5b.b37c4098 Mon, Oct 30 2017 20:15:55.70140transmit timestamp: dda17a5b.b37c4098 Mon, Oct 30 2017 20:15:55.701
41filter delay: 0.28581 0.28406 0.28551 0.28596 41filter delay: 0.28581 0.28406 0.28551 0.28596
42 0.00000 0.00000 0.00000 0.00000 42 0.00000 0.00000 0.00000 0.00000
43filter offset: -0.00802 -0.00854 -0.00791 -0.0078743filter offset: -0.00802 -0.00854 -0.00791 -0.00787
44 0.000000 0.000000 0.000000 0.00000044 0.000000 0.000000 0.000000 0.000000
45delay 0.28406, dispersion 0.0005045delay 0.28406, dispersion 0.00050
@@ -48,8 +48,8 @@ offset -0.008544
48reference time: dda17735.4a03e3ca Mon, Oct 30 2017 20:02:29.28948reference time: dda17735.4a03e3ca Mon, Oct 30 2017 20:02:29.289
49originate timestamp: dda17a5c.1634d231 Mon, Oct 30 2017 20:15:56.08649originate timestamp: dda17a5c.1634d231 Mon, Oct 30 2017 20:15:56.086
50transmit timestamp: dda17a5b.e6934fad Mon, Oct 30 2017 20:15:55.90050transmit timestamp: dda17a5b.e6934fad Mon, Oct 30 2017 20:15:55.900
51filter delay: 0.37044 0.37077 0.37050 0.37086 51filter delay: 0.37044 0.37077 0.37050 0.37086
52 0.00000 0.00000 0.00000 0.00000 52 0.00000 0.00000 0.00000 0.00000
53filter offset: 0.013993 0.013624 0.013425 0.01336253filter offset: 0.013993 0.013624 0.013425 0.013362
54 0.000000 0.000000 0.000000 0.00000054 0.000000 0.000000 0.000000 0.000000
55delay 0.37044, dispersion 0.0004655delay 0.37044, dispersion 0.00046
@@ -58,8 +58,8 @@ offset 0.013993
58reference time: dda17695.69e65b2f Mon, Oct 30 2017 19:59:49.41358reference time: dda17695.69e65b2f Mon, Oct 30 2017 19:59:49.413
59originate timestamp: dda17a5c.4944bb52 Mon, Oct 30 2017 20:15:56.28659originate timestamp: dda17a5c.4944bb52 Mon, Oct 30 2017 20:15:56.286
60transmit timestamp: dda17a5c.19cf5199 Mon, Oct 30 2017 20:15:56.10060transmit timestamp: dda17a5c.19cf5199 Mon, Oct 30 2017 20:15:56.100
61filter delay: 0.36873 0.36823 0.36911 0.36781 61filter delay: 0.36873 0.36823 0.36911 0.36781
62 0.00000 0.00000 0.00000 0.00000 62 0.00000 0.00000 0.00000 0.00000
63filter offset: 0.014635 0.014599 0.014166 0.01423963filter offset: 0.014635 0.014599 0.014166 0.014239
64 0.000000 0.000000 0.000000 0.00000064 0.000000 0.000000 0.000000 0.000000
65delay 0.36781, dispersion 0.0002665delay 0.36781, dispersion 0.00026
@@ -68,8 +68,8 @@ offset 0.014239
68reference time: dda179ee.3ec34fdd Mon, Oct 30 2017 20:14:06.24568reference time: dda179ee.3ec34fdd Mon, Oct 30 2017 20:14:06.245
69originate timestamp: dda17a5c.7bbd3828 Mon, Oct 30 2017 20:15:56.48369originate timestamp: dda17a5c.7bbd3828 Mon, Oct 30 2017 20:15:56.483
70transmit timestamp: dda17a5c.4cf92e99 Mon, Oct 30 2017 20:15:56.30070transmit timestamp: dda17a5c.4cf92e99 Mon, Oct 30 2017 20:15:56.300
71filter delay: 0.36554 0.36617 0.36673 0.36618 71filter delay: 0.36554 0.36617 0.36673 0.36618
72 0.00000 0.00000 0.00000 0.00000 72 0.00000 0.00000 0.00000 0.00000
73filter offset: 0.012466 0.012691 0.012863 0.01234673filter offset: 0.012466 0.012691 0.012863 0.012346
74 0.000000 0.000000 0.000000 0.00000074 0.000000 0.000000 0.000000 0.000000
75delay 0.36554, dispersion 0.0001875delay 0.36554, dispersion 0.00018

Subscribers

People subscribed via source and target branches