Skip to content
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

Management command to obtain JWT token for a user #62

Merged
merged 10 commits into from Dec 14, 2020

Conversation

MahdiZareie
Copy link

I needed a simple management command to use during development, in order to obtain JWT token for my test user easier, I thought it might be helpful to open a PR on the main repo.

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2020

Codecov Report

Merging #62 into master will decrease coverage by 6.89%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
- Coverage   98.14%   91.25%   -6.90%     
==========================================
  Files          19       20       +1     
  Lines         485      503      +18     
  Branches       45       49       +4     
==========================================
- Hits          476      459      -17     
- Misses          7       41      +34     
- Partials        2        3       +1     
Flag Coverage Δ
#codecov 91.25% <0.00%> (-6.90%) ⬇️
#dj111 91.25% <0.00%> (-6.43%) ⬇️
#dj20 90.85% <0.00%> (-6.41%) ⬇️
#dj21 90.85% <0.00%> (-6.41%) ⬇️
#dj22 90.85% <0.00%> (-6.41%) ⬇️
#dj30 90.85% <0.00%> (-6.88%) ⬇️
#drf310 90.85% <0.00%> (-6.41%) ⬇️
#drf311 90.85% <0.00%> (-6.88%) ⬇️
#drf37 91.25% <0.00%> (-6.43%) ⬇️
#drf38 91.25% <0.00%> (-6.43%) ⬇️
#drf39 91.25% <0.00%> (-6.43%) ⬇️
#py27 90.85% <0.00%> (-6.41%) ⬇️
#py35 90.85% <0.00%> (-6.41%) ⬇️
#py36 90.85% <0.00%> (-6.41%) ⬇️
#py37 90.85% <0.00%> (-6.41%) ⬇️
#py38 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
..._framework_jwt/management/commands/obtain_token.py 0.00% <0.00%> (ø)
src/rest_framework_jwt/compat.py 77.77% <0.00%> (-7.41%) ⬇️
src/rest_framework_jwt/authentication.py 96.73% <0.00%> (-0.30%) ⬇️
src/rest_framework_jwt/serializers.py 100.00% <0.00%> (ø)
src/rest_framework_jwt/blacklist/signals.py 100.00% <0.00%> (ø)
src/rest_framework_jwt/blacklist/exceptions.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79dda00...0d06aaa. Read the comment docs.

Copy link
Collaborator

@fitodic fitodic 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 PR! 👍

Could you please address the comments and add the following:

  1. a changelog;
  2. tests for the management command?

@MahdiZareie
Copy link
Author

Thanks for the PR! +1

Could you please address the comments and add the following:

1. a [changelog](https://github.com/Styria-Digital/django-rest-framework-jwt/blob/master/CONTRIBUTING.md#documentation);

2. [tests](https://github.com/Styria-Digital/django-rest-framework-jwt/blob/master/CONTRIBUTING.md#testing) for the management command?

How should I run the tests?
I followed README instructions but pytest displays this error:

$ PYTHONPATH=${PYTHONPATH}:./demo:./src/ pytest
ImportError while loading conftest '...django-rest-framework-jwt/tests/conftest.py'.
tests/conftest.py:9: in <module>
    from rest_framework.test import APIClient
env/lib/python3.8/site-packages/rest_framework/test.py:138: in <module>
    class APIRequestFactory(DjangoRequestFactory):
env/lib/python3.8/site-packages/rest_framework/test.py:139: in APIRequestFactory
    renderer_classes_list = api_settings.TEST_REQUEST_RENDERER_CLASSES
env/lib/python3.8/site-packages/rest_framework/settings.py:213: in __getattr__
    val = self.user_settings[attr]
env/lib/python3.8/site-packages/rest_framework/settings.py:204: in user_settings
    self._user_settings = getattr(settings, 'REST_FRAMEWORK', {})
env/lib/python3.8/site-packages/django/conf/__init__.py:76: in __getattr__
    self._setup(name)
env/lib/python3.8/site-packages/django/conf/__init__.py:57: in _setup
    raise ImproperlyConfigured(
E   django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.


changelog.d/62.doc.md Outdated Show resolved Hide resolved
src/rest_framework_jwt/management/commands/obtain_token.py Outdated Show resolved Hide resolved
@MahdiZareie
Copy link
Author

MahdiZareie commented Jul 22, 2020

I think there is nothing left to do except adding tests which I still trying to figure it out how to run them using pytest.

@fitodic
Copy link
Collaborator

fitodic commented Jul 23, 2020

I think there is nothing left to do except adding tests which I still trying to figure it out how to run them using pytest.

Have you tried using tox? It sets up the entire environment for you.
PYTHONPATH modifications are mostly for users who like running test suites using their IDEs. You update the environment variable and the IDE should pick it up from there.

@MahdiZareie
Copy link
Author

Thanks @fitodic, I learned a lot during this PR, Is there anything more you think I need to do about this PR?

@fitodic
Copy link
Collaborator

fitodic commented Jul 27, 2020

Thanks @fitodic, I learned a lot during this PR, Is there anything more you think I need to do about this PR?

You're welcome 😊 If you could just resolve all conversations once you're done, that would be great.

@fitodic fitodic merged commit b920ee4 into Styria-Digital:master Dec 14, 2020
@fitodic
Copy link
Collaborator

fitodic commented Dec 14, 2020

@MahdiZareie Thanks for the PR and sorry for the long wait 👍🏼

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.

None yet

3 participants