~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testgpg.py

  • Committer: Robert Collins
  • Date: 2005-10-17 08:15:09 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051017081509-f108fef422640aba
gpg signing of content

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import sys
23
23
 
 
24
import bzrlib.errors as errors
24
25
import bzrlib.gpg as gpg
25
26
from bzrlib.selftest import TestCase, TestCaseInTempDir
26
27
 
27
28
class FakeConfig(object):
28
29
 
29
30
    def gpg_signing_command(self):
30
 
        return "gnome-gpg"
 
31
        return "false"
31
32
        
32
33
 
33
34
class TestCommandLine(TestCase):
34
35
 
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())
 
40
 
 
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')
 
46
 
 
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"))