Skip to content

Commit

Permalink
Make sure we have the key
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed Sep 9, 2012
1 parent 728df59 commit 084262c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_zeyple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
from textwrap import dedent
from zeyple import zeyple

LINUS_ID = '79BE3E4300411886'

def is_encrypted(string):
return string.startswith(b'-----BEGIN PGP MESSAGE-----')

class ZeypleTest(unittest.TestCase):
def setUp(self):
shutil.copyfile('tests/zeyple.conf', 'zeyple.conf')
os.system("gpg --recv-keys %s 2> /dev/null" % LINUS_ID)
self.zeyple = zeyple.Zeyple()
self.zeyple._sendMessage = Mock() # don't try to send emails

Expand All @@ -33,18 +36,16 @@ def test__userKey(self):

self.assertIsNone(self.zeyple._userKey('non_existant@example.org'))

linus_id = "79BE3E4300411886"
os.system("gpg --recv-keys %s 2> /dev/null" % linus_id)
self.assertEqual(
self.zeyple._userKey('torvalds@linux-foundation.org'),
linus_id
LINUS_ID
)

def test__encrypt(self):
"""Encrypts plain text"""

encrypted = self.zeyple._encrypt(
'The key is under the carpet.', ['79BE3E4300411886']
'The key is under the carpet.', [LINUS_ID]
)
self.assertTrue(is_encrypted(encrypted))

Expand Down

0 comments on commit 084262c

Please sign in to comment.