本文整理汇总了Python中dvol.VoluminousOptions类的典型用法代码示例。如果您正苦于以下问题:Python VoluminousOptions类的具体用法?Python VoluminousOptions怎么用?Python VoluminousOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VoluminousOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_volume_already_exists
def test_create_volume_already_exists(self):
dvol = VoluminousOptions()
# Create the repository twice, second time should have the error
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
self.assertEqual(dvol.voluminous.getOutput()[-1],
"Error: volume foo already exists")
示例2: test_create_volume_already_exists
def test_create_volume_already_exists(self):
dvol = VoluminousOptions()
dvol.parseOptions(["-p", self.tmpdir.path, "init", "foo"])
self.assertRaises(VolumeAlreadyExists,
dvol.parseOptions, ["-p", self.tmpdir.path, "init", "foo"])
self.assertEqual(dvol.voluminous.getOutput(),
["Error: volume foo already exists"])
示例3: test_remove_volume_path_separator
def test_remove_volume_path_separator(self):
dvol = VoluminousOptions()
try:
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "rm", "-f", "foo/bar"])
output = dvol.voluminous.getOutput()[-1]
except CalledProcessErrorWithOutput, error:
output = error.original.output
示例4: test_list_empty_volumes
def test_list_empty_volumes(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "list"])
self.assertIn(
dvol.voluminous.getOutput()[-1].strip(),
" VOLUME BRANCH CONTAINERS"
)
示例5: test_create_volume
def test_create_volume(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
self.assertTrue(self.tmpdir.child("foo").exists())
self.assertTrue(self.tmpdir.child("foo").child("branches")
.child("master").exists())
self.assertEqual(dvol.voluminous.getOutput()[-1],
"Created volume foo\nCreated branch foo/master")
示例6: test_get_set_config
def test_get_set_config(self):
"""
A configuration key can be set and then retrieved.
"""
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "config", "user.name", "alice"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "config", "user.name"])
self.assertEqual(dvol.voluminous.getOutput()[-1],
"alice")
示例7: test_create_volume
def test_create_volume(self):
# TODO test volume names with '/' in them - they should not end up
# making nested heirarchy
dvol = VoluminousOptions()
dvol.parseOptions(["-p", self.tmpdir.path, "init", "foo"])
self.assertTrue(self.tmpdir.child("foo").exists())
self.assertTrue(self.tmpdir.child("foo").child("branches")
.child("master").exists())
self.assertEqual(dvol.voluminous.getOutput(),
["Created volume foo", "Created branch foo/master"])
示例8: test_branch_multi_volumes
def test_branch_multi_volumes(self, volumes):
"""
Always show the last checked-out branch for all volumes in ``list``.
"""
tmpdir = FilePath(self.mktemp())
tmpdir.makedirs()
dvol = VoluminousOptions()
for volume, branch in volumes:
dvol.parseOptions(ARGS + ["-p", tmpdir.path, "init", volume])
dvol.parseOptions(ARGS + ["-p", tmpdir.path, "commit", "-m", "hello"])
dvol.parseOptions(ARGS + ["-p", tmpdir.path, "checkout", "-b", branch])
dvol.parseOptions(ARGS + ["-p", tmpdir.path, "list"])
lines = dvol.voluminous.getOutput()[-1].split("\n")
header, rest = lines[0], lines[1:]
expected_volumes = [[volume, branch] for volume, branch in volumes]
# `init` activates the volume, so the last initialized volume is the
# active one.
expected_volumes[-1] = [
'*', expected_volumes[-1][0], expected_volumes[-1][1]]
self.assertEqual(['VOLUME', 'BRANCH', 'CONTAINERS'], header.split())
self.assertEqual(
sorted(expected_volumes),
sorted([line.split() for line in rest]),
)
示例9: test_log
def test_log(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"init", "foo"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"commit", "-m", "oi"])
first_commit = dvol.voluminous.getOutput()[-1]
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"commit", "-m", "you"])
second_commit = dvol.voluminous.getOutput()[-1]
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"log"])
actual = dvol.voluminous.getOutput()[-1]
expected = (
"commit {second_commit}\n"
"Author: Who knows <[email protected]>\n"
"Date: Whenever\n"
"\n"
" you\n"
"\n"
"commit {first_commit}\n"
"Author: Who knows <[email protected]>\n"
"Date: Whenever\n"
"\n"
" oi\n").format(
first_commit=first_commit,
second_commit=second_commit
)
expectedLines = expected.split("\n")
actualLines = actual.split("\n")
self.assertEqual(len(expectedLines), len(actualLines))
for expected, actual in zip(
expectedLines, actualLines):
self.assertTrue(actual.startswith(expected))
示例10: test_log
def test_log(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"init", "foo"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"commit", "-m", "oi"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"commit", "-m", "you"])
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"log"])
actual = dvol.voluminous.getOutput()[-1]
expected = (
"commit\n"
"Author:\n"
"Date:\n"
"\n"
" you\n"
"\n"
"commit\n"
"Author:\n"
"Date:\n"
"\n"
" oi\n")
expectedLines = expected.split("\n")
actualLines = actual.split("\n")
self.assertEqual(len(expectedLines), len(actualLines))
for expected, actual in zip(
expectedLines, actualLines):
self.assertTrue(actual.startswith(expected))
示例11: test_commit_no_message_raises_error
def test_commit_no_message_raises_error(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
try:
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "commit"])
# TODO assert exit code != 0
self.assertTrue(dvol.voluminous.getOutput()[-1].strip().endswith(
"You must provide a commit message"))
except UsageError:
# in non-out-of-process case, we'll get this exception. This is OK.
pass
示例12: test_switch_volume_does_not_exist
def test_switch_volume_does_not_exist(self):
"""
``dvol switch`` should give a meaningful error message if the
volume we try to switch to doesn't exist.
"""
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
try:
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "switch", "bar"])
except CalledProcessErrorWithOutput, error:
self.assertEqual(error.original.output.rstrip(), "Error: bar does not exist")
示例13: test_create_volume_already_exists
def test_create_volume_already_exists(self):
dvol = VoluminousOptions()
# Create the repository twice, second time should have the error
expected_output = "Error: volume foo already exists"
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
try:
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
self.assertEqual(dvol.voluminous.getOutput()[-1], expected_output)
except CalledProcessErrorWithOutput, error:
self.assertIn(expected_output, error.original.output)
self.assertTrue(error.original.returncode != 0)
示例14: test_commit_no_message_raises_error
def test_commit_no_message_raises_error(self):
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
# TODO after throwing away python version, make this test stricter
# about exit code != 0
try:
try:
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "commit"])
except CalledProcessErrorWithOutput, error: # go version
expected_output = "You must provide a commit message"
self.assertIn(expected_output, error.original.output)
self.assertTrue(error.original.returncode != 0)
except UsageError: # python version
# in non-out-of-process case, we'll get this exception. This is OK.
pass
示例15: test_commit_volume
def test_commit_volume(self):
# TODO need to assert that containers using this volume get stopped
# and started around commits
# TODO test snapshotting nonexistent volume
dvol = VoluminousOptions()
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path, "init", "foo"])
volume = self.tmpdir.child("foo")
volume.child("branches").child("master").child(
"file.txt").setContent("hello!")
dvol.parseOptions(ARGS + ["-p", self.tmpdir.path,
"commit", "-m", "hello from 30,000 ft"])
commitId = dvol.voluminous.getOutput()[-1]
commit = volume.child("commits").child(commitId)
self.assertTrue(commit.exists())
self.assertTrue(commit.child("file.txt").exists())
self.assertEqual(commit.child("file.txt").getContent(), "hello!")