Merge ~vultaire/charm-grafana:master into ~prometheus-charmers/charm-grafana:master
- Git
- lp:~vultaire/charm-grafana
- master
- Merge into master
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) |
||||
Related bugs: |
|
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.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Alvaro Uria (aluria) wrote : | # |
Changes here have been merged into a bigger MP. See https:/
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
1 | diff --git a/Makefile b/Makefile |
2 | new file mode 100644 |
3 | index 0000000..5bef873 |
4 | --- /dev/null |
5 | +++ b/Makefile |
6 | @@ -0,0 +1,50 @@ |
7 | +ifndef JUJU_REPOSITORY |
8 | + JUJU_REPOSITORY := $(shell pwd) |
9 | + $(warning Warning JUJU_REPOSITORY was not set, defaulting to $(JUJU_REPOSITORY)) |
10 | +endif |
11 | + |
12 | +help: |
13 | + @echo "This project supports the following targets" |
14 | + @echo "" |
15 | + @echo " make help - show this text" |
16 | + @echo " make submodules - make sure that the submodules are up-to-date" |
17 | + @echo " make lint - run flake8" |
18 | + @echo " make test - run the unittests and lint" |
19 | + @echo " make unittest - run the tests defined in the unittest subdirectory" |
20 | + @echo " make functional - run the tests defined in the functional subdirectory" |
21 | + @echo " make release - build the charm" |
22 | + @echo " make clean - remove unneeded files" |
23 | + @echo "" |
24 | + |
25 | +submodules: |
26 | + @echo "Cloning submodules" |
27 | + @git submodule update --init --recursive |
28 | + |
29 | +lint: |
30 | + @echo "Running flake8" |
31 | + @cd src && tox -e lint |
32 | + |
33 | +test: unittest functional lint |
34 | + |
35 | +unittest: |
36 | + @cd src && tox -e unit |
37 | + |
38 | +functional: build |
39 | + @cd src && tox -e functional |
40 | + |
41 | +build: |
42 | + @echo "Building charm to base directory $(JUJU_REPOSITORY)" |
43 | + @-git describe --tags > ./src/repo-info |
44 | + @LAYER_PATH=./layers INTERFACE_PATH=./interfaces\ |
45 | + JUJU_REPOSITORY=$(JUJU_REPOSITORY) charm build ./src --force |
46 | + |
47 | +release: clean build |
48 | + @echo "Charm is built at $(JUJU_REPOSITORY)/builds" |
49 | + |
50 | +clean: |
51 | + @echo "Cleaning files" |
52 | + @if [ -d src/.tox ] ; then rm -r src/.tox ; fi |
53 | + @if [ -d src/.pytest_cache ] ; then rm -r src/.pytest_cache ; fi |
54 | + |
55 | +# The targets below don't depend on a file |
56 | +.PHONY: lint test unittest functional build release clean help submodules |
57 | diff --git a/interfaces/.empty b/interfaces/.empty |
58 | new file mode 100644 |
59 | index 0000000..792d600 |
60 | --- /dev/null |
61 | +++ b/interfaces/.empty |
62 | @@ -0,0 +1 @@ |
63 | +# |
64 | diff --git a/layers/.empty b/layers/.empty |
65 | new file mode 100644 |
66 | index 0000000..792d600 |
67 | --- /dev/null |
68 | +++ b/layers/.empty |
69 | @@ -0,0 +1 @@ |
70 | +# |
71 | diff --git a/src/Makefile b/src/Makefile |
72 | new file mode 100644 |
73 | index 0000000..e1e1a8b |
74 | --- /dev/null |
75 | +++ b/src/Makefile |
76 | @@ -0,0 +1,25 @@ |
77 | +help: |
78 | + @echo "This project supports the following targets" |
79 | + @echo "" |
80 | + @echo " make help - show this text" |
81 | + @echo " make test - run the functional test and unittests" |
82 | + @echo " make unittest - run the the unittest" |
83 | + @echo " make functionaltest - run the functional tests" |
84 | + @echo " make clean - remove unneeded files" |
85 | + @echo "" |
86 | + |
87 | +test: unittest functionaltest lint |
88 | + |
89 | +unittest: |
90 | + @tox -e unit |
91 | + |
92 | +functionaltest: |
93 | + @tox -e functional |
94 | + |
95 | +clean: |
96 | + @echo "Cleaning files" |
97 | + @if [ -d ./.tox ] ; then rm -r ./.tox ; fi |
98 | + @if [ -d ./.pytest_cache ] ; then rm -r ./.pytest_cache ; fi |
99 | + |
100 | +# The targets below don't depend on a file |
101 | +.PHONY: lint test unittest functionaltest clean help |
102 | diff --git a/README.md b/src/README.md |
103 | similarity index 100% |
104 | rename from README.md |
105 | rename to src/README.md |
106 | diff --git a/actions.yaml b/src/actions.yaml |
107 | similarity index 100% |
108 | rename from actions.yaml |
109 | rename to src/actions.yaml |
110 | diff --git a/actions/change-user-role b/src/actions/change-user-role |
111 | similarity index 100% |
112 | rename from actions/change-user-role |
113 | rename to src/actions/change-user-role |
114 | diff --git a/actions/create-api-key b/src/actions/create-api-key |
115 | similarity index 100% |
116 | rename from actions/create-api-key |
117 | rename to src/actions/create-api-key |
118 | diff --git a/actions/create-user b/src/actions/create-user |
119 | similarity index 100% |
120 | rename from actions/create-user |
121 | rename to src/actions/create-user |
122 | diff --git a/actions/delete-user b/src/actions/delete-user |
123 | similarity index 100% |
124 | rename from actions/delete-user |
125 | rename to src/actions/delete-user |
126 | diff --git a/actions/get-admin-password b/src/actions/get-admin-password |
127 | similarity index 100% |
128 | rename from actions/get-admin-password |
129 | rename to src/actions/get-admin-password |
130 | diff --git a/actions/grafana_utils.py b/src/actions/grafana_utils.py |
131 | similarity index 100% |
132 | rename from actions/grafana_utils.py |
133 | rename to src/actions/grafana_utils.py |
134 | diff --git a/actions/import-dashboard b/src/actions/import-dashboard |
135 | similarity index 100% |
136 | rename from actions/import-dashboard |
137 | rename to src/actions/import-dashboard |
138 | diff --git a/actions/set-user-password b/src/actions/set-user-password |
139 | similarity index 100% |
140 | rename from actions/set-user-password |
141 | rename to src/actions/set-user-password |
142 | diff --git a/config.yaml b/src/config.yaml |
143 | similarity index 64% |
144 | rename from config.yaml |
145 | rename to src/config.yaml |
146 | index 3d58088..ee5cf85 100644 |
147 | --- a/config.yaml |
148 | +++ b/src/config.yaml |
149 | @@ -13,68 +13,68 @@ options: |
150 | default: | |
151 | - | |
152 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
153 | - Version: GnuPG v1 |
154 | + Version: GnuPG v1.4.11 (GNU/Linux) |
155 | |
156 | - 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 |
214 | - sA== |
215 | - =H60S |
216 | + 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 |
275 | + =ewdt |
276 | -----END PGP PUBLIC KEY BLOCK----- |
277 | type: string |
278 | description: | |
279 | diff --git a/copyright b/src/copyright |
280 | similarity index 100% |
281 | rename from copyright |
282 | rename to src/copyright |
283 | diff --git a/files/dashboards_backup b/src/files/dashboards_backup |
284 | similarity index 100% |
285 | rename from files/dashboards_backup |
286 | rename to src/files/dashboards_backup |
287 | diff --git a/getstarted.md b/src/getstarted.md |
288 | similarity index 100% |
289 | rename from getstarted.md |
290 | rename to src/getstarted.md |
291 | diff --git a/icon.svg b/src/icon.svg |
292 | similarity index 100% |
293 | rename from icon.svg |
294 | rename to src/icon.svg |
295 | diff --git a/layer.yaml b/src/layer.yaml |
296 | similarity index 100% |
297 | rename from layer.yaml |
298 | rename to src/layer.yaml |
299 | diff --git a/src/lib/lib_grafana.py b/src/lib/lib_grafana.py |
300 | new file mode 100644 |
301 | index 0000000..b074e53 |
302 | --- /dev/null |
303 | +++ b/src/lib/lib_grafana.py |
304 | @@ -0,0 +1,28 @@ |
305 | +from charmhelpers.core import hookenv, unitdata |
306 | +from charms.reactive import remove_state |
307 | + |
308 | + |
309 | +APT_COMMON = '/var/lib/grafana' |
310 | +SNAP_NAME = 'grafana' |
311 | +SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME) |
312 | + |
313 | + |
314 | +class GrafanaHelper(): |
315 | + def __init__(self): |
316 | + self.charm_config = hookenv.config() |
317 | + |
318 | + def action_function(self): |
319 | + ''' An example function for calling from an action ''' |
320 | + return |
321 | + |
322 | + |
323 | +def data_path(): |
324 | + data_dir = {'snap': SNAP_COMMON, |
325 | + 'apt': APT_COMMON} |
326 | + kv = unitdata.kv() |
327 | + source = kv.get('install_method') |
328 | + if source in ('snap', 'apt'): |
329 | + return data_dir[source] |
330 | + else: |
331 | + hookenv.status_set('blocked', 'Unsupported install_method') |
332 | + remove_state('grafana.installed') |
333 | diff --git a/metadata.yaml b/src/metadata.yaml |
334 | similarity index 100% |
335 | rename from metadata.yaml |
336 | rename to src/metadata.yaml |
337 | diff --git a/reactive/grafana.py b/src/reactive/grafana.py |
338 | similarity index 90% |
339 | rename from reactive/grafana.py |
340 | rename to src/reactive/grafana.py |
341 | index f98e11c..54f80c6 100644 |
342 | --- a/reactive/grafana.py |
343 | +++ b/src/reactive/grafana.py |
344 | @@ -31,12 +31,11 @@ from charms.reactive import ( |
345 | ) |
346 | |
347 | from charms.layer import snap |
348 | +from lib_grafana import data_path, SNAP_NAME |
349 | |
350 | SVCNAME = {'snap': 'snap.grafana.grafana', |
351 | 'apt': 'grafana-server'} |
352 | -SNAP_NAME = 'grafana' |
353 | SNAP_DATA = '/var/snap/{}/current'.format(SNAP_NAME) |
354 | -SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME) |
355 | |
356 | GRAFANA_INI = {'snap': '{}/conf/grafana.ini'.format(SNAP_DATA), |
357 | 'apt': '/etc/grafana/grafana.ini'} |
358 | @@ -126,18 +125,6 @@ def install_packages(): |
359 | hookenv.status_set('blocked', 'Unsupported install_method') |
360 | |
361 | |
362 | -def data_path(): |
363 | - data_dir = {'snap': SNAP_COMMON, |
364 | - 'apt': '/var/lib/grafana'} |
365 | - kv = unitdata.kv() |
366 | - source = kv.get('install_method') |
367 | - if source in ('snap', 'apt'): |
368 | - return data_dir[source] |
369 | - else: |
370 | - hookenv.status_set('blocked', 'Unsupported install_method') |
371 | - remove_state('grafana.installed') |
372 | - |
373 | - |
374 | @when('grafana.installed') |
375 | @when('config.changed.install_plugins') |
376 | def install_plugins(): |
377 | diff --git a/src/requirements.txt b/src/requirements.txt |
378 | new file mode 100644 |
379 | index 0000000..8462291 |
380 | --- /dev/null |
381 | +++ b/src/requirements.txt |
382 | @@ -0,0 +1 @@ |
383 | +# Include python requirements here |
384 | diff --git a/scripts/get_admin_password b/src/scripts/get_admin_password |
385 | similarity index 100% |
386 | rename from scripts/get_admin_password |
387 | rename to src/scripts/get_admin_password |
388 | diff --git a/templates/dashboards/prometheus/CephCluster.json.j2 b/src/templates/dashboards/prometheus/CephCluster.json.j2 |
389 | similarity index 100% |
390 | rename from templates/dashboards/prometheus/CephCluster.json.j2 |
391 | rename to src/templates/dashboards/prometheus/CephCluster.json.j2 |
392 | diff --git a/templates/dashboards/prometheus/CephOSD.json.j2 b/src/templates/dashboards/prometheus/CephOSD.json.j2 |
393 | similarity index 100% |
394 | rename from templates/dashboards/prometheus/CephOSD.json.j2 |
395 | rename to src/templates/dashboards/prometheus/CephOSD.json.j2 |
396 | diff --git a/templates/dashboards/prometheus/CephPools.json.j2 b/src/templates/dashboards/prometheus/CephPools.json.j2 |
397 | similarity index 100% |
398 | rename from templates/dashboards/prometheus/CephPools.json.j2 |
399 | rename to src/templates/dashboards/prometheus/CephPools.json.j2 |
400 | diff --git a/templates/dashboards/prometheus/OpenStackCloud.json.j2 b/src/templates/dashboards/prometheus/OpenStackCloud.json.j2 |
401 | similarity index 100% |
402 | rename from templates/dashboards/prometheus/OpenStackCloud.json.j2 |
403 | rename to src/templates/dashboards/prometheus/OpenStackCloud.json.j2 |
404 | diff --git a/templates/dashboards/prometheus/RabbitMQ.json.j2 b/src/templates/dashboards/prometheus/RabbitMQ.json.j2 |
405 | similarity index 100% |
406 | rename from templates/dashboards/prometheus/RabbitMQ.json.j2 |
407 | rename to src/templates/dashboards/prometheus/RabbitMQ.json.j2 |
408 | diff --git a/templates/dashboards/prometheus/Swift.json.j2 b/src/templates/dashboards/prometheus/Swift.json.j2 |
409 | similarity index 100% |
410 | rename from templates/dashboards/prometheus/Swift.json.j2 |
411 | rename to src/templates/dashboards/prometheus/Swift.json.j2 |
412 | diff --git a/templates/dashboards/prometheus/Telegraf.json.j2 b/src/templates/dashboards/prometheus/Telegraf.json.j2 |
413 | similarity index 100% |
414 | rename from templates/dashboards/prometheus/Telegraf.json.j2 |
415 | rename to src/templates/dashboards/prometheus/Telegraf.json.j2 |
416 | diff --git a/templates/grafana.ini.j2 b/src/templates/grafana.ini.j2 |
417 | similarity index 100% |
418 | rename from templates/grafana.ini.j2 |
419 | rename to src/templates/grafana.ini.j2 |
420 | diff --git a/templates/juju-dashboards-backup.j2 b/src/templates/juju-dashboards-backup.j2 |
421 | similarity index 100% |
422 | rename from templates/juju-dashboards-backup.j2 |
423 | rename to src/templates/juju-dashboards-backup.j2 |
424 | diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt |
425 | new file mode 100644 |
426 | index 0000000..f76bfbb |
427 | --- /dev/null |
428 | +++ b/src/tests/functional/requirements.txt |
429 | @@ -0,0 +1,6 @@ |
430 | +flake8 |
431 | +juju |
432 | +mock |
433 | +pytest |
434 | +pytest-asyncio |
435 | +requests |
436 | diff --git a/src/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py |
437 | new file mode 100644 |
438 | index 0000000..c41422d |
439 | --- /dev/null |
440 | +++ b/src/tests/functional/test_deploy.py |
441 | @@ -0,0 +1,29 @@ |
442 | +import pytest |
443 | +from juju.model import Model |
444 | + |
445 | +# Treat tests as coroutines |
446 | +pytestmark = pytest.mark.asyncio |
447 | + |
448 | +series = ['bionic'] |
449 | + |
450 | + |
451 | +@pytest.fixture |
452 | +async def model(): |
453 | + model = Model() |
454 | + await model.connect_current() |
455 | + yield model |
456 | + await model.disconnect() |
457 | + |
458 | + |
459 | +@pytest.mark.parametrize('series', series) |
460 | +async def test_grafana_deploy(model, series): |
461 | + app = await model.deploy('.', series=series) |
462 | + await model.block_until(lambda: app.status == 'active') |
463 | + assert True |
464 | + |
465 | + |
466 | +# def test_example_action(self, deploy, unit): |
467 | +# uuid = unit.run_action('example-action') |
468 | +# action_output = deploy.get_action_output(uuid, full_output=True) |
469 | +# print(action_output) |
470 | +# assert action_output['status'] == 'completed' |
471 | diff --git a/src/tests/unit/conftest.py b/src/tests/unit/conftest.py |
472 | new file mode 100644 |
473 | index 0000000..aca2a0f |
474 | --- /dev/null |
475 | +++ b/src/tests/unit/conftest.py |
476 | @@ -0,0 +1,69 @@ |
477 | +#!/usr/bin/python3 |
478 | +import mock |
479 | +import pytest |
480 | + |
481 | + |
482 | +# If layer options are used, add this to grafana |
483 | +# and import layer in lib_grafana |
484 | +@pytest.fixture |
485 | +def mock_layers(monkeypatch): |
486 | + import sys |
487 | + sys.modules['charms.layer'] = mock.Mock() |
488 | + sys.modules['reactive'] = mock.Mock() |
489 | + # Mock any functions in layers that need to be mocked here |
490 | + |
491 | + def options(layer): |
492 | + # mock options for layers here |
493 | + if layer == 'example-layer': |
494 | + options = {'port': 9999} |
495 | + return options |
496 | + else: |
497 | + return None |
498 | + |
499 | + monkeypatch.setattr('lib_grafana.layer.options', options) |
500 | + |
501 | + |
502 | +@pytest.fixture |
503 | +def mock_hookenv_config(monkeypatch): |
504 | + import yaml |
505 | + |
506 | + def mock_config(): |
507 | + cfg = {} |
508 | + yml = yaml.load(open('./config.yaml')) |
509 | + |
510 | + # Load all defaults |
511 | + for key, value in yml['options'].items(): |
512 | + cfg[key] = value['default'] |
513 | + |
514 | + # Manually add cfg from other layers |
515 | + # cfg['my-other-layer'] = 'mock' |
516 | + return cfg |
517 | + |
518 | + monkeypatch.setattr('lib_grafana.hookenv.config', mock_config) |
519 | + |
520 | + |
521 | +@pytest.fixture |
522 | +def mock_remote_unit(monkeypatch): |
523 | + monkeypatch.setattr('lib_grafana.hookenv.remote_unit', lambda: 'unit-mock/0') |
524 | + |
525 | + |
526 | +@pytest.fixture |
527 | +def mock_charm_dir(monkeypatch): |
528 | + monkeypatch.setattr('lib_grafana.hookenv.charm_dir', lambda: '/mock/charm/dir') |
529 | + |
530 | + |
531 | +@pytest.fixture |
532 | +def grafana(tmpdir, mock_hookenv_config, mock_charm_dir, monkeypatch): |
533 | + from lib_grafana import GrafanaHelper |
534 | + helper = GrafanaHelper() |
535 | + |
536 | + # Example config file patching |
537 | + cfg_file = tmpdir.join('example.cfg') |
538 | + with open('./tests/unit/example.cfg', 'r') as src_file: |
539 | + cfg_file.write(src_file.read()) |
540 | + helper.example_config_file = cfg_file.strpath |
541 | + |
542 | + # Any other functions that load helper will get this version |
543 | + monkeypatch.setattr('lib_grafana.GrafanaHelper', lambda: helper) |
544 | + |
545 | + return helper |
546 | diff --git a/src/tests/unit/example.cfg b/src/tests/unit/example.cfg |
547 | new file mode 100644 |
548 | index 0000000..81b1e94 |
549 | --- /dev/null |
550 | +++ b/src/tests/unit/example.cfg |
551 | @@ -0,0 +1 @@ |
552 | +This is an example config file included with the unit tests |
553 | diff --git a/src/tests/unit/requirements.txt b/src/tests/unit/requirements.txt |
554 | new file mode 100644 |
555 | index 0000000..9c685e5 |
556 | --- /dev/null |
557 | +++ b/src/tests/unit/requirements.txt |
558 | @@ -0,0 +1,5 @@ |
559 | +charmhelpers |
560 | +charms.reactive |
561 | +mock |
562 | +pytest |
563 | +pytest-cov |
564 | diff --git a/src/tests/unit/test_actions.py b/src/tests/unit/test_actions.py |
565 | new file mode 100644 |
566 | index 0000000..731147e |
567 | --- /dev/null |
568 | +++ b/src/tests/unit/test_actions.py |
569 | @@ -0,0 +1,14 @@ |
570 | +import imp |
571 | + |
572 | +import mock |
573 | + |
574 | +from pytest import mark |
575 | + |
576 | +class TestActions(): |
577 | + @mark.skip() |
578 | + def test_example_action(self, grafana, monkeypatch): |
579 | + mock_function = mock.Mock() |
580 | + monkeypatch.setattr(grafana, 'action_function', mock_function) |
581 | + assert mock_function.call_count == 0 |
582 | + imp.load_source('action_function', './actions/example-action') |
583 | + assert mock_function.call_count == 1 |
584 | diff --git a/src/tests/unit/test_lib.py b/src/tests/unit/test_lib.py |
585 | new file mode 100644 |
586 | index 0000000..733a33c |
587 | --- /dev/null |
588 | +++ b/src/tests/unit/test_lib.py |
589 | @@ -0,0 +1,37 @@ |
590 | +#!/usr/bin/python3 |
591 | + |
592 | +from pytest import mark |
593 | +import mock |
594 | +import lib_grafana |
595 | + |
596 | + |
597 | +class TestLib(): |
598 | + def test_grafana(self, grafana): |
599 | + ''' See if the helper fixture works to load charm configs ''' |
600 | + # NOTE: This was added per the charm-create template; leaving it in in case it is useful. |
601 | + assert isinstance(grafana.charm_config, dict) |
602 | + |
603 | + @mark.parametrize( |
604 | + 'install_method,result', |
605 | + [ |
606 | + ('snap', lib_grafana.SNAP_COMMON), |
607 | + ('apt', lib_grafana.APT_COMMON), |
608 | + ] |
609 | + ) |
610 | + @mock.patch('lib_grafana.unitdata.kv') |
611 | + def test_data_path_valid_method_returns_dir(self, unitdata_kv_mock, install_method, result): |
612 | + unitdata_kv_mock.return_value = { |
613 | + 'install_method': install_method, |
614 | + } |
615 | + assert lib_grafana.data_path() == result |
616 | + |
617 | + @mock.patch('lib_grafana.remove_state') |
618 | + @mock.patch('lib_grafana.hookenv.status_set') |
619 | + @mock.patch('lib_grafana.unitdata.kv') |
620 | + def test_data_path_invalid_method_sets_blocked_status(self, unitdata_kv_mock, status_set_mock, remove_state_mock): |
621 | + unitdata_kv_mock.return_value = { |
622 | + 'install_method': 'bad_method', |
623 | + } |
624 | + assert lib_grafana.data_path() is None |
625 | + assert status_set_mock.mock_calls[-1] == mock.call('blocked', 'Unsupported install_method') |
626 | + assert remove_state_mock.mock_calls[-1] == mock.call('grafana.installed') |
627 | diff --git a/src/tox.ini b/src/tox.ini |
628 | new file mode 100644 |
629 | index 0000000..bd49daf |
630 | --- /dev/null |
631 | +++ b/src/tox.ini |
632 | @@ -0,0 +1,35 @@ |
633 | +[tox] |
634 | +skipsdist=True |
635 | +envlist = unit, functional |
636 | +skip_missing_interpreters = True |
637 | + |
638 | +[testenv] |
639 | +basepython = python3 |
640 | +setenv = |
641 | + PYTHONPATH = . |
642 | + |
643 | +[testenv:unit] |
644 | +commands = pytest -v --ignore {toxinidir}/tests/functional --ignore {toxinidir}/builds --cov=lib --cov=reactice --cov=actions --cov-report=term |
645 | +deps = -r{toxinidir}/tests/unit/requirements.txt |
646 | + -r{toxinidir}/requirements.txt |
647 | +setenv = PYTHONPATH={toxinidir}/lib |
648 | + |
649 | +[testenv:functional] |
650 | +passenv = |
651 | + HOME |
652 | + JUJU_REPOSITORY |
653 | + PATH |
654 | +commands = pytest -v --ignore {toxinidir}/tests/unit |
655 | +deps = -r{toxinidir}/tests/functional/requirements.txt |
656 | + -r{toxinidir}/requirements.txt |
657 | + |
658 | +[testenv:lint] |
659 | +commands = flake8 |
660 | +deps = flake8 |
661 | + |
662 | +[flake8] |
663 | +exclude = |
664 | + .git, |
665 | + __pycache__, |
666 | + .tox, |
667 | + |
668 | diff --git a/wheelhouse.txt b/src/wheelhouse.txt |
669 | similarity index 100% |
670 | rename from wheelhouse.txt |
671 | rename to src/wheelhouse.txt |
This merge proposal is being monitored by mergebot. Change the status to Approved to merge.