Ejemplo n.º 1
0
 def test_stored_and_found_objects_are_same_object(self):
     db = Database()
     object_1 = DatabaseObject(1)
     object_1.name = "Random Object Name"
     db.store(object_1)
     object_2 = db.find(1)
     object_2.name = "Specific name"
     self.assertEqual(object_1.name, object_2.name)
     self.assertEqual(object_1.name, 'Specific name')
Ejemplo n.º 2
0
 def test_old_db_is_overwritten(self):
     db = Database()
     pre_object = DatabaseObject(2)
     pre_object.name = "Michael"
     db.store(pre_object)
     db.store(DatabaseObject(5))
     persistance = DatabasePersister(self.file_name)
     persistance.dump(db)
     persistance = DatabasePersister(self.file_name)
     db = persistance.load()
     self.assertIsNone(db.find(1))
Ejemplo n.º 3
0
    def test_persistance_between_dump_load(self):
        db = Database()
        pre_object = DatabaseObject(1)
        pre_object.name = "Michael"
        db.store(pre_object)
        persistance = DatabasePersister(self.file_name)

        persistance.dump(db)
        db = persistance.load()
        object = db.find(1)
        self.assertEqual(object.ref, 1)
        self.assertEqual(object.name, 'Michael')
Ejemplo n.º 4
0
    def test_persistance_of_object_structure_data(self):
        db = Database()
        pre_object = DatabaseObject(1)
        pre_object.name = "Michael"
        pre_object.type = DB_TYPE_PLAYER

        db.store(pre_object)
        persistance = DatabasePersister(self.file_name)
        persistance.dump(db)
        db = persistance.load()
        object = db.find(1)
        self.assertEqual(object.name, 'Michael')
        self.assertEqual(object.type, DB_TYPE_PLAYER)
Ejemplo n.º 5
0
 def test_has_property_method(self):
     object = DatabaseObject(1)
     self.assertIsNotNone(object.get_property('created'))
Ejemplo n.º 6
0
 def test_cannot_change_reference(self):
     object_1 = DatabaseObject(1)
     with self.assertRaises(AttributeError):
         object_1.ref = 5