Skip to content

Commit

Permalink
TST: test also DUECREDIT_REPORT_TAGS while we're at it
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed May 28, 2016
1 parent fc799e3 commit 00712e1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions duecredit/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,51 @@ def test_output_return_all():

for flag in ['1', 'True', 'TRUE', 'true', 'on', 'yes']:
with patch.dict(os.environ, {'DUECREDIT_REPORT_ALL': flag}):
# if _all is None then get the environment
packages, modules, objects = output._get_collated_citations(tags=['*'])
assert_equal(len(packages), 2)
assert_false(modules)
assert_false(objects)
# however if _all is set it shouldn't work
packages, modules, objects = output._get_collated_citations(tags=['*'], all_=False)
assert_false(packages)
assert_false(modules)
assert_false(objects)


def test_output_tags():
entry = BibTeX(_sample_bibtex)
entry2 = BibTeX(_sample_bibtex2)

# normal use
collector = DueCreditCollector()
collector.cite(entry, path='package', cite_module=True, tags=['edu'])
collector.cite(entry2, path='package.module', tags=['wip'])

output = Output(None, collector)

packages, modules, objects = output._get_collated_citations(tags=['*'])
assert_true(len(packages) == 1)
assert_true(len(modules) == 1)
assert_false(objects)

packages, modules, objects = output._get_collated_citations()
assert_false(packages)
assert_false(modules)
assert_false(objects)

for tags in ['edu', 'wip', 'edu,wip']:
with patch.dict(os.environ, {'DUECREDIT_REPORT_TAGS': tags}):
# if tags is None then get the environment
packages, modules, objects = output._get_collated_citations()
assert_true(len(packages) == (1 if 'edu' in tags else 0))
assert_true(len(modules) == (1 if 'wip' in tags else 0))
assert_false(objects)
# however if tags is set it shouldn't work
packages, modules, objects = output._get_collated_citations(tags=['implementation'])
assert_false(packages)
assert_false(modules)
assert_false(objects)


def test_text_output():
Expand Down

0 comments on commit 00712e1

Please sign in to comment.