Skip to content
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

Add plugin level citations to the action --citation flag #339

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion q2cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ def get_opt_groups(self, ctx):
}

def _get_citation_records(self):
return self._get_action().citations
# Get plugin level citations
citations = list(self._get_plugin().citations)
# Add action level citations
citations.extend(self._get_action().citations)
return tuple(citations)

def _get_plugin(self):
import q2cli.util
Expand Down
56 changes: 56 additions & 0 deletions q2cli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,54 @@
from q2cli.click.type import QIIME2Type


EXPECTED_CITATIONS = """% use `qiime tools citations` on a QIIME 2 result for complete list

@article{key0,
author = {Unger, Donald L},
journal = {Arthritis & Rheumatology},
number = {5},
pages = {949--950},
publisher = {Wiley Online Library},
title = {Does knuckle cracking lead to arthritis of the fingers?},
volume = {41},
year = {1998}
}

@article{key1,
author = {Berry, Michael Victor and Geim, Andre Konstantin},
journal = {European Journal of Physics},
number = {4},
pages = {307},
publisher = {IOP Publishing},
title = {Of flying frogs and levitrons},
volume = {18},
year = {1997}
}

@article{key2,
author = {Witcombe, Brian and Meyer, Dan},
journal = {BMJ},
number = {7582},
pages = {1285--1287},
publisher = {British Medical Journal Publishing Group},
title = {Sword swallowing and its side effects},
volume = {333},
year = {2006}
}

@article{key3,
author = {Reimers, Eigil and Eftestøl, Sindre},
journal = {Arctic, antarctic, and alpine research},
number = {4},
pages = {483--489},
publisher = {BioOne},
title = {Response behaviors of Svalbard reindeer towards humans and humans disguised as polar bears on Edgeøya},
volume = {44},
year = {2012}
}
""" # noqa: E501


class CliTests(unittest.TestCase):
def setUp(self):
get_dummy_plugin()
Expand Down Expand Up @@ -359,6 +407,14 @@ def test_run_deprecated_gets_warning_msg(self):

self.assertIn('deprecated', result.output)

def test_get_citations(self):
qiime_cli = RootCommand()
command = qiime_cli.get_command(ctx=None, name='dummy-plugin')
result = self.runner.invoke(command, ['split-ints', '--citations'])

self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, EXPECTED_CITATIONS)


class TestOptionalArtifactSupport(unittest.TestCase):
def setUp(self):
Expand Down
Loading