Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv570/Modeling/tests
Modified Files:
run.py
Added Files:
test_dynamic.py
Log Message:
Fixed bug #981123 reported by Ernesto Revilla: dynamic.build() now accepts PyModels
In the same method: also fixed the generated module's '__name__', and added attribute '__module__' to the generated classes
--- NEW FILE: test_dynamic.py ---
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
#-----------------------------------------------------------------------------
# Modeling Framework: an Object-Relational Bridge for python
#
# Copyright (c) 2001-2004 Sébastien Bigaret <sbi...@us...>
# All rights reserved.
#
# This file is part of the Modeling Framework.
#
# This code is distributed under a "3-clause BSD"-style license;
# see the LICENSE file for details.
#-----------------------------------------------------------------------------
"""
Tests for module delegation
CVS Information
$Id: test_dynamic.py,v 1.1 2004/11/24 15:11:19 sbigaret Exp $
"""
__version__= '$Revision: 1.1 $'[11:-2]
import unittest
if __name__ == "__main__":
import utils, sys
utils.fixpath()
from Modeling import dynamic
def sample_pymodel(modelname):
"Builds a sample pymodel"
from Modeling.PyModel import Model, Entity, AString
pymodel=Model(modelname) # a PyModel.Model
pymodel.version='0.1' # This is mandatory!!
e=Entity("Person",properties=[AString("name")])
pymodel.entities.append(e)
return pymodel
class TestDynamic(unittest.TestCase):
"Tests for module dynamic"
def test_01_build_accepts_pymodel(self):
"[dynamic] build() accepts PyModels - bug #981123"
pymodel=sample_pymodel("TestDynamic_test_01_pymodel_a")
dynamic.build(pymodel) # should not fail
import TestDynamic_test_01_pymodel_a
self.failUnless(TestDynamic_test_01_pymodel_a.Person)
# an already built pymodel should be ok as well
pymodel=sample_pymodel("TestDynamic_test_01_pymodel_b")
pymodel.build()
dynamic.build(pymodel) # should not fail
import TestDynamic_test_01_pymodel_b
self.failUnless(TestDynamic_test_01_pymodel_b.Person)
# Build the test suite
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDynamic, "test_"))
return suite
if __name__ == "__main__":
errs = utils.run_suite(test_suite())
sys.exit(errs and 1 or 0)
Index: run.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/run.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** run.py 21 Sep 2004 18:03:27 -0000 1.12
--- run.py 24 Nov 2004 15:11:19 -0000 1.13
***************
*** 59,62 ****
--- 59,64 ----
import test_SchemaGeneration
+ import test_dynamic
+
def usage(prgName, exitStatus=None):
_usage="""%s [-v] [-V]
***************
*** 105,108 ****
--- 107,111 ----
suite.addTest(test_SQLExpression.test_suite())
suite.addTest(test_SchemaGeneration.test_suite())
+ suite.addTest(test_dynamic.test_suite())
# global
if global_tests:
|