Esempio 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"))
Esempio 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")
Esempio 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")
Esempio 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")
Esempio n. 5
0
 def test_add_object_WHEN_connection_AND_already_exists_THEN_exception(
         self):
     with mock_database.Database():
         mock_database.GamObject.create(ob_name="test1", ob_objecttype=0)
         with self.assertRaises(db_func.DBObjectNameAlreadyExists):
             db_func.add_object("test1", 0)
Esempio n. 6
0
 def test_add_object_WHEN_no_connection_THEN_returns_none(self):
     self.assertIsNone(db_func.add_object("test1", 0))