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

Add minimal tests #5

Merged
merged 3 commits into from Dec 5, 2018
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+69 −4
Diff settings

Always

Just for now

Copy path View file
@@ -0,0 +1,10 @@
language: python
python:
- 3.5
- 3.6
- 3.7
install:
- pip install --upgrade setuptools pip
- pip install . -r dev-requirements.txt
script:
- pytest
Copy path View file
@@ -1,2 +1,27 @@
# nativeauthenticator
JupyterHub-native user authenticator
# Native Authenticator

[JupyterHub](http://github.com/jupyter/jupyterhub/) authenticator


## Installation

While this package is not on package manager, you can clone this repository and
install it with:

`$ pip install -e .`

You can then use this as your authenticator by adding the following line to your jupyterhub_config.py:

`c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator'`


## Running tests

To run the tests locally, you can install the development dependencies:

`$ pip install dev-requirements.txt`

Then run tests with pytest:

`$ pytest`

Copy path View file
@@ -0,0 +1,2 @@
pytest
pytest-asyncio
@@ -1,5 +1,10 @@
from jupyterhub.auth import Authenticator

from tornado import gen


class NativeAuthenticator(Authenticator):
pass

@gen.coroutine
def authenticate(self, handler, data):
return data['username']
Copy path View file
@@ -9,7 +9,7 @@
author_email='leportella@protonmail.com',
license='3 Clause BSD',
packages=find_packages(),
install_requires=['bcrypt'],
install_requires=['jupyterhub>=0.8'],
package_data={
'': ['*.html'],
}
Copy path View file
@@ -0,0 +1,23 @@
import pytest
from unittest.mock import Mock


from nativeauthenticator import NativeAuthenticator


@pytest.fixture
def tmpcwd(tmpdir):
tmpdir.chdir()


# use pytest-asyncio
pytestmark = pytest.mark.asyncio
# run each test in a temporary working directory
pytestmark = pytestmark(pytest.mark.usefixtures("tmpcwd"))


async def test_basic(tmpcwd):
auth = NativeAuthenticator()
response = await auth.authenticate(Mock(), {'username': 'name',
'password': '123'})
assert response == 'name'
ProTip! Use n and p to navigate between commits in a pull request.