Exemplo n.º 1
0
 def test_add_object_WHEN_connection_AND_add_multi_THEN_returns_id(self):
     with mock_database.Database():
         ob_id = db_func.add_object("test1", 0)
         self.assertEqual(ob_id, 1)
         self.assertIsNotNone(db_func.get_object(ob_id))
         self.assertIsNotNone(db_func.get_object_id("test1"))
         ob_id = db_func.add_object("test2", 0)
         self.assertEqual(ob_id, 2)
         self.assertIsNotNone(db_func.get_object(ob_id))
         self.assertIsNotNone(db_func.get_object_id("test2"))
Exemplo n.º 2
0
 def test_add_object_WHEN_connection_AND_comment_THEN_has_comment(self):
     with mock_database.Database():
         ob_id = db_func.add_object("test1", 0, 0, "test_comment")
         self.assertEqual(ob_id, 1)
         self.assertIsNotNone(db_func.get_object(ob_id))
         self.assertIsNotNone(db_func.get_object_id("test1"))
         self.assertEqual(db_func.get_object(1).ob_comment, "test_comment")
Exemplo n.º 3
0
 def test_add_object_WHEN_connection_AND_valid_display_group_THEN_object_added_AND_has_display_group(
         self):
     with mock_database.Database():
         mock_database.GamDisplaygroup.create(dg_name="test2")
         ob_id = db_func.add_object("test1", 0, 1)
         self.assertEqual(ob_id, 1)
         self.assertIsNotNone(db_func.get_object(ob_id))
         self.assertIsNotNone(db_func.get_object_id("test1"))
         self.assertEqual(db_func.get_object_display_group(ob_id), "test2")
Exemplo n.º 4
0
 def test_add_object_WHEN_connection_AND_valid_type_THEN_object_added_AND_has_type(
         self):
     with mock_database.Database():
         mock_database.GamObjecttype.create(ot_name="test2",
                                            ot_objectclass=0)
         ob_id = db_func.add_object("test1", 1)
         self.assertEqual(ob_id, 1)
         self.assertIsNotNone(db_func.get_object(ob_id))
         self.assertIsNotNone(db_func.get_object_id("test1"))
         self.assertEqual(db_func.get_object_type(ob_id), "test2")
Exemplo n.º 5
0
 def test_get_object_id_WHEN_multiple_present_THEN_returns_lowest_id(self):
     with mock_database.Database():
         obj = mock_database.GamObject.create(ob_name="test",
                                              ob_objecttype=1)
         mock_database.GamObject.create(ob_name="test", ob_objecttype=1)
         self.assertEqual(db_func.get_object_id("test"), obj.ob_id)
Exemplo n.º 6
0
 def test_create_module_if_required_WHEN_connection_AND_module_not_required_THEN_no_module(
         self):
     with mock_database.Database():
         db_func.create_module_if_required(1, "test1", "test2", 1)
         self.assertIsNone(mock_database.GamObjectrelation.get_or_none(1))
         self.assertIsNone(db_func.get_object_id("SLD \"test1\" (ID: 1)"))
Exemplo n.º 7
0
 def test_get_object_id_WHEN_not_present_THEN_returns_none(self):
     with mock_database.Database():
         mock_database.GamObject.create(ob_name="test1", ob_objecttype=1)
         self.assertIsNone(db_func.get_object_id("test"))
Exemplo n.º 8
0
 def test_get_object_id_WHEN_no_connection_THEN_returns_none(self):
     self.assertIsNone(db_func.get_object_id("test"))