timelesslounge / timelessis

37 stars 21 forks source link

Current integration tests are not covering basic scenarios #547

Open krzyk opened 5 years ago

krzyk commented 5 years ago

I'm working on reservations puzzle, and wanted to create a reservation so I can see it in a list. Clean db, code from master.

There are tests for such scenario in it_reservations_test.py.

First result when I tried to create a reservation (http://127.0.0.1:5000/reservations/create) is Bad CSRF token - what? Why? So it looks like the CreateView is not adding CSRF token, but our tests happily pass - this should not happen, tests should fail if there is no CSRF token.

Second error (when I disabled CSRF), I get sqlalchemy error:

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column "num_of_persons" is of type timestamp without time zone but expression is of type integer LINE 1: ...imestamp, '2018-02-03T01:00:00'::timestamp, NULL, 3, 'Random... ^ HINT: You will need to rewrite or cast the expression. [SQL: 'INSERT INTO reservations (created_on, updated_on, start_time, end_time, customer_id, num_of_persons, comment, status) VALUES (%(created_on)s, %(updated_on)s, %(start_time)s, %(end_time)s, %(customer_id)s, %(num_of_persons)s, %(comment)s, %(status)s) RETURNING reservations.id'] [parameters: {'created_on': datetime.datetime(2019, 3, 15, 13, 39, 0, 71842), 'updated_on': datetime.datetime(2019, 3, 15, 13, 39, 0, 71847), 'start_time': datetime.datetime(2017, 8, 1, 1, 0), 'end_time': datetime.datetime(2018, 2, 3, 1, 0), 'customer_id': None, 'num_of_persons': 3, 'comment': 'Random comment', 'status': 'started'}] (Background on this error at: http://sqlalche.me/e/f405)

And the issue is in migrations, someone pushed a migration (2019-02-10T185948.py) that created such column:

    sa.Column('num_of_persons', sa.DateTime(), nullable=False),

Again, this should be captured by our tests, but didn't. This should be fixed, if we have tests that fail to discover such scenarios they are worthless.

0crat commented 5 years ago

@emilianodellacasa/z please, pay attention to this issue

emilianodellacasa commented 5 years ago

@krzyk Let's investigate starting from the CSRF problem, as it is affecting all forms (including login form)

0crat commented 5 years ago

Job #547 is now in scope, role is DEV

0crat commented 5 years ago

Bug was reported, see §29: +15 point(s) just awarded to @krzyk/z