-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from depaul-dice/feature-checkout
Checkout Feature for Sciunit Executions
- Loading branch information
Showing
5 changed files
with
272 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import absolute_import | ||
|
||
from sciunit2.command import AbstractCommand | ||
from sciunit2.command.context import CheckoutContext | ||
from sciunit2.exceptions import CommandLineError | ||
from sciunit2.util import quoted_format | ||
import sciunit2.core | ||
|
||
from getopt import getopt | ||
import sys | ||
|
||
|
||
class CheckoutCommand(AbstractCommand): | ||
name = 'checkout' | ||
|
||
@property | ||
def usage(self): | ||
return [('checkout <execution id>', | ||
"Checkout the execution of <execution id>")] | ||
|
||
def run(self, args): | ||
optlist, args = getopt(args, '') | ||
if len(args) != 1: | ||
raise CommandLineError | ||
with CheckoutContext(args[0]) as (pkgdir, _): | ||
return pkgdir | ||
|
||
def note(self, project_dir): | ||
return quoted_format('Checked out at: {0}\n', project_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import absolute_import | ||
|
||
from nose.tools import * | ||
import os | ||
import testpath | ||
|
||
from tests import testit | ||
|
||
|
||
class TestCheckout(testit.LocalCase): | ||
def test_all(self): | ||
with assert_raises(SystemExit) as r: | ||
testit.sciunit('checkout') | ||
assert_equal(r.exception.code, 2) | ||
|
||
with assert_raises(SystemExit) as r: | ||
testit.sciunit('checkout', '-i') | ||
assert_equal(r.exception.code, 2) | ||
|
||
with assert_raises(SystemExit) as r: | ||
testit.sciunit('checkout', 'e1') | ||
assert_equal(r.exception.code, 1) | ||
|
||
testit.sciunit('create', 'ok') | ||
|
||
with assert_raises(SystemExit) as r: | ||
testit.sciunit('checkout', 'asdf') | ||
assert_equal(r.exception.code, 1) | ||
|
||
with assert_raises(SystemExit) as r: | ||
testit.sciunit('checkout', 'e1') | ||
assert_equal(r.exception.code, 1) | ||
|
||
testit.sciunit('exec', 'pwd') | ||
testit.sciunit('checkout', 'e1') | ||
assert_true(os.path.isdir('tmp/ok/cde-package')) |