-
Notifications
You must be signed in to change notification settings - Fork 2
adding automated tests #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6cf43d
overwrite parent to add child
Mahir-Sparkess b90834c
adding automated tests
f660885
overwrite parent node using update method
Mahir-Sparkess 705516c
add dev install to get test requirements
c739790
adding dev extras_require
f38b808
Merge pull request #9 from Mahir-Sparkess/issue/8/overwrite-parent
9bbf4f0
Adding test badge
fa2145e
Increment version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# encoding: utf-8 | ||
""" | ||
|
||
""" | ||
__author__ = 'Richard Smith' | ||
__date__ = '23 Nov 2021' | ||
__copyright__ = 'Copyright 2018 United Kingdom Research and Innovation' | ||
__license__ = 'BSD - see LICENSE file in top-level package directory' | ||
__contact__ = 'richard.d.smith@stfc.ac.uk' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# encoding: utf-8 | ||
""" | ||
|
||
""" | ||
__author__ = 'Richard Smith' | ||
__date__ = '23 Nov 2021' | ||
__copyright__ = 'Copyright 2018 United Kingdom Research and Innovation' | ||
__license__ = 'BSD - see LICENSE file in top-level package directory' | ||
__contact__ = 'richard.d.smith@stfc.ac.uk' | ||
|
||
import pytest | ||
|
||
from directory_tree import DatasetNode | ||
|
||
@pytest.fixture | ||
def tree(): | ||
return DatasetNode() | ||
|
||
|
||
def test_add_child(tree): | ||
|
||
dataset_path = '/badc/faam/a/b/c/' | ||
tree.add_child(dataset_path) | ||
|
||
node = tree.search('/badc/faam/a/b/c/d/e') | ||
|
||
assert node.dataset | ||
assert node.directory_path() == dataset_path | ||
|
||
|
||
def test_extra_args(tree): | ||
dataset_path = '/badc/faam/a/b/c/' | ||
tree.add_child(dataset_path, description_file='file1') | ||
|
||
node = tree.search('/badc/faam/a/b/c/d/e') | ||
|
||
assert node.dataset | ||
assert node.directory_path() == dataset_path | ||
assert node.description_file == 'file1' | ||
|
||
def test_search_all(tree): | ||
|
||
path1 = '/badc/faam/a/' | ||
path2 = '/badc/faam/a/b/c/' | ||
|
||
tree.add_child(path1) | ||
tree.add_child(path2) | ||
|
||
nodes = tree.search_all('/badc/faam/a/b/c/d/e/') | ||
|
||
assert len(nodes) == 2 | ||
assert nodes[0].directory_path() == path1 | ||
assert nodes[1].directory_path() == path2 | ||
|
||
|
||
def test_out_of_order_add_child(tree): | ||
|
||
path1 = '/badc/faam/a/' | ||
path2 = '/badc/faam/a/b/c/' | ||
|
||
tree.add_child(path2, description_file='file2') | ||
tree.add_child(path1, description_file='file1') | ||
|
||
nodes = tree.search_all('/badc/faam/a/b/c/d/e/') | ||
|
||
assert nodes[0].description_file == 'file1' | ||
assert nodes[1].description_file == 'file2' | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[tox] | ||
envlist = py36, py37, py38, flake8 | ||
|
||
[gh-actions] | ||
python = | ||
3.8: py38 | ||
3.7: py37 | ||
3.6: py36 | ||
|
||
|
||
[testenv] | ||
setenv = | ||
PYTHONPATH = {toxinidir} | ||
deps = pytest | ||
-r{toxinidir}/requirements.txt | ||
extras = dev | ||
commands = pytest {posargs} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.