Changeset 442
- Timestamp:
- 01/07/09 16:45:21 (3 years ago)
- Location:
- elixir/trunk/tests
- Files:
-
- 10 modified
-
b.py (modified) (1 diff)
-
test_autoload.py (modified) (4 diffs)
-
test_collections.py (modified) (1 diff)
-
test_inherit.py (modified) (1 diff)
-
test_nestedclass.py (modified) (1 diff)
-
test_o2m.py (modified) (4 diffs)
-
test_options.py (modified) (2 diffs)
-
test_order_by.py (modified) (3 diffs)
-
test_packages.py (modified) (5 diffs)
-
test_perform_ddl.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/tests/b.py
r234 r442 3 3 class B(Entity): 4 4 name = Field(String(30)) 5 as_= OneToMany('tests.a.A')5 many_a = OneToMany('tests.a.A') 6 6 -
elixir/trunk/tests/test_autoload.py
r397 r442 5 5 from sqlalchemy import Table, Column, ForeignKey, MetaData 6 6 from elixir import * 7 from elixir import options # (not in __all__)8 7 import elixir 9 8 … … 147 146 grampa = Person.get_by(name="Abe") 148 147 149 print "Persons in the '%s' category: %s." % (150 c.name,151 ", ".join([p.name for p in c.persons]))152 153 148 assert len(c.persons) == 4 154 149 assert c in grampa.categories … … 167 162 assert homer in barney.isappreciatedby 168 163 164 # ---------------- 169 165 # overrides tests 166 # ---------------- 170 167 171 168 def test_override_pk_fails(self): … … 234 231 table = Table('father', local_meta, 235 232 Column('id', Integer, primary_key=True), 236 Column('row_type', options.POLYMORPHIC_COL_TYPE))233 Column('row_type', elixir.options.POLYMORPHIC_COL_TYPE)) 237 234 238 235 local_meta.create_all() -
elixir/trunk/tests/test_collections.py
r363 r442 68 68 class A(Entity): 69 69 name = Field(String(30)) 70 using_options( autosetup=False,tablename='a')70 using_options(tablename='a') 71 71 72 72 setup_all() -
elixir/trunk/tests/test_inherit.py
r433 r442 1 1 """ 2 simple test case2 test inheritance 3 3 """ 4 4 -
elixir/trunk/tests/test_nestedclass.py
r347 r442 18 18 class TestNestedClass(object): 19 19 def test_nestedclass(self): 20 21 print "GLOBALS", globals().keys()22 20 assert 'name' in Thing.table.columns.keys() 23 21 assert 'type' in Thing.table.columns.keys() -
elixir/trunk/tests/test_o2m.py
r438 r442 62 62 p = Person.get_by(name="Homer") 63 63 64 print "%s is %s's child." % (p.name, p.father.name)65 print "His children are: %s." % (66 " and ".join([c.name for c in p.children]))67 68 64 assert p in p.father.children 69 65 assert p.father is Person.get_by(name="Abe") … … 74 70 75 71 class TreeNode(Entity): 72 using_options(order_by='name') 76 73 name = Field(String(50), required=True) 77 74 … … 80 77 root = ManyToOne('TreeNode') 81 78 82 def __str__(self): 83 return self._getstring(0) 84 85 def _getstring(self, level): 86 s = ' ' * level + \ 87 "%s (%s,%s,%s, %d)" % (self.name, self.id, self.parent_id, 88 self.root_id, id(self)) + \ 89 '\n' 90 s += ''.join([n._getstring(level+1) for n in self.children]) 91 return s 92 93 setup_all(True) 94 95 node2 = TreeNode(name='node2') 96 node2.children.append(TreeNode(name='subnode1')) 97 node2.children.append(TreeNode(name='subnode2')) 98 node = TreeNode(name='rootnode') 99 node.children.append(TreeNode(name='node1')) 100 node.children.append(node2) 101 node.children.append(TreeNode(name='node3')) 79 setup_all(True) 80 81 root = TreeNode(name='rootnode') 82 root.children.append(TreeNode(name='node1', root=root)) 83 node2 = TreeNode(name='node2', root=root) 84 node2.children.append(TreeNode(name='subnode1', root=root)) 85 node2.children.append(TreeNode(name='subnode2', root=root)) 86 root.children.append(node2) 87 root.children.append(TreeNode(name='node3', root=root)) 102 88 103 89 session.commit() … … 105 91 106 92 root = TreeNode.get_by(name='rootnode') 107 print root 93 sub2 = TreeNode.get_by(name='subnode2') 94 assert sub2 in root.children[1].children 95 assert sub2.root == root 108 96 109 97 def test_viewonly(self): -
elixir/trunk/tests/test_options.py
r349 r442 13 13 14 14 def teardown(self): 15 cleanup_all( )15 cleanup_all(True) 16 16 17 17 # this test is a rip-off SQLAlchemy's activemapper's update test … … 22 22 using_options(version_id_col=True) 23 23 24 setup_all() 25 Person.table.create() 24 setup_all(True) 26 25 27 26 p1 = Person(name='Daniel') -
elixir/trunk/tests/test_order_by.py
r349 r442 66 66 records = Record.query.all() 67 67 68 print "-year, +title"69 for record in records:70 print record71 72 68 assert records[0].year == 2005 73 69 assert records[2].year >= records[5].year … … 77 73 def test_o2m_order_by(self): 78 74 records = Artist.get_by(name="Dream Theater").records 79 80 print "+year, -title"81 for record in records:82 print record83 75 84 76 assert records[0].year == 1989 … … 91 83 records = Genre.get_by(name="Progressive metal").records 92 84 93 print "-title"94 for record in records:95 print record96 97 85 assert records[0].year == 1989 98 86 assert records[2].title >= records[5].title -
elixir/trunk/tests/test_packages.py
r363 r442 9 9 def setup(): 10 10 metadata.bind = 'sqlite:///' 11 sys.modules.pop('tests.a', None) 12 sys.modules.pop('tests.b', None) 13 11 14 12 15 class TestPackages(object): 13 16 def teardown(self): 14 cleanup_all(True)15 16 def test_full_entity_path(self):17 17 # This is an ugly workaround because when nosetest is run globally (ie 18 18 # either on the tests directory or in the "trunk" directory, it imports … … 21 21 # calls cleanup_all(), so when we get here, A and B are already dead 22 22 # and reimporting their modules does nothing because they were already 23 # imported. 24 23 # imported. Additionally, if I remove the __init__.py file from the 24 # tests/ directory, nosetests doesn't import all modules, but does 25 # import a and b (probably because they are not prefixed with "test_"). 26 # the result is almost the same, even if less messy. 25 27 sys.modules.pop('tests.a', None) 26 28 sys.modules.pop('tests.b', None) 29 cleanup_all(True) 27 30 31 def test_full_entity_path(self): 28 32 from tests.a import A 29 33 from tests.b import B … … 31 35 setup_all(True) 32 36 33 b1 = B(name='b1', as_=[A(name='a1')])37 b1 = B(name='b1', many_a=[A(name='a1')]) 34 38 35 39 session.commit() … … 38 42 a = A.query.one() 39 43 40 assert a in a.b. as_44 assert a in a.b.many_a 41 45 42 46 def test_ref_to_imported_entity_using_class(self): 43 sys.modules.pop('tests.a', None)44 sys.modules.pop('tests.b', None)45 46 47 from tests.a import A 47 48 from tests.b import B … … 56 57 57 58 def test_ref_to_imported_entity_using_name(self): 58 sys.modules.pop('tests.a', None)59 sys.modules.pop('tests.b', None)60 61 59 from tests.a import A 62 60 from tests.b import B -
elixir/trunk/tests/test_perform_ddl.py
r411 r442 2 2 from elixir.ext.perform_ddl import perform_ddl, preload_data 3 3 4 4 5 def setup(): 5 6 metadata.bind = "sqlite:///" 7 6 8 7 9 class TestPerformDDL(object): … … 37 39 38 40 class TestPreloadData(object): 41 def teardown(self): 42 cleanup_all(True) 43 39 44 def test_several(self): 40 45 class Movie(Entity):
