Update of /cvsroot/webware/Webware/MiddleKit/Tests/MKClone.mkmodel
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27431
Added Files:
Classes.csv Settings1.config Settings2.config TestEmpty.py
Log Message:
Added test case for clone functionality.
--- NEW FILE: Classes.csv ---
Class,Attribute,Type,Default,Min,Max,Extras,Copy
Book,,,,,,,
,title,string,,0,100,,
,authors,"list of Wrote",,,,,deep
,loans,"list of Loan",,,,,none
,shelf,Shelf,,,,,shallow
,publisher,string,,0,100,,
,,,,,,,
Wrote,,,,,,,
,book,Book,,,,,deep
,author,Author,,,,,shallow
,,,,,,,
Author,,,,,,,
,name,string,,0,100,,
,wrote,"list of Wrote",,,,,
,,,,,,,
Loan,,,,,,,
,book,Book,,,,,
,borrower,string,,0,100,,
,,,,,,,
Shelf,,,,,,,
,name,string,,0,100,,
--- NEW FILE: Settings1.config ---
{
'UseBigIntObjRefColumns': False,
#'SQLLog': { 'File': 'stdout', },
}
--- NEW FILE: Settings2.config ---
{
'UseBigIntObjRefColumns': True,
'SQLSerialColumnName': '%(className)sId',
}
--- NEW FILE: TestEmpty.py ---
def test(store):
from Book import Book
from Author import Author
from Loan import Loan
from Wrote import Wrote
from Shelf import Shelf
classics = Shelf()
classics.setName('Classics')
store.addObject(classics)
store.saveChanges()
ed = Author()
ed.setName('Edmund Wells')
david = Book()
wrote = Wrote()
ed.addToWrote(wrote)
david.addToAuthors(wrote)
david.setTitle('David Coperfield')
david.setPublisher('Monty Python')
loan = Loan()
loan.setBorrower('A. Git')
david.addToLoans(loan)
david.setShelf(classics)
store.addObject(david)
store.saveChanges()
# create a clone of the book and associated objects
grate = david.clone()
grate.setTitle('Grate Expections')
store.addObject(grate)
store.saveChanges()
assert david is not grate
assert len(grate.authors()) == 1
assert david.authors()[0] is not grate.authors()[0]
assert grate.authors()[0].author() is ed
assert len(grate.loans()) == 0
assert grate.shelf() is david.shelf()
assert grate.publisher() == 'Monty Python'
|