nah it works, its essentially decorating the execute() process of the
db engine. The test suite hands it a list of SQL statements and
parameter lists to verify, and the list is set as an attribute on the
test wrapper, which it pops from each time a new statement comes in.
when the test is complete the list of conditions is removed.
To illustrate, try out:
python test/objectstore.py SaveTest.testbackwardsonetoone
its going to test, on the next three engine.execute() calls, for
these statements:
(
"INSERT INTO users (user_name) VALUES
(:user_name)",
{'user_name': 'imnewlyadded'}
),
(
"UPDATE email_addresses SET
email_address=:email_address WHERE email_addresses.address_id
= :email_addresses_address_id",
lambda: [{'email_address': '[EMAIL PROTECTED]',
'email_addresses_address_id': objects[2].address_id}]
),
(
"UPDATE email_addresses SET user_id=:user_id
WHERE email_addresses.address_id = :email_addresses_address_id",
lambda: [{'user_id': objects[3].user.user_id,
'email_addresses_address_id': objects[3].address_id}]
),
the second parameter in each tuple is the parameter list. if its a
lambda:, its going to execute the lambda to produce the desired
parameter list; this is used to anticipate data which was just
created, such as the user_id on a newly inserted user object.
youll notice if you change the text of any of the above SQL
statements, the unit test will then fail, showing you just what
expected statement didnt match.
the above list also has a corresponding list called "with_sequences",
which is executed for databases that explicitly insert the primary
key column from a sequence, which are currently postgres and oracle.
On Jan 13, 2006, at 3:40 AM, Robin Munn wrote:
I've been looking into SQLAlchemy's test suite, and I think I've found
a bug in the test suite, which may be causing some tests not to be
run.
In test/testbase.py, the EngineAssert class has a post_exec() function
that looks like it's supposed to run through a list of assertions and
check each one against the actual SQL that was executed. But the
function contains not a single while statement! As it's written, it
will only check the first assertion in self.assert_list, instead of
all of them.
I think that line 113, "if self.assert_list is not None:", should have
been "while self.assert_list:". (That's line 113 as of SVN revision
817). That would allow the entire assertion list to get checked.
Either that, or I'm misunderstanding the purpose of
EngineAssert.post_exec(). That's always possible as well... :-)
--
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through
log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users