<commit_before>from nose.tools import *
import unittest

from cryptocoin import BitcoinKey

PASSPHRASE = '<PASSWORD>'
SECRET_EXPONENT = (
    '<KEY>'
)
PRIVATE_KEY = '<KEY>'
PUBLIC_KEY = (
    '04'  # First byte, per the Bitcoin specification
    '78d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'  # x
    'a1518063243acd4dfe96b66e3f2ec8013c8e072cd09b3834a19f81f659cc3455'  # y
)
ADDRESS = '1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T'


class KeyTestCase(unittest.TestCase):

    __test__ = False

    def test_passphrase(self):
        with assert_raises(AttributeError):
            _ = self.key.passphrase

    def test_secret_exponent(self):
        with assert_raises(AttributeError):
            _ = self.key.secret_exponent

    def test_private_key(self):
        with assert_raises(AttributeError):
            _ = self.key.private_key

    def test_address(self):
        assert_equal(
            self.key.address,
            ADDRESS,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            PUBLIC_KEY,
        )


@istest
class PassphraseTestCase(KeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(passphrase=PASSPHRASE)

    def test_passphrase(self):
        assert_equal(
            self.key.passphrase,
            PASSPHRASE,
        )

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            SECRET_EXPONENT,
        )

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            PRIVATE_KEY,
        )


@istest
class PrivateKeyTestCase(KeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(
            private_key=PRIVATE_KEY)

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            PRIVATE_KEY,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            PUBLIC_KEY,
        )

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            SECRET_EXPONENT,
        )


@istest
class SecretExponentTestCase(KeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(
            secret_exponent=SECRET_EXPONENT
        )

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            SECRET_EXPONENT,
        )

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            PRIVATE_KEY,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            PUBLIC_KEY,
        )<commit_msg>refactors tests to better support generic Key subclasses<commit_after>from nose.tools import *
import unittest

from cryptocoin import BitcoinKey


class KeyTestCase(unittest.TestCase):

    __test__ = False

    def test_passphrase(self):
        with assert_raises(AttributeError):
            _ = self.key.passphrase

    def test_secret_exponent(self):
        with assert_raises(AttributeError):
            _ = self.key.secret_exponent

    def test_private_key(self):
        with assert_raises(AttributeError):
            _ = self.key.private_key

    def test_address(self):
        assert_equal(
            self.key.address,
            self.ADDRESS,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            self.PUBLIC_KEY,
        )


class BitcoinKeyTestCase(KeyTestCase):
    __test__ = False

    PASSPHRASE = 'correct horse battery staple'
    SECRET_EXPONENT = (
        '<KEY>'
    )
    PRIVATE_KEY = '<KEY>'
    PUBLIC_KEY = (
        '04'  # First byte, per the Bitcoin specification
        '78d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'  # x
        'a1518063243acd4dfe96b66e3f2ec8013c8e072cd09b3834a19f81f659cc3455'  # y
    )
    ADDRESS = '1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T'


@istest
class PassphraseTestCase(BitcoinKeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(passphrase=self.PASSPHRASE)

    def test_passphrase(self):
        assert_equal(
            self.key.passphrase,
            self.PASSPHRASE,
        )

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            self.SECRET_EXPONENT,
        )

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            self.PRIVATE_KEY,
        )


@istest
class PrivateKeyTestCase(BitcoinKeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(private_key=self.PRIVATE_KEY)

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            self.PRIVATE_KEY,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            self.PUBLIC_KEY,
        )

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            self.SECRET_EXPONENT,
        )


@istest
class SecretExponentTestCase(BitcoinKeyTestCase):
    def setUp(self):
        self.key = BitcoinKey(secret_exponent=self.SECRET_EXPONENT)

    def test_secret_exponent(self):
        assert_equal(
            self.key.secret_exponent,
            self.SECRET_EXPONENT,
        )

    def test_private_key(self):
        assert_equal(
            self.key.private_key,
            self.PRIVATE_KEY,
        )

    def test_public_key(self):
        assert_equal(
            self.key.public_key,
            self.PUBLIC_KEY,
        )
{'fraction_non_alphanumeric': 0.07682596934174932, 'fraction_numerical': 0.03318304779080253, 'mean_word_length': 2.124507042253521, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1257451', 'n_tokens_mistral': 1950, 'n_tokens_neox': 1811, 'n_words': 264}