Commit Graph
55 Commits
Author SHA1 Message Date
Andre Neto bfd711271b Add MIT LICENSE (first commit year 2020) and point the README section to it
O repo era publico e espelhado sem licenca: sem LICENSE os direitos ficam
reservados e ninguem pode reutilizar o codigo. MIT foi a licenca decidida para
o catalogo; o ano do copyright e o do primeiro commit, nao o de hoje.
2026-10-08 14:53:34 +01:00
Andre Neto db490b0354 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.
2026-10-08 14:38:11 +01:00
Andre Neto 4ef5a67343 Add the schema, the dependencies and an end-to-end test suite
The schema existed only inside the queries, so a clean clone could not run:
nothing created the tables that database.py and main.py expect, and there was
no declaration of what to install.

- schema.sql: the seven tables, their primary and foreign keys, and the
  administrator the code requires. Reconstructed from the SQL the code issues
  and typed for it: the code reads rows by position (SELECT *), so the column
  order is part of the contract, and users.userid has to be a 4-byte integer
  because message_all() counts rows with pg_column_size(userid)/4.
- scripts/db.py, Makefile, docker-compose.yml: a throwaway PostgreSQL and the
  targets up/schema/seed/run/test/down. Both passwords come from the
  environment (NETFLOX_DB_PASSWORD, NETFLOX_DEMO_PASSWORD); nothing is stored
  in the repository, and schema.sql receives the administrator password
  through a session setting.
- requirements.txt and requirements-dev.txt: psycopg2-binary, plus pytest for
  the suite.
- tests/: 30 end-to-end tests that recreate the schema and drive the real
  functions of database.py. They check the column order and the keys against
  information_schema and walk every main flow. The defects found while mapping
  the code are pinned by test_known_bug_* and xfail instead of fixed, since
  fixing the application was not part of this change. The suite also guards the
  credential fix: database.py must refuse to import without its variable and no
  tracked file may contain the value.
- README.md: the sections shared with the other repositories, with a real
  session.
- The report moved to docs/relatorio-BD.pdf: it had accents and spaces in the
  filename.
2026-10-08 14:26:47 +01:00
Andre Neto c2a253071e Netflox: read DB password from env; stop tracking archive with old password
database.py had the PostgreSQL password in plain text (inline literal repeated
in every psycopg2.connect call). It now reads NETFLOX_DB_PASSWORD once at
import time and raises RuntimeError if it is unset, so there is no default.

The committed Projeto_Netflox_*.zip embeds the same database.py and therefore
still carries the old password, so it is removed from the index
(git rm --cached; the file stays on disk outside the working tree). README.md
documents the env var and the archive removal.

