-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from gcarrarom/feature/undo-flag
Feature/undo flag
- Loading branch information
Showing
9 changed files
with
317 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ tests/__pycache__ | |
coverage.xml | ||
htmlcov | ||
demo.yml | ||
tests/*.bak |
This file contains 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 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 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
setup( | ||
name='kcleaner', | ||
version='0.1.2', | ||
version='0.2.0', | ||
author='Gui Martins', | ||
url='https://fancywhale.ca/', | ||
author_email='[email protected]', | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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,54 @@ | ||
from kcleaner import file_exists | ||
from testfixtures import log_capture | ||
import click | ||
from click.testing import CliRunner | ||
import pytest | ||
|
||
runner = CliRunner() | ||
|
||
@log_capture() | ||
def test_no_parameters(capture): | ||
|
||
with pytest.raises(SystemExit) as pytest_wrapped_e: | ||
file_exists(None) | ||
|
||
assert pytest_wrapped_e.value.code == 20 | ||
capture.check_present( | ||
('root', 'ERROR', "Filename cannot be 'None'") | ||
) | ||
|
||
@log_capture() | ||
def test_empty_string(capture): | ||
|
||
with pytest.raises(SystemExit) as pytest_wrapped_e: | ||
file_exists("") | ||
|
||
assert pytest_wrapped_e.value.code == 21 | ||
capture.check_present( | ||
('root', 'ERROR', "Filename cannot be empty!") | ||
) | ||
|
||
@log_capture() | ||
def test_existing_file(capture): | ||
with runner.isolated_filesystem(): | ||
with open('./config', 'w') as f: | ||
f.write('lololol') | ||
|
||
exists = file_exists("./config") | ||
|
||
assert exists == True | ||
capture.check_present( | ||
('root', 'DEBUG', 'File exists!') | ||
) | ||
|
||
@log_capture() | ||
def test_non_existing_file(capture): | ||
with runner.isolated_filesystem(): | ||
|
||
exists = file_exists("./config") | ||
|
||
assert exists == False | ||
capture.check_present( | ||
('root', 'INFO', 'Config File Not found!') | ||
) | ||
|
This file contains 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,49 @@ | ||
import click | ||
from click.testing import CliRunner | ||
from kcleaner import cli | ||
from testfixtures import log_capture | ||
|
||
|
||
runner = CliRunner() | ||
|
||
@log_capture() | ||
def test_clean_non_existant_file(capture): | ||
|
||
results = runner.invoke(cli, ['-k', './non_existent_file']) | ||
assert results.exit_code == 10 | ||
capture.check_present( | ||
('root', 'DEBUG', 'Trying to retrieve contents of file ./non_existent_file'), | ||
('root', 'DEBUG', 'checking if file ./non_existent_file exists...'), | ||
('root', 'INFO', 'Config File Not found!'), | ||
('root', 'ERROR', 'Cannot work with an empty file!, please check the path of your config file.'), | ||
) | ||
|
||
@log_capture() | ||
def test_clean_empty_file(capture): | ||
with runner.isolated_filesystem(): | ||
with open('./config', 'w') as f: | ||
f.write('') | ||
|
||
result = runner.invoke(cli, ['-k', './config']) | ||
assert result.exit_code == 11 | ||
capture.check_present( | ||
('root', 'DEBUG', 'Trying to retrieve contents of file ./config'), | ||
('root', 'DEBUG', 'checking if file ./config exists...'), | ||
('root', 'DEBUG', 'File exists!'), | ||
('root', 'DEBUG', "Type of the file contents: <class 'NoneType'>"), | ||
('root', 'ERROR', "Config File is empty! Can't use it.") | ||
) | ||
|
||
@log_capture() | ||
def test_non_valid_yaml(capture): | ||
with runner.isolated_filesystem(): | ||
with open('./config', 'w') as f: | ||
f.write('lololol') | ||
|
||
result = runner.invoke(cli, ['-k', './config']) | ||
assert result.exit_code == 12 | ||
capture.check_present( | ||
('root', 'DEBUG', 'checking if file ./config exists...'), | ||
('root', 'DEBUG', 'File exists!'), | ||
('root', 'ERROR', 'Config File is not a valid yaml file!'), | ||
) |
Oops, something went wrong.