Beispiel #1
0
    def test_comparison_operators(self):
        a = yogi.OperationId(4)
        b = yogi.OperationId(4)
        c = yogi.OperationId(1)

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

        self.assertFalse(a != b)
        self.assertTrue(a != c)
Beispiel #2
0
def test_comparison_operators():
    """Verifies that two OperationId instances can be compared for equality/non-equality"""
    a = yogi.OperationId(4)
    b = yogi.OperationId(4)
    c = yogi.OperationId(1)

    assert a == b
    assert not a == c

    assert not a != b
    assert a != c
Beispiel #3
0
    def test_from_value(self):
        oid = yogi.OperationId(5)
        self.assertEqual(oid.value, 5)
        self.assertTrue(oid.is_valid)

        oid = yogi.OperationId(0)
        self.assertEqual(oid.value, 0)
        self.assertFalse(oid.is_valid)

        oid = yogi.OperationId(-10)
        self.assertEqual(oid.value, -10)
        self.assertFalse(oid.is_valid)
Beispiel #4
0
def test_from_value():
    """Verifies that an OperationId can be constructed from a numeric value"""
    oid = yogi.OperationId(5)
    assert oid.value == 5
    assert oid.is_valid

    oid = yogi.OperationId(0)
    assert oid.value == 0
    assert not oid.is_valid

    oid = yogi.OperationId(-10)
    assert oid.value == -10
    assert not oid.is_valid
Beispiel #5
0
def test_cancel_send_broadcast(mocks: Mocks, branch: yogi.Branch):
    """Verifies that an asynchronous send broadcast operation can be cancelled"""
    def fn(branch, oid):
        assert branch == 8888
        assert oid == 111
        return yogi.ErrorCode.OK

    mocks.MOCK_BranchCancelSendBroadcast(fn)
    assert branch.cancel_send_broadcast(yogi.OperationId(111))

    def fn2(branch, oid):
        assert oid == 222
        return yogi.ErrorCode.INVALID_OPERATION_ID

    mocks.MOCK_BranchCancelSendBroadcast(fn2)
    assert not branch.cancel_send_broadcast(yogi.OperationId(222))
Beispiel #6
0
def test_hash():
    """Verifies that a hash can be computed for an OperationId"""
    a = yogi.OperationId(4)
    b = yogi.OperationId(7)
    assert hash(a) != hash(b)
Beispiel #7
0
 def test_hash(self):
     a = yogi.OperationId(4)
     b = yogi.OperationId(7)
     self.assertNotEqual(hash(a), hash(b))