24
import bzrlib.errors as errors
24
25
import bzrlib.gpg as gpg
25
26
from bzrlib.selftest import TestCase, TestCaseInTempDir
27
28
class FakeConfig(object):
29
30
def gpg_signing_command(self):
33
34
class TestCommandLine(TestCase):
35
36
def test_signing_command_line(self):
36
37
my_gpg = gpg.GPGStrategy(FakeConfig())
37
self.assertEqual('gnome-gpg --clearsign',
38
self.assertEqual(['false', '--clearsign'],
38
39
my_gpg._command_line())
41
def test_checks_return_code(self):
42
# This test needs a unix like platform - one with 'false' to run.
43
# if you have one, please make this work :)
44
my_gpg = gpg.GPGStrategy(FakeConfig())
45
self.assertRaises(errors.SigningFailed, my_gpg.sign, 'content')
47
def test_returns_output(self):
48
# This test needs a 'cat' command or similar to work.
49
my_gpg = gpg.GPGStrategy(FakeConfig())
50
my_gpg._command_line = lambda:["cat", "-"]
51
self.assertEqual("some content\nwith newlines\n",
52
my_gpg.sign("some content\nwith newlines\n"))