Merge ~vultaire/charm-grafana:master into ~prometheus-charmers/charm-grafana:master

Proposed by Paul Goins
Status: Rejected
Rejected by: Alvaro Uria
Proposed branch: ~vultaire/charm-grafana:master
Merge into: ~prometheus-charmers/charm-grafana:master
Diff against target: 671 lines (+364/-75)
16 files modified
Makefile (+50/-0)
interfaces/.empty (+1/-0)
layers/.empty (+1/-0)
src/Makefile (+25/-0)
src/config.yaml (+61/-61)
src/lib/lib_grafana.py (+28/-0)
src/reactive/grafana.py (+1/-14)
src/requirements.txt (+1/-0)
src/tests/functional/requirements.txt (+6/-0)
src/tests/functional/test_deploy.py (+29/-0)
src/tests/unit/conftest.py (+69/-0)
src/tests/unit/example.cfg (+1/-0)
src/tests/unit/requirements.txt (+5/-0)
src/tests/unit/test_actions.py (+14/-0)
src/tests/unit/test_lib.py (+37/-0)
src/tox.ini (+35/-0)
Reviewer Review Type Date Requested Status
Prometheus Charmers Pending
Review via email: mp+362164@code.launchpad.net

Commit message

Migrate to using template from charm-create and add initial unit tests

Description of the change

With this, "make unittest" will work from within the src directory.

The topmost Makefile (generated via charm-create) does not seem to work
at present; I haven't looked into why. "cd" into "src" first.

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
Alvaro Uria (aluria) wrote :

Changes here have been merged into a bigger MP. See https://code.launchpad.net/~aluria/grafana-charm/+git/grafana-charm-1/+merge/364044

Changes here look good to be, but rejecting the MP due to the above.

Unmerged commits

0332bff... by Paul Goins

Added tests for the data_path() helper method

The data_path() method was refactored out into the lib_grafana module,
along with required constants. This removed dependencies on modules
provided by "charm build" and allows for doing a "make unittest" within
the src directory and having it "just work".

A few other small tweaks were added:

* I tweaked the tox.ini for unit testing so that it will ignore files
  in the builds directory, in case "charm build" is run.

* I disabled a test in the test_actions.py module as we haven't
  implemented any real tests there yet.

92fca06... by Paul Goins

Adding new files from charm-create template; ignoring files which already exist

7cf91c4... by Paul Goins

Moving files to match new charm template structure

e20740c... by Jason Hobbs

Update packagecloud repository key.

Reviewed-on: https://code.launchpad.net/~jason-hobbs/grafana-charm/+git/grafana-charm/+merge/361519
Reviewed-by: Xav Paice <email address hidden>

b15be8f... by Jason Hobbs

Update packagecloud repository key.

On January 7th, 2019, packagecloud changed to a new repository
signing key for the grafana stable repository. This change
updates this charm to use that key rather than the old one.

