# Path: tsukiji/crypto.py
# KEYFILE_NAME = 'key.pem'
# def create_key():
# def retrieve_key():
# def get_public_bytestring():
# def decrypt_message(message):
# def encrypt_message(key_string, message):


import unittest
import os
import errno
from nose.tools import assert_equal
from tsukiji import crypto as cr
    try:
        os.remove(filename)
    except OSError as e:
        if e.errno != errno.ENOENT:
            raise


class CryptoTest(unittest.TestCase):
    '''
    Test crypto functions.

    Since crypto is essentially just a wrapper around the PyCrypto library, we will not test this module extensively.
    '''
    def test_create_key(self):
        silentremove('key.pem')
        cr.create_key()
        assert os.path.isfile('key.pem')

    def test_retrieve_key_does_not_exist_yet(self):
        silentremove('key.pem')
        cr.retrieve_key()
        assert os.path.isfile('key.pem')

    def test_retrieve_key(self):
        cr.retrieve_key()
        assert os.path.isfile('key.pem')

    def test_encrypt_decrypt_message(self):
        message = "Hello, world"
        encrypted_message = cr.encrypt_message(cr.get_public_bytestring(), message)

# Path: tsukiji/crypto.py
# KEYFILE_NAME = 'key.pem'
# def create_key():
# def retrieve_key():
# def get_public_bytestring():
# def decrypt_message(message):
# def encrypt_message(key_string, message):


# Path: tests/test_crypto.py
import unittest
import os
import errno
from nose.tools import assert_equal
from tsukiji import crypto as cr

    try:
        os.remove(filename)
    except OSError as e:
        if e.errno != errno.ENOENT:
            raise


class CryptoTest(unittest.TestCase):
    '''
    Test crypto functions.

    Since crypto is essentially just a wrapper around the PyCrypto library, we will not test this module extensively.
    '''
    def test_create_key(self):
        silentremove('key.pem')
        cr.create_key()
        assert os.path.isfile('key.pem')

    def test_retrieve_key_does_not_exist_yet(self):
        silentremove('key.pem')
        cr.retrieve_key()
        assert os.path.isfile('key.pem')

    def test_retrieve_key(self):
        cr.retrieve_key()
        assert os.path.isfile('key.pem')

    def test_encrypt_decrypt_message(self):
        message = "Hello, world"
        encrypted_message = cr.encrypt_message(cr.get_public_bytestring(), message)

        decrypted_message = cr.decrypt_message(encrypted_message)