add tests for Digest class
This commit is contained in:
parent
b37aa61c55
commit
84546757b6
|
@ -4,6 +4,10 @@ import unittest
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
|
||||||
|
|
||||||
|
BODY = b'{"@context":"https://www.w3.org/ns/activitystreams","id":"https://barkshark.xyz/3b49486e-d933-4e62-9c91-002ed901cc47","type":"Follow","actor":"https://barkshark.xyz/actor","object":"https://www.w3.org/ns/activitystreams#Public"}'
|
||||||
|
BODY_DIGEST = "SHA-256=NaQWaYfGtWY/aniiFBuMuASqbmGEes5vsPTFaRKuTGI="
|
||||||
|
|
||||||
|
|
||||||
class MiscTest(unittest.TestCase):
|
class MiscTest(unittest.TestCase):
|
||||||
def test_httpdate(self):
|
def test_httpdate(self):
|
||||||
output = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
|
output = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
|
||||||
|
@ -17,3 +21,15 @@ class MiscTest(unittest.TestCase):
|
||||||
data = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
|
data = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
|
||||||
|
|
||||||
self.assertEqual(output, data)
|
self.assertEqual(output, data)
|
||||||
|
|
||||||
|
|
||||||
|
def test_digest_create(self):
|
||||||
|
digest = aputils.Digest.new(BODY)
|
||||||
|
|
||||||
|
self.assertEqual(digest.compile(), BODY_DIGEST)
|
||||||
|
|
||||||
|
|
||||||
|
def test_digest_validate(self):
|
||||||
|
digest = aputils.Digest.new_from_digest(BODY_DIGEST)
|
||||||
|
|
||||||
|
self.assertTrue(digest.validate(BODY))
|
||||||
|
|
Loading…
Reference in a new issue