Skip to content

Commit

Permalink
Merge pull request #27 from seddonym/add-failing-functional-tests
Browse files Browse the repository at this point in the history
Add failing functional tests
  • Loading branch information
seddonym committed Mar 23, 2019
2 parents e322373 + 963199b commit 0c8940f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
11 changes: 11 additions & 0 deletions tests/assets/testpackage/.brokencontract.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[importlinter]
root_package_name = testpackage


[importlinter:contract:one]
name=Expected broken contract
; This should fail, as high.blue.one -> utils -> high.green.
type=independence
modules=
testpackage.high.blue
testpackage.high.green
9 changes: 9 additions & 0 deletions tests/assets/testpackage/.malformedcontract.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[importlinter]
root_package_name = testpackage


[importlinter:contract:one]
name=Expected malformed contract
; This should fail validation, as modules expects multiple arguments.
type=independence
modules=testpackage.high.blue
20 changes: 17 additions & 3 deletions tests/functional/test_lint_imports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

import pytest

from importlinter import cli


Expand All @@ -11,9 +13,21 @@
)


def test_lint_imports():
@pytest.mark.parametrize(
'config_filename, expected_result',
(
(None, cli.EXIT_STATUS_SUCCESS),
('.brokencontract.ini', cli.EXIT_STATUS_ERROR),
('.malformedcontract.ini', cli.EXIT_STATUS_ERROR),
)
)
def test_lint_imports(config_filename, expected_result):

os.chdir(testpackage_directory)
result = cli.lint_imports()

assert 0 == result
if config_filename:
result = cli.lint_imports(config_filename=config_filename)
else:
result = cli.lint_imports()

assert expected_result == result

0 comments on commit 0c8940f

Please sign in to comment.