summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimeon Simeonov2022-04-10 22:21:41 +0200
committerSimeon Simeonov2022-04-10 22:21:41 +0200
commitd15ee60ca7ad62004c5e036203f095cc27660f90 (patch)
tree0fc478fe2cab5cd670137ad4d4dbd75fd4b68b36 /tests
parente36f260c2ebc5e21724e5eedf0a91d2bc66cceec (diff)
Introduce a new macro (%p) representing the parent value of a given key
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py15
-rw-r--r--tests/test_cli.py4
-rw-r--r--tests/test_envtoolkit_instance.py13
3 files changed, 19 insertions, 13 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 0770adb..5dcc456 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -30,17 +30,16 @@ def config_data():
30 ) 30 )
31 }, 31 },
32 'instances': { 32 'instances': {
33 'default': {'ETOOLKIT_PROMPT': '(%i)'}, 33 '_default': {
34 'ETOOLKIT_PROMPT': '(%i)',
35 'PYTHONPATH': '/home/foo/%i/python',
36 },
34 'dev': { 37 'dev': {
35 'ETOOLKIT_PARENT': 'default', 38 'ETOOLKIT_PARENT': '_default',
36 'PYTHONPATH': ':/home/user/.pythonpath', 39 'PYTHONPATH': '%p:/home/user/%i/.pythonpath',
37 'DB_CONNECTION': (
38 'enc-val$1$Y/TBb1F3siHTw6qZg9ERzZfA8PLPf2CwGSQLpu9jYWw=$FT'
39 '5tS9o+ABvsxogIXpJim16Gz5SVtV8='
40 ),
41 }, 40 },
42 'secret': { 41 'secret': {
43 'ETOOLKIT_PARENT': 'default', 42 'ETOOLKIT_PARENT': '_default',
44 'ETOOLKIT_SENSITIVE': ['PASSWORD'], 43 'ETOOLKIT_SENSITIVE': ['PASSWORD'],
45 'GNUPGHOME': '%h/private/.gnupg', 44 'GNUPGHOME': '%h/private/.gnupg',
46 'PASSWORD': ( 45 'PASSWORD': (
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 884e676..684c2e7 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -89,9 +89,7 @@ def test_list(capsys, config_file):
89 main(['-c', f'{config_file}', '-l']) 89 main(['-c', f'{config_file}', '-l'])
90 assert exit_info.type == SystemExit 90 assert exit_info.type == SystemExit
91 assert exit_info.value.code == 0 91 assert exit_info.value.code == 0
92 assert capsys.readouterr().out.strip() == ( 92 assert capsys.readouterr().out.strip() == f'dev{os.linesep}secret'
93 f'default{os.linesep}dev{os.linesep}secret'
94 )
95 93
96 94
97def test_help(capsys): 95def test_help(capsys):
diff --git a/tests/test_envtoolkit_instance.py b/tests/test_envtoolkit_instance.py
index 9061dc8..09baa31 100644
--- a/tests/test_envtoolkit_instance.py
+++ b/tests/test_envtoolkit_instance.py
@@ -1,5 +1,5 @@
1# etoolkit 1# etoolkit
2# Copyright (C) 2021-22 Simeon Simeonov 2# Copyright (C) 2021-2022 Simeon Simeonov
3 3
4# This program is free software: you can redistribute it and/or modify 4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
@@ -63,4 +63,13 @@ def test_get_environ(config_data):
63def test_get_full_name(config_data): 63def test_get_full_name(config_data):
64 """Tests the EtoolkitInstance.get_full_name method""" 64 """Tests the EtoolkitInstance.get_full_name method"""
65 instance = etoolkit.EtoolkitInstance('secret', config_data) 65 instance = etoolkit.EtoolkitInstance('secret', config_data)
66 assert instance.get_full_name('->') == 'default->secret' 66 assert instance.get_full_name('->') == '_default->secret'
67
68
69def test_parent_vars(config_data):
70 """Tests the EtoolkitInstance.get_full_name method"""
71 instance = etoolkit.EtoolkitInstance('dev', config_data)
72 assert instance.get_full_name('->') == '_default->dev'
73 assert instance.get_environ()['PYTHONPATH'] == (
74 '/home/foo/_default/python:/home/user/dev/.pythonpath'
75 )