mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-12-01 05:53:59 +03:00
fa469618dd
* Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Add files via upload * Update README.rst * Rename Blank Diagram (1).svg to di-map.svg * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Add files via upload * Rename Blank Diagram (2).svg to di-map2.svg * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Add files via upload * Add files via upload * Rename README.svg to di-map3.svg * Update README.rst * Add files via upload * Rename README - Page 3.svg to di-map4.svg * Update README.rst * Add files via upload * Rename README - Copy of Page 3.svg to di-map5.svg * Update README.rst * Delete di-map.svg * Delete di-map2.svg * Delete di-map3.svg * Delete di-map4.svg * Update README.rst * Update README.rst * Add Github Navigator - Flask application * Do more refactoring for ghnav-flask * More refactoring * Update README * Add tests * Update readme * Add Flask extension * Add Factory.provides attribute * Add Flask extension module * User flask extension in githubnavigator example * Add README for ghnav-flask * Update ghnav-flask README * Update ghnav-flask README * Update README with ghnav container example * Move ghnav-flask to miniapps/ folder * Fix auth token reading from env for ghnav-flask * Update readme * Fix ghnav-flask linter errors * Add downloads and wheel badge * Add tests for flask extension * Fix flask tests * Add requirements-ext.txt installation to tox.ini * Add API docs for ext.flask module * Update setup.py * Add Flask to the list of keywords * Update badges on docs README * Update docs README title * Fix ext.flask tests * Fix syntax of ext.flask for Python 2.7, 3.4, 3.5 * Fix syntax of ext.flask for Python 2.7, 3.4, 3.5 * Fix imports in ext.flask for Python 2.7, 3.4, 3.5 * Update ghfnav-flask README * Update ghfnav-flask README * Remove setting of empty github token * Add flask extras * Update requirements * Update requirements * Add flask extra to python 3.4 tox.ini * Update changelog * Update changelog
91 lines
2.5 KiB
Python
91 lines
2.5 KiB
Python
"""Tests module."""
|
|
|
|
from unittest import mock
|
|
|
|
import pytest
|
|
from github import Github
|
|
from flask import url_for
|
|
|
|
from .application import Application
|
|
|
|
|
|
@pytest.fixture
|
|
def application():
|
|
application = Application()
|
|
application.config.from_dict(
|
|
{
|
|
'github': {
|
|
'auth_token': 'test-token',
|
|
'request_timeout': 10,
|
|
},
|
|
'search': {
|
|
'default_term': 'Dependency Injector',
|
|
'default_limit': 5,
|
|
},
|
|
}
|
|
)
|
|
return application
|
|
|
|
|
|
@pytest.fixture()
|
|
def app(application: Application):
|
|
return application.app()
|
|
|
|
|
|
def test_index(client, application: Application):
|
|
github_client_mock = mock.Mock(spec=Github)
|
|
github_client_mock.search_repositories.return_value = [
|
|
mock.Mock(
|
|
html_url='repo1-url',
|
|
name='repo1-name',
|
|
owner=mock.Mock(
|
|
login='owner1-login',
|
|
html_url='owner1-url',
|
|
avatar_url='owner1-avatar-url',
|
|
),
|
|
created_at='repo1-created-at',
|
|
get_commits=mock.Mock(return_value=[mock.Mock()]),
|
|
),
|
|
mock.Mock(
|
|
html_url='repo2-url',
|
|
name='repo2-name',
|
|
owner=mock.Mock(
|
|
login='owner2-login',
|
|
html_url='owner2-url',
|
|
avatar_url='owner2-avatar-url',
|
|
),
|
|
created_at='repo2-created-at',
|
|
get_commits=mock.Mock(return_value=[mock.Mock()]),
|
|
),
|
|
]
|
|
|
|
with application.github_client.override(github_client_mock):
|
|
response = client.get(url_for('index'))
|
|
|
|
assert response.status_code == 200
|
|
|
|
assert b'repo1-url' in response.data
|
|
assert b'repo1-name' in response.data
|
|
assert b'owner1-login' in response.data
|
|
assert b'owner1-url' in response.data
|
|
assert b'owner1-avatar-url' in response.data
|
|
assert b'repo1-created-at' in response.data
|
|
|
|
assert b'repo2-url' in response.data
|
|
assert b'repo2-name' in response.data
|
|
assert b'owner2-login' in response.data
|
|
assert b'owner2-url' in response.data
|
|
assert b'owner2-avatar-url' in response.data
|
|
assert b'repo2-created-at' in response.data
|
|
|
|
|
|
def test_index_no_results(client, application: Application):
|
|
github_client_mock = mock.Mock(spec=Github)
|
|
github_client_mock.search_repositories.return_value = []
|
|
|
|
with application.github_client.override(github_client_mock):
|
|
response = client.get(url_for('index'))
|
|
|
|
assert response.status_code == 200
|
|
assert b'No search results' in response.data
|