Skip to content

Commit

Permalink
Merge pull request #616 from opencobra/cli_tests
Browse files Browse the repository at this point in the history
Cli tests
  • Loading branch information
Midnighter committed Mar 29, 2019
2 parents 8c4eabc + 2bbcad3 commit 5887ccf
Show file tree
Hide file tree
Showing 11 changed files with 592 additions and 83 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ Next Release
* Add metrics, i.e., model-size independent test outcomes to almost all test
cases.
* Repair auto generation of API docs and update section on test suite.
* Remove our dependecy on PyGithub and TravisPy by reimplementing all the
necessary steps with `requests`
* Add unit and integration tests for `runner.py` and `reports.py`, except
for `memote online`.
* Debug `memote online` - could only be tested manually, CI is impossible
without a secure way of storing github credentials.
* Add logging statements to all CLI functions to facilitate future debugging.

0.9.3 (2019-01-30)
------------------
Expand Down
11 changes: 8 additions & 3 deletions memote/suite/cli/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import logging
import sys
from builtins import open
from multiprocessing import Pool
from multiprocessing import Pool, cpu_count
from functools import partial

from libsbml import SBMLError
Expand Down Expand Up @@ -143,6 +143,7 @@ def snapshot(model, filename, pytest_args, exclusive, skip, solver,
"option can be specified multiple times.")
def history(location, model, filename, deployment, custom_config):
"""Generate a report over a model's git commit history."""
LOGGER.info("Initialising history report generation.")
if location is None:
raise click.BadParameter("No 'location' given or configured.")
try:
Expand All @@ -153,7 +154,9 @@ def history(location, model, filename, deployment, custom_config):
"the model's commit history.")
sys.exit(1)
previous = repo.active_branch
repo.heads[deployment].checkout()
LOGGER.info("Obtaining history of results from "
"the deployment branch {}.".format(deployment))
repo.git.checkout(deployment)
try:
manager = managers.SQLResultManager(repository=repo, location=location)
except (AttributeError, ArgumentError):
Expand All @@ -163,8 +166,10 @@ def history(location, model, filename, deployment, custom_config):
# Update the default test configuration with custom ones (if any).
for custom in custom_config:
config.merge(ReportConfiguration.load(custom))
LOGGER.info("Tracing the commit history.")
history = managers.HistoryManager(repository=repo, manager=manager)
history.load_history(model, skip={deployment})
LOGGER.info("Composing the history report.")
report = api.history_report(history, config=config)
previous.checkout()
with open(filename, "w", encoding="utf-8") as file_handle:
Expand Down Expand Up @@ -271,7 +276,7 @@ def diff(models, filename, pytest_args, exclusive, skip, solver,
partial_test_diff = partial(_test_diff, pytest_args=pytest_args,
skip=skip, exclusive=exclusive,
experimental=experimental)
pool = Pool(min(len(models), os.cpu_count()))
pool = Pool(min(len(models), cpu_count()))
results = pool.map(partial_test_diff, model_and_model_ver_tuple)

for model_path, result in zip(models, results):
Expand Down

0 comments on commit 5887ccf

Please sign in to comment.