def test_success(self):
     self.assertTrue(yogi.Success(1))
     self.assertTrue(yogi.Success(0))
     self.assertRaises(AssertionError, lambda: yogi.Success(-1))
     self.assertEqual(str(yogi.Success(1)), str(yogi.Result(1)))
     self.assertEqual(yogi.Success(1), yogi.Result(1))
     self.assertIsInstance(yogi.Success(1), yogi.Result)
 def test_failure(self):
     self.assertFalse(yogi.Failure(yogi.ErrorCode.BUSY))
     self.assertEqual(str(yogi.Failure(yogi.ErrorCode.BUSY)),
                      str(yogi.Result(yogi.ErrorCode.BUSY)))
     self.assertEqual(yogi.Failure(yogi.ErrorCode.BUSY),
                      yogi.Result(yogi.ErrorCode.BUSY))
     self.assertIsInstance(yogi.Failure(yogi.ErrorCode.BUSY), yogi.Result)
Ejemplo n.º 3
0
def test_success():
    """Checks the Success class"""
    assert yogi.Success(1)
    assert yogi.Success(0)
    assert str(yogi.Success(1)) == str(yogi.Result(1))
    assert yogi.Success(1) == yogi.Result(1)
    assert isinstance(yogi.Success(1), yogi.Result)
Ejemplo n.º 4
0
 def test_comparison(self):
     self.assertNotEqual(yogi.Success(), yogi.Result(123))
     self.assertEqual(yogi.Success(123), yogi.Result(123))
     self.assertEqual(yogi.Success(), yogi.Result(0))
Ejemplo n.º 5
0
 def test_comparison(self):
     self.assertNotEqual(yogi.Failure(-1), yogi.Result(1))
     self.assertEqual(yogi.Failure(-1), yogi.Result(-1))
Ejemplo n.º 6
0
 def test_comparison(self):
     self.assertNotEqual(self.okResult, self.idResult)
     self.assertEqual(self.idResult, yogi.Result(123))
Ejemplo n.º 7
0
 def setUp(self):
     self.okResult = yogi.Result(0)
     self.idResult = yogi.Result(123)
     self.errorResult = yogi.Result(-2)
 def test_result(self):
     self.assertFalse(yogi.Result(-1))
     self.assertFalse(yogi.Result(yogi.ErrorCode.BUSY))
     self.assertTrue(yogi.Result(0))
     self.assertTrue(yogi.Result(1))
     self.assertEqual(yogi.Result(10).value, 10)
     self.assertEqual(yogi.Result(3), yogi.Result(3))
     self.assertNotEqual(yogi.Result(2), yogi.Result(3))
     self.assertGreater(len(str(yogi.Result(yogi.ErrorCode.BUSY))), 5)
     self.assertNotEqual(hash(yogi.Result(1)), hash(yogi.Result(2)))
     self.assertIsInstance(
         yogi.Result(yogi.ErrorCode.BUSY).error_code, yogi.ErrorCode)
     self.assertEqual(yogi.Result(0).error_code, yogi.Result(1).error_code)
Ejemplo n.º 9
0
def test_failure():
    """Checks the Failure class"""
    assert not yogi.Failure(yogi.ErrorCode.BAD_ALLOC)
    assert str(yogi.Failure(yogi.ErrorCode.BAD_ALLOC)) == str(yogi.Result(yogi.ErrorCode.BAD_ALLOC))
    assert yogi.Failure(yogi.ErrorCode.BAD_ALLOC) == yogi.Result(yogi.ErrorCode.BAD_ALLOC)
    assert isinstance(yogi.Failure(yogi.ErrorCode.BAD_ALLOC), yogi.Result)
Ejemplo n.º 10
0
def test_result():
    """Checks the Result class"""
    assert not yogi.Result(-1)
    assert not yogi.Result(yogi.ErrorCode.BAD_ALLOC)
    assert yogi.Result(0)
    assert yogi.Result(1)
    assert yogi.Result(10).value == 10
    assert yogi.Result(3) == yogi.Result(3)
    assert yogi.Result(2) != yogi.Result(3)
    assert str(yogi.Result(yogi.ErrorCode.BAD_ALLOC)) == 'Dummy error string'
    assert hash(yogi.Result(1)) != hash(yogi.Result(2))
    assert isinstance(yogi.Result(yogi.ErrorCode.BAD_ALLOC).error_code, yogi.ErrorCode)
    assert yogi.Result(0).error_code == yogi.Result(1).error_code