Why: the credential must not live in the repository. The value is still in the
history and in any clone/cache, so it must be rotated.
2026-10-08 14:03:21 +01:00
alexalmeida2001 9177ffb7e9 Add files via upload 2020-12-12 21:58:55 +00:00
alexalmeida2001 8074252074 Add files via upload 2020-12-12 21:56:44 +00:00
agsNeto20 22dd6968d9 Add files via upload 2020-12-12 13:40:18 +00:00
agsNeto20 b19b0f3fdb Delete main.py 2020-12-12 13:40:07 +00:00
agsNeto20 32877ad278 Delete database.py 2020-12-12 13:36:46 +00:00
agsNeto20 dced1e0d7e Add files via upload 2020-12-12 06:31:39 +00:00
agsNeto20 64ab222151 Delete ernetflox.json 2020-12-12 06:28:21 +00:00
agsNeto20 40155dd2b3 Delete sqlfinal.sql 2020-12-12 06:25:19 +00:00
agsNeto20 566c211785 Delete main.py 2020-12-12 06:25:12 +00:00
agsNeto20 b76cce566c Delete database.py 2020-12-12 06:25:04 +00:00
agsNeto20 303e1b2fc7 Update database.py 2020-12-11 22:09:10 +00:00
agsNeto20 7af6b46ed4 Update main.py 2020-12-11 22:00:54 +00:00
agsNeto20 baecf5a0c5 Update database.py 2020-12-11 22:00:32 +00:00
agsNeto20 022436c7b3 Add files via upload 2020-12-10 20:02:08 +00:00
agsNeto20 2e7a798c59 Add files via upload 2020-12-10 20:01:58 +00:00
agsNeto20 cc61339385 Delete projetodatabase_alex_UPDATED.sql 2020-12-10 20:01:19 +00:00
agsNeto20 cd4eb4a6dd Delete main_CODIGO_TOTAL 2020-12-10 20:01:09 +00:00
agsNeto20 d3fe512121 Delete database_TOTAL 2020-12-10 20:01:01 +00:00
agsNeto20 2cff69bdae Delete databaseUPDATED-alex.py 2020-12-10 20:00:55 +00:00
agsNeto20 9b11d10792 Delete database.py 2020-12-10 20:00:49 +00:00
agsNeto20 cfe71e66bd Delete appUPDATED-alex.py 2020-12-10 20:00:37 +00:00
agsNeto20 a67fc2c8fe Delete app.py 2020-12-10 20:00:29 +00:00
agsNeto20 21fb445d03 Delete DATABASE_SQL 2020-12-10 20:00:18 +00:00
alexalmeida2001 d2709b2a3c Add files via upload 2020-12-10 12:01:36 +00:00
alexalmeida2001 eb12a528c9 Update main_CODIGO_TOTAL 2020-12-10 11:56:48 +00:00
alexalmeida2001 96911c6f1f Add files via upload 2020-12-10 01:20:21 +00:00
alexalmeida2001 2854c36929 Create database_TOTAL 2020-12-09 10:50:09 +00:00
alexalmeida2001 734b48fa6e Create main_CODIGO_TOTAL 2020-12-09 10:49:37 +00:00
alexalmeida2001 88b6ca0ea8 Update databaseUPDATED-alex.py 2020-12-07 17:29:39 +00:00
alexalmeida2001 95e361c167 Update app.py 2020-12-07 17:29:19 +00:00
alexalmeida2001 cf57033a75 Update databaseUPDATED-alex.py 2020-12-07 16:23:15 +00:00
alexalmeida2001 916beb4905 Update appUPDATED-alex.py 2020-12-07 16:22:46 +00:00
alexalmeida2001 d21f4ced94 Update database.py 2020-12-06 12:30:47 +00:00
alexalmeida2001 77ca634bed Update app.py 2020-12-06 12:30:20 +00:00
alexalmeida2001 6a461c8fa7 Add files via upload 2020-12-06 12:29:40 +00:00
alexalmeida2001 0be5531afd Update appUPDATED-alex.py 2020-12-05 19:22:27 +00:00
alexalmeida2001 2861446546 Update databaseUPDATED-alex.py 2020-12-05 19:22:07 +00:00
alexalmeida2001 1847513760 Update databaseUPDATED-alex.py 2020-12-05 19:16:30 +00:00
alexalmeida2001 7c40fd0596 Update and rename databaseUPDATED.py to databaseUPDATED-alex.py 2020-12-05 18:27:51 +00:00
alexalmeida2001 6e1e2665fe Update and rename appUPDATED.py to appUPDATED-alex.py 2020-12-05 18:26:57 +00:00
alexalmeida2001 fdf9b678d9 Create appUPDATED.py 2020-12-03 16:49:21 +00:00
alexalmeida2001 751e14904b Create databaseUPDATED.py 2020-12-03 16:48:53 +00:00
alexalmeida2001 5f363e78d8 Update database.py 2020-12-03 11:45:35 +00:00
alexalmeida2001 7741501c18 Update app.py 2020-12-03 11:45:02 +00:00
alexalmeida2001 1b3e45308d Update database.py 2020-12-02 16:24:43 +00:00
alexalmeida2001 8edbdb3fb5 Add files via upload
new stuff
2020-11-28 12:05:12 +00:00