Fix the defects the suite pinned; turn xfail/known_bug into regressions
The suite documented every defect with two `xfail` and four `test_known_bug_*` tests. With the tests as the specification, all of them are fixed and those tests are now regression tests that fail against the previous code: - findby_director() returned None on the success path (it printed the matches and fell off the end); it returns the rows now. - findby_actor() raised UnboundLocalError when no actor matched, and returned only the last article of an actor with several; it returns the list, or None. - findby_name() and findby_type() returned the integer 0 on no match, which main.py indexed into; they return an empty list and the menus skip it. - purchase() debited USERID (the account of the last log_in) instead of the userid argument, while the rent went to the argument. - the message list looked the author up with row[4] (the recipient) instead of row[5] (the sender), in the unread and in the read list. - remove_article() checked only the open rents, so the foreign keys on the older rents and on pricehistory turned the refusal into a traceback; it now explains which records keep the article and rolls back as a backstop. - show_unread_messages() returned None when there was nothing; it returns an empty list like the read side, and the messages menu skips an empty list. - database.USERID did not exist before a login, so leaving the menu with 0 raised AttributeError; it starts as None and the menu code handles 0. - every connection is opened and closed by one context manager: findby_director(), findby_actor() and findby_type() returned before conn.close() and statistics() never closed, leaving sessions `idle in transaction`. make test: 40 passed, 0 xfailed (was 30 passed, 2 xfailed). No xfail and no test_known_bug_* is left. The README's previous "what is broken" paragraph and its test output are updated, and a "Known limitations" section lists what was deliberately not touched: SQL built by string concatenation, menu selections past the end of the list, and input() inside the data layer.
This commit is contained in:
+524
-480
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user