Beispiel #1
0
 def test_gravatar(self):
     dut = CommentHandler(CommentForm())
     self.assertEqual(dut.get_gravatar("*****@*****.**"),
                      "61f4730021b2869d7ad8babcfe790fbb")
     self.assertEqual(dut.get_gravatar("  [email protected]  "),
                      "61f4730021b2869d7ad8babcfe790fbb")
     self.assertEqual(dut.get_gravatar("[email protected]  "),
                      "61f4730021b2869d7ad8babcfe790fbb")
Beispiel #2
0
class TestKeyValidation(unittest.TestCase):
    def setUp(self):
        self.comment_form = CommentForm()
        self.dut = CommentHandler(self.comment_form)

    def test_valid_without_url(self):
        self.assertTrue(self.dut.validate_keys())

    def test_missing_key(self):
        self.comment_form.key_list.pop()
        self.assertFalse(self.dut.validate_keys())

    def test_valid_with_url(self):
        self.comment_form.key_list.append('url')
        self.assertTrue(self.dut.validate_keys())

    def test_extra_key(self):
        self.comment_form.key_list.append('extra')
        self.assertFalse(self.dut.validate_keys())
Beispiel #3
0
 def test_id(self):
     dut = CommentHandler(CommentForm())
     hash = sha256()
     dut.data['post_id'] = "test"
     hash.update("test".encode("utf-8"))
     dut.data['name'] = "Test User"
     hash.update("Test User".encode("utf-8"))
     dut.data['message'] = "Hello World!"
     hash.update("Hello World!".encode("utf-8"))
     date = datetime.now()
     dut.data['date'] = date
     hash.update(str(date).encode("utf-8"))
     self.assertEqual(dut.get_id(), hash.hexdigest())
Beispiel #4
0
 def test_simple_configuration(self):
     dut = CommentHandler(CommentForm(), "foo: bar")
     self.assertEqual(dut.config['foo'], 'bar')
Beispiel #5
0
 def test_with_redirect(self):
     dut = CommentHandler({'redirect': 'https://www.google.com/'})
     self.assertEqual(dut.get_redirect_url(), 'https://www.google.com/')
Beispiel #6
0
 def test_without_redirect(self):
     dut = CommentHandler(CommentForm())
     self.assertFalse(dut.get_redirect_url())
Beispiel #7
0
 def setUp(self):
     self.comment_form = CommentForm()
     self.dut = CommentHandler(self.comment_form)