2017-08-19 15:36:55 +00:00
|
|
|
# coding=utf-8
|
|
|
|
"""Unit tests for models.py."""
|
2017-08-19 19:36:36 +00:00
|
|
|
from __future__ import unicode_literals
|
2017-08-19 15:36:55 +00:00
|
|
|
|
|
|
|
import models
|
2017-08-24 06:24:47 +00:00
|
|
|
import testutil
|
2017-08-19 15:36:55 +00:00
|
|
|
|
|
|
|
|
2017-08-24 06:24:47 +00:00
|
|
|
class ModelsTest(testutil.TestCase):
|
2017-08-19 15:36:55 +00:00
|
|
|
|
|
|
|
def test_magic_key_get_or_create(self):
|
|
|
|
key = models.MagicKey.get_or_create('x@y.z')
|
|
|
|
assert key.mod
|
|
|
|
assert key.public_exponent
|
|
|
|
assert key.private_exponent
|
|
|
|
|
|
|
|
same = models.MagicKey.get_or_create('x@y.z')
|
|
|
|
self.assertEquals(same, key)
|
2017-08-19 16:15:29 +00:00
|
|
|
|
|
|
|
def test_href(self):
|
|
|
|
key = models.MagicKey.get_or_create('x@y.z')
|
|
|
|
href = key.href()
|
|
|
|
self.assertTrue(href.startswith('data:application/magic-public-key,RSA.'), href)
|
|
|
|
self.assertIn(key.mod, href)
|
|
|
|
self.assertIn(key.public_exponent, href)
|