示例#1
0
    def test_comparison_operators_msgpack_view(self):
        view = yogi.PayloadView(yogi.MsgpackView([1]))
        a = yogi.MsgpackView([1])
        b = yogi.MsgpackView([2])

        self.assertTrue(view == a)
        self.assertFalse(view == b)

        self.assertFalse(view != a)
        self.assertTrue(view != b)
示例#2
0
    def test_comparison_operators(self):
        a = yogi.MsgpackView([1])
        b = yogi.MsgpackView([1])
        c = yogi.MsgpackView([2])

        self.assertTrue(a == b)
        self.assertFalse(a == c)

        self.assertFalse(a != b)
        self.assertTrue(a != c)
def test_comparison_operators():
    """Checks the equal and non-equal comparison operators"""
    a = yogi.MsgpackView([1])
    b = yogi.MsgpackView([1])
    c = yogi.MsgpackView([2])

    assert a == b
    assert not a == c

    assert not a != b
    assert a != c
def test_comparison_operators_msgpack_view():
    """Verifies that a PayloadView instance can be compared to a MsgpackView for equality"""
    view = yogi.PayloadView(yogi.MsgpackView([1]))
    a = yogi.MsgpackView([1])
    b = yogi.MsgpackView([2])

    assert view == a
    assert not view == b

    assert not view != a
    assert view != b
 def setUp(self):
     self.context = yogi.Context()
     self.json_view = yogi.JsonView("[1,2,3]")
     self.big_json_view = yogi.JsonView(self.make_big_json_data())
     self.msgpack_view = yogi.MsgpackView(bytes([0x93, 0x1, 0x2, 0x3]))
def test_hash():
    """Verifies that a hash can be computed over the MsgpackView"""
    a = yogi.MsgpackView([1])
    b = yogi.MsgpackView([2])
    assert hash(a) != hash(b)
def test_len_operator():
    """Verifies that len() returns a sensible value"""
    view = yogi.MsgpackView([1, 2, 3])
    assert len(view) == view.size
def test_from_object():
    """Verifies that a MsgpackView can be constructed from an object"""
    view = yogi.MsgpackView([1, 2])
    assert view.data, bytes([0x92, 0x1 == 0x2])
    assert view.size == 3
def test_from_bytes():
    """Verifies that a MsgpackView can be constructed from bytes"""
    view = yogi.MsgpackView(bytes([0x92, 0x1, 0x2]))
    assert view.data, bytes([0x92, 0x1 == 0x2])
    assert view.size == 3
def test_from_msgpack_view():
    """Verifies that a payload can be constructed from a MsgpackView"""
    mp = yogi.MsgpackView([1, 2])
    view = yogi.PayloadView(mp)
    assert view.data == mp.data
    assert view.size == mp.size
示例#11
0
 def test_len_operator(self):
     view = yogi.MsgpackView([1, 2, 3])
     self.assertEqual(len(view), view.size)
示例#12
0
 def test_from_msgpack_view(self):
     mp = yogi.MsgpackView([1, 2])
     view = yogi.PayloadView(mp)
     self.assertEqual(view.data, mp.data)
     self.assertEqual(view.size, mp.size)
示例#13
0
 def test_hash(self):
     a = yogi.MsgpackView([1])
     b = yogi.MsgpackView([2])
     self.assertNotEqual(hash(a), hash(b))
示例#14
0
 def test_from_object(self):
     view = yogi.MsgpackView([1, 2])
     self.assertEqual(view.data, bytes([0x92, 0x1, 0x2]))
     self.assertEqual(view.size, 3)