LP: #1810969

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/Makefile b/Makefile
0new file mode 1006440new file mode 100644
index 0000000..5bef873
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,50 @@
1ifndef JUJU_REPOSITORY
2 JUJU_REPOSITORY := $(shell pwd)
3 $(warning Warning JUJU_REPOSITORY was not set, defaulting to $(JUJU_REPOSITORY))
4endif
5
6help:
7 @echo "This project supports the following targets"
8 @echo ""
9 @echo " make help - show this text"
10 @echo " make submodules - make sure that the submodules are up-to-date"
11 @echo " make lint - run flake8"
12 @echo " make test - run the unittests and lint"
13 @echo " make unittest - run the tests defined in the unittest subdirectory"
14 @echo " make functional - run the tests defined in the functional subdirectory"
15 @echo " make release - build the charm"
16 @echo " make clean - remove unneeded files"
17 @echo ""
18
19submodules:
20 @echo "Cloning submodules"
21 @git submodule update --init --recursive
22
23lint:
24 @echo "Running flake8"
25 @cd src && tox -e lint
26
27test: unittest functional lint
28
29unittest:
30 @cd src && tox -e unit
31
32functional: build
33 @cd src && tox -e functional
34
35build:
36 @echo "Building charm to base directory $(JUJU_REPOSITORY)"
37 @-git describe --tags > ./src/repo-info
38 @LAYER_PATH=./layers INTERFACE_PATH=./interfaces\
39 JUJU_REPOSITORY=$(JUJU_REPOSITORY) charm build ./src --force
40
41release: clean build
42 @echo "Charm is built at $(JUJU_REPOSITORY)/builds"
43
44clean:
45 @echo "Cleaning files"
46 @if [ -d src/.tox ] ; then rm -r src/.tox ; fi
47 @if [ -d src/.pytest_cache ] ; then rm -r src/.pytest_cache ; fi
48
49# The targets below don't depend on a file
50.PHONY: lint test unittest functional build release clean help submodules
diff --git a/interfaces/.empty b/interfaces/.empty
0new file mode 10064451new file mode 100644
index 0000000..792d600
--- /dev/null
+++ b/interfaces/.empty
@@ -0,0 +1 @@
1#
diff --git a/layers/.empty b/layers/.empty
0new file mode 1006442new file mode 100644
index 0000000..792d600
--- /dev/null
+++ b/layers/.empty
@@ -0,0 +1 @@
1#
diff --git a/src/Makefile b/src/Makefile
0new file mode 1006442new file mode 100644
index 0000000..e1e1a8b
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,25 @@
1help:
2 @echo "This project supports the following targets"
3 @echo ""
4 @echo " make help - show this text"
5 @echo " make test - run the functional test and unittests"
6 @echo " make unittest - run the the unittest"
7 @echo " make functionaltest - run the functional tests"
8 @echo " make clean - remove unneeded files"
9 @echo ""
10
11test: unittest functionaltest lint
12
13unittest:
14 @tox -e unit
15
16functionaltest:
17 @tox -e functional
18
19clean:
20 @echo "Cleaning files"
21 @if [ -d ./.tox ] ; then rm -r ./.tox ; fi
22 @if [ -d ./.pytest_cache ] ; then rm -r ./.pytest_cache ; fi
23
24# The targets below don't depend on a file
25.PHONY: lint test unittest functionaltest clean help
diff --git a/README.md b/src/README.md
0similarity index 100%26similarity index 100%
1rename from README.md27rename from README.md
2rename to src/README.md28rename to src/README.md
diff --git a/actions.yaml b/src/actions.yaml
3similarity index 100%29similarity index 100%
4rename from actions.yaml30rename from actions.yaml
5rename to src/actions.yaml31rename to src/actions.yaml
diff --git a/actions/change-user-role b/src/actions/change-user-role
6similarity index 100%32similarity index 100%
7rename from actions/change-user-role33rename from actions/change-user-role
8rename to src/actions/change-user-role34rename to src/actions/change-user-role
diff --git a/actions/create-api-key b/src/actions/create-api-key
9similarity index 100%35similarity index 100%
10rename from actions/create-api-key36rename from actions/create-api-key
11rename to src/actions/create-api-key37rename to src/actions/create-api-key
diff --git a/actions/create-user b/src/actions/create-user
12similarity index 100%38similarity index 100%
13rename from actions/create-user39rename from actions/create-user
14rename to src/actions/create-user40rename to src/actions/create-user
diff --git a/actions/delete-user b/src/actions/delete-user
15similarity index 100%41similarity index 100%
16rename from actions/delete-user42rename from actions/delete-user
17rename to src/actions/delete-user43rename to src/actions/delete-user
diff --git a/actions/get-admin-password b/src/actions/get-admin-password
18similarity index 100%44similarity index 100%
19rename from actions/get-admin-password45rename from actions/get-admin-password
20rename to src/actions/get-admin-password46rename to src/actions/get-admin-password
diff --git a/actions/grafana_utils.py b/src/actions/grafana_utils.py
21similarity index 100%47similarity index 100%
22rename from actions/grafana_utils.py48rename from actions/grafana_utils.py
23rename to src/actions/grafana_utils.py49rename to src/actions/grafana_utils.py
diff --git a/actions/import-dashboard b/src/actions/import-dashboard
24similarity index 100%50similarity index 100%
25rename from actions/import-dashboard51rename from actions/import-dashboard
26rename to src/actions/import-dashboard52rename to src/actions/import-dashboard
diff --git a/actions/set-user-password b/src/actions/set-user-password
27similarity index 100%53similarity index 100%
28rename from actions/set-user-password54rename from actions/set-user-password
29rename to src/actions/set-user-password55rename to src/actions/set-user-password
diff --git a/config.yaml b/src/config.yaml
30similarity index 64%56similarity index 64%
31rename from config.yaml57rename from config.yaml
32rename to src/config.yaml58rename to src/config.yaml
index 3d58088..ee5cf85 100644
--- a/config.yaml
+++ b/src/config.yaml
@@ -13,68 +13,68 @@ options:
13 default: |13 default: |
14 - |14 - |
15 -----BEGIN PGP PUBLIC KEY BLOCK-----15 -----BEGIN PGP PUBLIC KEY BLOCK-----
16 Version: GnuPG v116 Version: GnuPG v1.4.11 (GNU/Linux)
1717
18 mQINBFLUbogBEADceEoxBDoE6QM5xV/13qiELbFIkQgy/eEi3UesXmJblFdU7wcD18 mQINBFu7jn8BEAC+f2xaHm8VnvpsoK2mD9dQAPDf9Pslvv0EH0Rhs6D54LpkF7hj
19 LOW3NuOIx/dgbZljeMEerj6N1cR7r7X5sVoFVEZiK4RLkC3Cpdns0d90ud2f3VyK19 VjeUH+cpNha7Gcr4vTubcVVAsq5m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USEVl0bMV4CtS+qP2il17D846bA=
77 =H60S77 =ewdt
78 -----END PGP PUBLIC KEY BLOCK-----78 -----END PGP PUBLIC KEY BLOCK-----
79 type: string79 type: string
80 description: |80 description: |
diff --git a/copyright b/src/copyright
81similarity index 100%81similarity index 100%
82rename from copyright82rename from copyright
83rename to src/copyright83rename to src/copyright
diff --git a/files/dashboards_backup b/src/files/dashboards_backup
84similarity index 100%84similarity index 100%
85rename from files/dashboards_backup85rename from files/dashboards_backup
86rename to src/files/dashboards_backup86rename to src/files/dashboards_backup
diff --git a/getstarted.md b/src/getstarted.md
87similarity index 100%87similarity index 100%
88rename from getstarted.md88rename from getstarted.md
89rename to src/getstarted.md89rename to src/getstarted.md
diff --git a/icon.svg b/src/icon.svg
90similarity index 100%90similarity index 100%
91rename from icon.svg91rename from icon.svg
92rename to src/icon.svg92rename to src/icon.svg
diff --git a/layer.yaml b/src/layer.yaml
93similarity index 100%93similarity index 100%
94rename from layer.yaml94rename from layer.yaml
95rename to src/layer.yaml95rename to src/layer.yaml
diff --git a/src/lib/lib_grafana.py b/src/lib/lib_grafana.py
96new file mode 10064496new file mode 100644
index 0000000..b074e53
--- /dev/null
+++ b/src/lib/lib_grafana.py
@@ -0,0 +1,28 @@
1from charmhelpers.core import hookenv, unitdata
2from charms.reactive import remove_state
3
4
5APT_COMMON = '/var/lib/grafana'
6SNAP_NAME = 'grafana'
7SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME)
8
9
10class GrafanaHelper():
11 def __init__(self):
12 self.charm_config = hookenv.config()
13
14 def action_function(self):
15 ''' An example function for calling from an action '''
16 return
17
18
19def data_path():
20 data_dir = {'snap': SNAP_COMMON,
21 'apt': APT_COMMON}
22 kv = unitdata.kv()
23 source = kv.get('install_method')
24 if source in ('snap', 'apt'):
25 return data_dir[source]
26 else:
27 hookenv.status_set('blocked', 'Unsupported install_method')
28 remove_state('grafana.installed')
diff --git a/metadata.yaml b/src/metadata.yaml
0similarity index 100%29similarity index 100%
1rename from metadata.yaml30rename from metadata.yaml
2rename to src/metadata.yaml31rename to src/metadata.yaml
diff --git a/reactive/grafana.py b/src/reactive/grafana.py
3similarity index 90%32similarity index 90%
4rename from reactive/grafana.py33rename from reactive/grafana.py
5rename to src/reactive/grafana.py34rename to src/reactive/grafana.py
index f98e11c..54f80c6 100644
--- a/reactive/grafana.py
+++ b/src/reactive/grafana.py
@@ -31,12 +31,11 @@ from charms.reactive import (
31)31)
3232
33from charms.layer import snap33from charms.layer import snap
34from lib_grafana import data_path, SNAP_NAME
3435
35SVCNAME = {'snap': 'snap.grafana.grafana',36SVCNAME = {'snap': 'snap.grafana.grafana',
36 'apt': 'grafana-server'}37 'apt': 'grafana-server'}
37SNAP_NAME = 'grafana'
38SNAP_DATA = '/var/snap/{}/current'.format(SNAP_NAME)38SNAP_DATA = '/var/snap/{}/current'.format(SNAP_NAME)
39SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME)
4039
41GRAFANA_INI = {'snap': '{}/conf/grafana.ini'.format(SNAP_DATA),40GRAFANA_INI = {'snap': '{}/conf/grafana.ini'.format(SNAP_DATA),
42 'apt': '/etc/grafana/grafana.ini'}41 'apt': '/etc/grafana/grafana.ini'}
@@ -126,18 +125,6 @@ def install_packages():
126 hookenv.status_set('blocked', 'Unsupported install_method')125 hookenv.status_set('blocked', 'Unsupported install_method')
127126
128127
129def data_path():
130 data_dir = {'snap': SNAP_COMMON,
131 'apt': '/var/lib/grafana'}
132 kv = unitdata.kv()
133 source = kv.get('install_method')
134 if source in ('snap', 'apt'):
135 return data_dir[source]
136 else:
137 hookenv.status_set('blocked', 'Unsupported install_method')
138 remove_state('grafana.installed')
139
140
141@when('grafana.installed')128@when('grafana.installed')
142@when('config.changed.install_plugins')129@when('config.changed.install_plugins')
143def install_plugins():130def install_plugins():
diff --git a/src/requirements.txt b/src/requirements.txt
144new file mode 100644131new file mode 100644
index 0000000..8462291
--- /dev/null
+++ b/src/requirements.txt
@@ -0,0 +1 @@
1# Include python requirements here
diff --git a/scripts/get_admin_password b/src/scripts/get_admin_password
0similarity index 100%2similarity index 100%
1rename from scripts/get_admin_password3rename from scripts/get_admin_password
2rename to src/scripts/get_admin_password4rename to src/scripts/get_admin_password
diff --git a/templates/dashboards/prometheus/CephCluster.json.j2 b/src/templates/dashboards/prometheus/CephCluster.json.j2
3similarity index 100%5similarity index 100%
4rename from templates/dashboards/prometheus/CephCluster.json.j26rename from templates/dashboards/prometheus/CephCluster.json.j2
5rename to src/templates/dashboards/prometheus/CephCluster.json.j27rename to src/templates/dashboards/prometheus/CephCluster.json.j2
diff --git a/templates/dashboards/prometheus/CephOSD.json.j2 b/src/templates/dashboards/prometheus/CephOSD.json.j2
6similarity index 100%8similarity index 100%
7rename from templates/dashboards/prometheus/CephOSD.json.j29rename from templates/dashboards/prometheus/CephOSD.json.j2
8rename to src/templates/dashboards/prometheus/CephOSD.json.j210rename to src/templates/dashboards/prometheus/CephOSD.json.j2
diff --git a/templates/dashboards/prometheus/CephPools.json.j2 b/src/templates/dashboards/prometheus/CephPools.json.j2
9similarity index 100%11similarity index 100%
10rename from templates/dashboards/prometheus/CephPools.json.j212rename from templates/dashboards/prometheus/CephPools.json.j2
11rename to src/templates/dashboards/prometheus/CephPools.json.j213rename to src/templates/dashboards/prometheus/CephPools.json.j2
diff --git a/templates/dashboards/prometheus/OpenStackCloud.json.j2 b/src/templates/dashboards/prometheus/OpenStackCloud.json.j2
12similarity index 100%14similarity index 100%
13rename from templates/dashboards/prometheus/OpenStackCloud.json.j215rename from templates/dashboards/prometheus/OpenStackCloud.json.j2
14rename to src/templates/dashboards/prometheus/OpenStackCloud.json.j216rename to src/templates/dashboards/prometheus/OpenStackCloud.json.j2
diff --git a/templates/dashboards/prometheus/RabbitMQ.json.j2 b/src/templates/dashboards/prometheus/RabbitMQ.json.j2
15similarity index 100%17similarity index 100%
16rename from templates/dashboards/prometheus/RabbitMQ.json.j218rename from templates/dashboards/prometheus/RabbitMQ.json.j2
17rename to src/templates/dashboards/prometheus/RabbitMQ.json.j219rename to src/templates/dashboards/prometheus/RabbitMQ.json.j2
diff --git a/templates/dashboards/prometheus/Swift.json.j2 b/src/templates/dashboards/prometheus/Swift.json.j2
18similarity index 100%20similarity index 100%
19rename from templates/dashboards/prometheus/Swift.json.j221rename from templates/dashboards/prometheus/Swift.json.j2
20rename to src/templates/dashboards/prometheus/Swift.json.j222rename to src/templates/dashboards/prometheus/Swift.json.j2
diff --git a/templates/dashboards/prometheus/Telegraf.json.j2 b/src/templates/dashboards/prometheus/Telegraf.json.j2
21similarity index 100%23similarity index 100%
22rename from templates/dashboards/prometheus/Telegraf.json.j224rename from templates/dashboards/prometheus/Telegraf.json.j2
23rename to src/templates/dashboards/prometheus/Telegraf.json.j225rename to src/templates/dashboards/prometheus/Telegraf.json.j2
diff --git a/templates/grafana.ini.j2 b/src/templates/grafana.ini.j2
24similarity index 100%26similarity index 100%
25rename from templates/grafana.ini.j227rename from templates/grafana.ini.j2
26rename to src/templates/grafana.ini.j228rename to src/templates/grafana.ini.j2
diff --git a/templates/juju-dashboards-backup.j2 b/src/templates/juju-dashboards-backup.j2
27similarity index 100%29similarity index 100%
28rename from templates/juju-dashboards-backup.j230rename from templates/juju-dashboards-backup.j2
29rename to src/templates/juju-dashboards-backup.j231rename to src/templates/juju-dashboards-backup.j2
diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt
30new file mode 10064432new file mode 100644
index 0000000..f76bfbb
--- /dev/null
+++ b/src/tests/functional/requirements.txt
@@ -0,0 +1,6 @@
1flake8
2juju
3mock
4pytest
5pytest-asyncio
6requests
diff --git a/src/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py
0new file mode 1006447new file mode 100644
index 0000000..c41422d
--- /dev/null
+++ b/src/tests/functional/test_deploy.py
@@ -0,0 +1,29 @@
1import pytest
2from juju.model import Model
3
4# Treat tests as coroutines
5pytestmark = pytest.mark.asyncio
6
7series = ['bionic']
8
9
10@pytest.fixture
11async def model():
12 model = Model()
13 await model.connect_current()
14 yield model
15 await model.disconnect()
16
17
18@pytest.mark.parametrize('series', series)
19async def test_grafana_deploy(model, series):
20 app = await model.deploy('.', series=series)
21 await model.block_until(lambda: app.status == 'active')
22 assert True
23
24
25# def test_example_action(self, deploy, unit):
26# uuid = unit.run_action('example-action')
27# action_output = deploy.get_action_output(uuid, full_output=True)
28# print(action_output)
29# assert action_output['status'] == 'completed'
diff --git a/src/tests/unit/conftest.py b/src/tests/unit/conftest.py
0new file mode 10064430new file mode 100644
index 0000000..aca2a0f
--- /dev/null
+++ b/src/tests/unit/conftest.py
@@ -0,0 +1,69 @@
1#!/usr/bin/python3
2import mock
3import pytest
4
5
6# If layer options are used, add this to grafana
7# and import layer in lib_grafana
8@pytest.fixture
9def mock_layers(monkeypatch):
10 import sys
11 sys.modules['charms.layer'] = mock.Mock()
12 sys.modules['reactive'] = mock.Mock()
13 # Mock any functions in layers that need to be mocked here
14
15 def options(layer):
16 # mock options for layers here
17 if layer == 'example-layer':
18 options = {'port': 9999}
19 return options
20 else:
21 return None
22
23 monkeypatch.setattr('lib_grafana.layer.options', options)
24
25
26@pytest.fixture
27def mock_hookenv_config(monkeypatch):
28 import yaml
29
30 def mock_config():
31 cfg = {}
32 yml = yaml.load(open('./config.yaml'))
33
34 # Load all defaults
35 for key, value in yml['options'].items():
36 cfg[key] = value['default']
37
38 # Manually add cfg from other layers
39 # cfg['my-other-layer'] = 'mock'
40 return cfg
41
42 monkeypatch.setattr('lib_grafana.hookenv.config', mock_config)
43
44
45@pytest.fixture
46def mock_remote_unit(monkeypatch):
47 monkeypatch.setattr('lib_grafana.hookenv.remote_unit', lambda: 'unit-mock/0')
48
49
50@pytest.fixture
51def mock_charm_dir(monkeypatch):
52 monkeypatch.setattr('lib_grafana.hookenv.charm_dir', lambda: '/mock/charm/dir')
53
54
55@pytest.fixture
56def grafana(tmpdir, mock_hookenv_config, mock_charm_dir, monkeypatch):
57 from lib_grafana import GrafanaHelper
58 helper = GrafanaHelper()
59
60 # Example config file patching
61 cfg_file = tmpdir.join('example.cfg')
62 with open('./tests/unit/example.cfg', 'r') as src_file:
63 cfg_file.write(src_file.read())
64 helper.example_config_file = cfg_file.strpath
65
66 # Any other functions that load helper will get this version
67 monkeypatch.setattr('lib_grafana.GrafanaHelper', lambda: helper)
68
69 return helper
diff --git a/src/tests/unit/example.cfg b/src/tests/unit/example.cfg
0new file mode 10064470new file mode 100644
index 0000000..81b1e94
--- /dev/null
+++ b/src/tests/unit/example.cfg
@@ -0,0 +1 @@
1This is an example config file included with the unit tests
diff --git a/src/tests/unit/requirements.txt b/src/tests/unit/requirements.txt
0new file mode 1006442new file mode 100644
index 0000000..9c685e5
--- /dev/null
+++ b/src/tests/unit/requirements.txt
@@ -0,0 +1,5 @@
1charmhelpers
2charms.reactive
3mock
4pytest
5pytest-cov
diff --git a/src/tests/unit/test_actions.py b/src/tests/unit/test_actions.py
0new file mode 1006446new file mode 100644
index 0000000..731147e
--- /dev/null
+++ b/src/tests/unit/test_actions.py
@@ -0,0 +1,14 @@
1import imp
2
3import mock
4
5from pytest import mark
6
7class TestActions():
8 @mark.skip()
9 def test_example_action(self, grafana, monkeypatch):
10 mock_function = mock.Mock()
11 monkeypatch.setattr(grafana, 'action_function', mock_function)
12 assert mock_function.call_count == 0
13 imp.load_source('action_function', './actions/example-action')
14 assert mock_function.call_count == 1
diff --git a/src/tests/unit/test_lib.py b/src/tests/unit/test_lib.py
0new file mode 10064415new file mode 100644
index 0000000..733a33c
--- /dev/null
+++ b/src/tests/unit/test_lib.py
@@ -0,0 +1,37 @@
1#!/usr/bin/python3
2
3from pytest import mark
4import mock
5import lib_grafana
6
7
8class TestLib():
9 def test_grafana(self, grafana):
10 ''' See if the helper fixture works to load charm configs '''
11 # NOTE: This was added per the charm-create template; leaving it in in case it is useful.
12 assert isinstance(grafana.charm_config, dict)
13
14 @mark.parametrize(
15 'install_method,result',
16 [
17 ('snap', lib_grafana.SNAP_COMMON),
18 ('apt', lib_grafana.APT_COMMON),
19 ]
20 )
21 @mock.patch('lib_grafana.unitdata.kv')
22 def test_data_path_valid_method_returns_dir(self, unitdata_kv_mock, install_method, result):
23 unitdata_kv_mock.return_value = {
24 'install_method': install_method,
25 }
26 assert lib_grafana.data_path() == result
27
28 @mock.patch('lib_grafana.remove_state')
29 @mock.patch('lib_grafana.hookenv.status_set')
30 @mock.patch('lib_grafana.unitdata.kv')
31 def test_data_path_invalid_method_sets_blocked_status(self, unitdata_kv_mock, status_set_mock, remove_state_mock):
32 unitdata_kv_mock.return_value = {
33 'install_method': 'bad_method',
34 }
35 assert lib_grafana.data_path() is None
36 assert status_set_mock.mock_calls[-1] == mock.call('blocked', 'Unsupported install_method')
37 assert remove_state_mock.mock_calls[-1] == mock.call('grafana.installed')
diff --git a/src/tox.ini b/src/tox.ini
0new file mode 10064438new file mode 100644
index 0000000..bd49daf
--- /dev/null
+++ b/src/tox.ini
@@ -0,0 +1,35 @@
1[tox]
2skipsdist=True
3envlist = unit, functional
4skip_missing_interpreters = True
5
6[testenv]
7basepython = python3
8setenv =
9 PYTHONPATH = .
10
11[testenv:unit]
12commands = pytest -v --ignore {toxinidir}/tests/functional --ignore {toxinidir}/builds --cov=lib --cov=reactice --cov=actions --cov-report=term
13deps = -r{toxinidir}/tests/unit/requirements.txt
14 -r{toxinidir}/requirements.txt
15setenv = PYTHONPATH={toxinidir}/lib
16
17[testenv:functional]
18passenv =
19 HOME
20 JUJU_REPOSITORY
21 PATH
22commands = pytest -v --ignore {toxinidir}/tests/unit
23deps = -r{toxinidir}/tests/functional/requirements.txt
24 -r{toxinidir}/requirements.txt
25
26[testenv:lint]
27commands = flake8
28deps = flake8
29
30[flake8]
31exclude =
32 .git,
33 __pycache__,
34 .tox,
35
diff --git a/wheelhouse.txt b/src/wheelhouse.txt
0similarity index 100%36similarity index 100%
1rename from wheelhouse.txt37rename from wheelhouse.txt
2rename to src/wheelhouse.txt38rename to src/wheelhouse.txt

Subscribers

People subscribed via source and target branches