Skip to content

Conversation

danickfort
Copy link
Contributor

@danickfort danickfort commented Oct 9, 2025

@lucasrcezimbra The username field is customizable in Django's AbstractBaseUser, by specifying a custom USERNAME_FIELD that is different from username. AbstractBaseUser provides the method get_username to retrieve the correct representation for the username.

In the current implementation of APIKey, the code crashes if username doesn't exist on the user model.

Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.87%. Comparing base (978a4c4) to head (ef81e61).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
+ Coverage   94.73%   94.87%   +0.13%     
==========================================
  Files          11       11              
  Lines         266      273       +7     
==========================================
+ Hits          252      259       +7     
  Misses         14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@lucasrcezimbra lucasrcezimbra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Please, add a test case to avoid regression.

Copy link
Owner

@lucasrcezimbra lucasrcezimbra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is failing, and it's testing the mock, not the change.

The username field is customizable in Django's AbstractBaseUser, by specifying a custom `USERNAME_FIELD`.
This model provides the method `get_username` to retrieve the correct representation for the username.
In the current implementation of `APIKey`, the code crashes if `USERNAME_FIELD` is not `username`
@danickfort
Copy link
Contributor Author

The test is failing, and it's testing the mock, not the change.

I addressed these issues and push a fix. I'm not able to run the tests locally at this time, sorry about that.

@lucasrcezimbra lucasrcezimbra merged commit 75aa3f1 into lucasrcezimbra:main Oct 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants