<s> from __future__ import unicode_literals <EOL> import pytest <EOL> from django . core . urlresolvers import reverse <EOL> from localshop . apps . packages . tasks import fetch_package <EOL> from tests . factories import ReleaseFileFactory <EOL> @ pytest . mark . django_db <EOL> def test_success ( app , admin_user , repository , pypi_stub ) : <EOL> repository . upstream_pypi_url = pypi_stub . url <EOL> repository . save ( ) <EOL> release_file = ReleaseFileFactory ( release__package__repository = repository ) <EOL> response = app . get ( <EOL> reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : release_file . release . package . name , <EOL> '<STR_LIT>' : release_file . release . package . repository . slug <EOL> } ) ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert '<STR_LIT>' in response . unicode_body <EOL> a_elms = response . html . select ( '<STR_LIT:a>' ) <EOL> assert len ( a_elms ) == <NUM_LIT:1> <EOL> assert a_elms [ <NUM_LIT:0> ] [ '<STR_LIT>' ] == ( <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> assert a_elms [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> @ pytest . mark . django_db <EOL> def test_missing_package_local_package ( app , admin_user , repository , <EOL> pypi_stub ) : <EOL> repository . upstream_pypi_url = pypi_stub . url <EOL> repository . save ( ) <EOL> fetch_package . run ( repository . pk , '<STR_LIT>' ) <EOL> response = app . get ( <EOL> reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : repository . slug , <EOL> } ) ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert '<STR_LIT>' in response . unicode_body <EOL> assert '<STR_LIT>' in response . unicode_body <EOL> assert '<STR_LIT>' in response . unicode_body <EOL> assert '<STR_LIT>' in response . unicode_body <EOL> @ pytest . mark . django_db <EOL> def test_nonexistent_package ( app , admin_user , repository , pypi_stub ) : <EOL> repository . upstream_pypi_url = pypi_stub . url <EOL> repository . save ( ) <EOL> response = app . get ( <EOL> reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : repository . slug , <EOL> } ) ) <EOL> assert response . url == '<STR_LIT>' <EOL> assert response . status_code == <NUM_LIT> <EOL> @ pytest . mark . django_db <EOL> def test_wrong_package_name_case ( app , admin_user , repository , pypi_stub ) : <EOL> repository . upstream_pypi_url = pypi_stub . url <EOL> repository . save ( ) <EOL> ReleaseFileFactory ( <EOL> release__package__repository = repository , <EOL> release__package__name = '<STR_LIT>' ) <EOL> response = app . get ( <EOL> reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:default>' <EOL> } ) ) <EOL> assert response . status_code == <NUM_LIT> <EOL> assert response . url == '<STR_LIT>' </s>
