summaryrefslogtreecommitdiff
path: root/tests/test_message.py
blob: 025c3c4b29c17991ed02b3aae935e6f5ceade3ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from memoryhole import message

import pytest


def test_protection_level():
    pl0 = message.ProtectionLevel(signed_by=['alice'], encrypted_by=['alice'])
    pl1 = message.ProtectionLevel(signed_by=['alice'])
    pl2 = message.ProtectionLevel(encrypted_by=['alice'])
    pl3 = message.ProtectionLevel()
    assert pl0 > pl1
    assert pl1 > pl2
    assert pl2 > pl3
    assert pl0 == pl0
    assert pl1 == pl1
    assert pl2 == pl2
    assert pl2 < pl1
    assert pl1 < pl0


def test_compare_wrong_types():
    pl0 = message.ProtectionLevel(signed_by=['alice'])
    with pytest.raises(TypeError):
        assert pl0 > 1