~lifeless/storm/bug-620615

129 by Gustavo Niemeyer
Added LGPL version 2.1 in the LICENSE file, and a standard
1
#
2
# Copyright (c) 2006, 2007 Canonical
3
#
4
# Written by Gustavo Niemeyer <gustavo@niemeyer.net>
5
#
6
# This file is part of Storm Object Relational Mapper.
7
#
8
# Storm is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU Lesser General Public License as
10
# published by the Free Software Foundation; either version 2.1 of
11
# the License, or (at your option) any later version.
12
#
13
# Storm is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU Lesser General Public License for more details.
17
#
18
# You should have received a copy of the GNU Lesser General Public License
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
#
95.3.2 by Gustavo Niemeyer
Forgot to include base files.
21
import weakref
22
import gc
23
24
from storm.properties import Property, PropertyPublisherMeta
142.2.3 by Gustavo Niemeyer
- Finished implementation of the C version of ObjectInfo
25
from storm.info import get_obj_info
95.3.2 by Gustavo Niemeyer
Forgot to include base files.
26
from storm.base import *
27
28
from tests.helper import TestHelper
29
30
31
class BaseTest(TestHelper):
32
33
    def test_metaclass(self):
34
        class Class(Storm):
95.6.5 by Gustavo Niemeyer
- __storm_table__ now will *only* contain the table.
35
            __storm_table__ = "table_name"
36
            prop = Property(primary=True)
95.3.2 by Gustavo Niemeyer
Forgot to include base files.
37
        self.assertEquals(type(Class), PropertyPublisherMeta)
38
39
    def test_class_is_collectable(self):
40
        class Class(Storm):
95.6.5 by Gustavo Niemeyer
- __storm_table__ now will *only* contain the table.
41
            __storm_table__ = "table_name"
42
            prop = Property(primary=True)
95.3.2 by Gustavo Niemeyer
Forgot to include base files.
43
        obj = Class()
142.2.3 by Gustavo Niemeyer
- Finished implementation of the C version of ObjectInfo
44
        get_obj_info(obj) # Build all wanted meta-information.
95.3.2 by Gustavo Niemeyer
Forgot to include base files.
45
        obj_ref = weakref.ref(obj)
46
        del obj
47
        gc.collect()
48
        self.assertEquals(obj_ref(), None)