-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tests): Remove ineffectual login #27149
chore(tests): Remove ineffectual login #27149
Conversation
5db29f3
to
177efb5
Compare
177efb5
to
5b4cf74
Compare
be6ffc1
to
9752ca0
Compare
4f761b5
to
b915d66
Compare
@@ -196,7 +196,8 @@ def get_or_create(self, cls, criteria, **kwargs): | |||
db.session.commit() | |||
return obj | |||
|
|||
def login(self, username="admin", password="general"): | |||
def login(self, username, password="general"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require the explicit username so it's evident who is logging in.
d9fd234
to
fc58d28
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #27149 +/- ##
=======================================
Coverage 67.43% 67.44%
=======================================
Files 1911 1911
Lines 74966 74966
Branches 8353 8353
=======================================
+ Hits 50555 50558 +3
+ Misses 22358 22355 -3
Partials 2053 2053
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
672d3ea
to
5016a45
Compare
3dbd03d
to
21c4a0b
Compare
1811d2a
to
7825fea
Compare
@@ -51,7 +56,11 @@ class TestSqlLabApi(SupersetTestCase): | |||
clear=True, | |||
) | |||
def test_get_from_empty_bootsrap_data(self): | |||
self.login(username="gamma_sqllab_no_data") | |||
if utils.backend() == "postgres": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina I've spent/wasted hours trying to get a few failing PostgreSQL tests to pass. The tests succeed when testing locally and/or remotely when I run either i) the specific test, or ii) the specific file, however they fail when run as part of the entire test suite.
My hypothesis is that there are a slew of non-idempotent tests and this change merely (re)highlighted how fragile aspects of our tests are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's kind of frustrating that we have many non-idempotent tests. Given that we'll need a specific effort for fixing this problem globally, I'm ok with skipping the test. We do the same for many sqlite tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @michael-s-molina. Also it's worth mentioning it's not like the test is being skipped globally, i.e., we have coverage on the said logic for MySQL and SQLite.
7825fea
to
4d777bf
Compare
4d777bf
to
73194b2
Compare
SUMMARY
Whilst working on [SIP-99B] Proposal for (re)defining a "unit of work" I was running into an issue where (I thought) tests were failing due to an issue with the persistence of a logged in user whereas in actuality it was because I was missing the
Public
role.The red herring was due to the slew of tests which don't interface with the test client "logging" in a user in the hope of persisting the logged in user to
g.user
. This is ineffectual outside of the client as the Flask globals only persist for the lifetime of the request, i.e.,Flask-Login automatically restores
g.user
from that cookie if it is not in the session when dealing with requests from the client. The TL;DR is authenticating (logging in/logging out) the user is only effectual in the context of web requests via the client.This PR removes any erroneous logins (and logouts)—determined by first eliminating all references and re-adding them for API related tests. It also cleans up any inconsistencies in how logging in occurs. I updated the
login()
method to remove the defaultadmin
username so now it's a required argument which aids with readability.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI.
ADDITIONAL INFORMATION