tjcsl / ion

TJ Intranet 3
https://ion.tjhsst.edu
GNU General Public License v2.0
100 stars 87 forks source link

Tests should use postgresql #1144

Open pefoley2 opened 3 years ago

pefoley2 commented 3 years ago

It appears that https://github.com/tjcsl/ion/blob/master/ci/spec.yml#L242 is not actually running all the tests.

./setup.py test produces: Ran 285 tests in 96.273s

OK

But installing/running pytest-django gives: ======================================================= short test summary info ========================================================FAILED intranet/apps/api/tests.py::ApiTest::test_api_bus_detail - django.db.utils.DataError: value too long for type character varyin...FAILED intranet/apps/api/tests.py::ApiTest::test_api_bus_list - django.db.utils.DataError: value too long for type character varying(5) FAILED intranet/apps/bus/tests.py::BusTest::test_route_representation - django.db.utils.DataError: value too long for type character ...FAILED intranet/apps/bus/tests.py::BusTest::test_routes - django.db.utils.DataError: value too long for type character varying(5) FAILED intranet/apps/eighth/tests/test_attendance.py::EighthAttendanceTestCase::test_take_attendance - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_attendance.py::EighthAttendanceTestCase::test_take_attendance_google_meet_csv - AssertionError...FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_all_associated_rooms - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_blacklist - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_both_blocks - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_cancel_uncancel - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_passes - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_room_use - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_signups - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_general.py::EighthTest::test_true_capacity - AssertionError: 200 != 302 FAILED intranet/apps/eighth/tests/test_profile.py::EighthProfileTest::test_profile_signup_view - AssertionError: 58 != 56 FAILED intranet/apps/eighth/tests/test_signup.py::EighthSignupTest::test_eighth_multi_signup_view - KeyError: '1' FAILED intranet/apps/eighth/tests/admin/test_admin_attendance.py::EighthAdminAttendanceTest::test_take_attendance_cancelled - Asserti...FAILED intranet/apps/eighth/tests/admin/test_admin_attendance.py::EighthAdminAttendanceTest::test_take_attendance_zero - AssertionErr...FAILED intranet/apps/eighth/tests/admin/test_admin_groups.py::EighthAdminGroupsTest::test_download_group_csv_view - django.db.utils.D...FAILED intranet/apps/eighth/tests/admin/test_admin_groups.py::EighthAdminGroupsTest::test_eighth_admin_distribute_action - django.db....FAILED intranet/apps/eighth/tests/admin/test_admin_groups.py::EighthAdminGroupsTest::test_eighth_admin_distribute_group - django.db.u...FAILED intranet/apps/eighth/tests/admin/test_admin_groups.py::EighthAdminGroupsTest::test_eighth_admin_distribute_unsigned - django.d...FAILED intranet/apps/eighth/tests/admin/test_admin_groups.py::EighthAdminGroupsTest::test_eighth_admin_signup_group - django.db.utils...FAILED intranet/apps/events/tests.py::EventsTest::test_add_event - AssertionError: 'Error adding event.' != 'Because you are an admin...FAILED intranet/apps/events/tests.py::EventsTest::test_modify_event - AssertionError: 'Error modifying event.' != 'Successfully modif...FAILED intranet/apps/schedule/tests.py::ScheduleTest::test_schedule_context - AssertionError: <Day: 2021-03-22: Test Day> != None FAILED intranet/apps/search/tests.py::SearchTestCase::test_eighth_activity_search - AssertionError: '123' not found in 'b\'\n\n<!DO...======================================= 27 failed, 258 passed, 29 warnings in 212.30s (0:03:32) ========================================

To pick a concrete example, bus_number is limited to len(5) here: https://github.com/tjcsl/ion/blob/master/intranet/apps/bus/models.py#L11

But the api test tries to make an entry of len(6) here: https://github.com/tjcsl/ion/blob/master/intranet/apps/api/tests.py#L510

which results in an error like: E django.db.utils.DataError: value too long for type character varying(5)

So for whatever reason, ./setup.py test isn't doing what it should...

See https://github.com/tjcsl/ion/pull/1143 for an example.

pefoley2 commented 3 years ago

See https://github.com/tjcsl/ion/pull/1143#issuecomment-850936891 for what the current set of failures exposed by switching to pytest looks like.

pefoley2 commented 3 years ago

The issue is actually that we're using sqlite in the test suite, which does much less sanity checking than postgres: See https://github.com/tjcsl/ion/pull/1143#issuecomment-851683411