def test_guarantee_object_id_typeerror(self): """Test that `guarantee_object_id()` raises `TypeError`.""" with self.assertRaises(TypeError): guarantee_object_id(1) with self.assertRaises(TypeError): guarantee_object_id([AN_OBJECT_ID_STR])
def test_guarantee_object_id(self): """Test the `guarantee_object_id()` method.""" expected = AN_OBJECT_ID actual = guarantee_object_id(AN_OBJECT_ID_STR) self.assertEqual(actual, expected)
def test_guarantee_object_id_tuple(self): """Test the `guarantee_object_id()` method with a `tuple`.""" expected = { '$in': [AN_OBJECT_ID, AN_OBJECT_ID], } actual = guarantee_object_id({ '$in': (AN_OBJECT_ID_STR, AN_OBJECT_ID), }) self.assertEqual(actual, expected)
def test_guarantee_object_id_dict(self): """Test the `guarantee_object_id()` method with `dict`.""" expected = { '$gt': AN_OBJECT_ID, '$lt': AN_OBJECT_ID, } actual = guarantee_object_id({ '$gt': AN_OBJECT_ID_STR, '$lt': AN_OBJECT_ID, }) self.assertEqual(actual, expected)
def test_guarantee_object_id_invalidid(self): """Test that `guarantee_object_id()` raises `InvalidId`.""" with self.assertRaises(InvalidId): guarantee_object_id('abc')