Skip to content

Commit

Permalink
Additional spag_cli tests for branch coverage and pkg LICENSE check.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrozansk committed May 17, 2019
1 parent 6cb59cd commit cce9e77
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions tests/test_spag_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 2,26 @@
Testing for SPaG CLI script located in spag/__main__.py
"""
import pytest
#from pkg_resources import resource_string
from pkg_resources import Environment


class TestSPaGCLI:
"""
A test suite for testing the SPaG CLI script.
"""

#@staticmethod
#def test_liscence_distro():
# """
# Ensure the LISCENCE is in the distribution.
# """
# pkg_license_output = resource_string('spag', 'LICENSE.txt').decode('ascii')
# with open('LICENSE.txt') as fd:
# git_license_output = fd.read()
# assert git_license_output == pkg_license_output
@staticmethod
def test_liscence_distro():
"""
Ensure the LISCENCE is in the distribution.
"""
spag = Environment().__getitem__('spag')[0]
assert spag.has_metadata('LICENSE.txt')
pkg_license_output = spag.get_metadata('LICENSE.txt')
git_license_output = ''
with open('LICENSE.txt') as fd:
git_license_output = fd.read()
assert git_license_output == pkg_license_output

@staticmethod
def test_version(script_runner):
Expand Down Expand Up @@ -348,6 351,19 @@ def test_generate_safe(script_runner):
assert ret.stderr == ''
assert ret.stdout == ''

@staticmethod
def test_generate_force(script_runner):
"""
Ensure generating again overwrite files if force flag is set.
"""
ret = script_runner.run('spag_cli',
'-p', 'examples/Lisp/parser.json',
'-s', 'examples/Lisp/scanner.json',
'-g', 'c', '-f')
assert ret.returncode == 0
assert ret.stderr == ''
assert ret.stdout == ''

@staticmethod
def test_invalid_scanner_spec(script_runner):
"""
Expand Down

0 comments on commit cce9e77

Please sign in to comment.