def test_get_impl_uses_hash_from_algo(self): h = hashes.Hash("some algo", b"foo") with unittest.mock.patch( "aioxmpp.hashes.hash_from_algo") as hash_from_algo: impl = h.get_impl() hash_from_algo.assert_called_once_with(h.algo, ) self.assertEqual(impl, hash_from_algo())
def test_parse(self): t = hashes.HashType() h = hashes.Hash("fnord", b"baz") pair = t.parse(h) self.assertSequenceEqual(pair, ( "fnord", b"baz", ))
def test_init(self): h = hashes.Hash("algo", b"digest") self.assertEqual(h.algo, "algo") self.assertEqual(h.digest, b"digest")
def test_init_default(self): with self.assertRaises(TypeError): hashes.Hash()