Skip to content

Commit

Permalink
Adding tox and moving initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sarcasticadmin committed Aug 12, 2019
1 parent 632de39 commit c673046
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 23 deletions.
Empty file added __init__.py
Empty file.
Empty file added tests/unit/__init__.py
Empty file.
46 changes: 23 additions & 23 deletions test_initial.py → tests/unit/test_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ def test_trailing_slash():

## recursive_path_builder

@mock.patch('kv_recursive.list_path')
def test_recursive_path_buider(mock_list_path):
client = ""
kv_list = ['test/', 'test1']
kv_version = 1
source_mount = 'secret'

mock_list_path.return_value = ''

kv_recursive.recursive_path_builder(client, kv_list, kv_version, source_mount)

assert kv_recursive.list_path.called
# assert kv_recursive.recursive_path_builder.called


@mock.patch('hvac.api.secrets_engines.kv_v1.list_secrets')
def test_list_path(mock_kv)

kv_version = 1
list_path()


#@mock.patch('kv_recursive.list_path')
#def test_recursive_path_buider(mock_list_path):
# client = ""
# kv_list = ['test/', 'test1']
# kv_version = 1
# source_mount = 'secret'
#
# mock_list_path.return_value = ''
#
# kv_recursive.recursive_path_builder(client, kv_list, kv_version, source_mount)
#
# assert kv_recursive.list_path.called
# # assert kv_recursive.recursive_path_builder.called


#@mock.patch('hvac.api.secrets_engines.kv_v1.list_secrets')
#def test_list_path(mock_kv)
#
#kv_version = 1
#list_path()
#
#
# kv_list has test/, ensure list_path is called then ensure recursive_path_builder is called

# kv_list has no ending /s, ensure neither list_path or recursive_ are called
Expand All @@ -47,4 +47,4 @@ def test_list_path(mock_kv)

## read_secrets_from_list

# pass a list with secret/test, mock return to read_secret() and enssure properformat of output
# pass a list with secret/test, mock return to read_secret() and enssure properformat of output
42 changes: 42 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[flake8]
# Ignores
# E121: Line continuation not a multiple of 4
# E128: Line continuation not lined up
# E402: Imports can be spaced out
# W503: Making if's readable
ignore = E121,E128,E402,W503,E12

# This project follows the datanav convention for line length.
max-complexity = 10
max-line-length = 120

[tox]
# This means you MUST call pip install -e in your commands for each testenv
# unless you don't actually need the full env (e.g. flake8)
skipsdist = True
envlist = flake8, vault_kv_migration_tests

[testenv]
basepython = python3.6
basedeps =
pytest-cov
mock
pytest
whitelist_externals =
rm

[testenv:flake8]
deps =
flake8
commands =
flake8 ./tests/unit

[testenv:vault_kv_migration_tests]
# changedir happens after deps so you need
# full path to reqs
deps = -r ./requirements.txt
{[testenv]basedeps}
commands =
pip install -e .
coverage erase
py.test --cov-report=term-missing ./tests/unit

0 comments on commit c673046

Please sign in to comment.