from django.test import LiveServerTestCase

try:
    from django.urls import reverse
except ImportError:  # django < 1.10
    from django.core.urlresolvers import reverse

from tusclient import client


class TestUploadView(LiveServerTestCase):

    def test_get_is_not_allowed(self):
        response = self.client.get(reverse('tus_upload'))
        assert response.status_code == 405

    def test_upload_file(self):
        tus_client = client.TusClient(
            self.live_server_url + reverse('tus_upload')
        )
        uploader = tus_client.uploader('tests/files/hello_world.txt', chunk_size=200)
        uploader.upload()
        assert uploader.request.status_code == 204

try:
    from django.urls import reverse
except ImportError:  # django < 1.10
    from django.core.urlresolvers import reverse

from tusclient.client import TusClient


class TestUploadView(object):

    def test_get_is_not_allowed(self, client):
        response = client.get(reverse('tus_upload'))
        assert response.status_code == 405

    def test_upload_file(self, live_server):
        tus_client = TusClient(
            live_server.url + reverse('tus_upload')
        )
        uploader = tus_client.uploader('tests/files/hello_world.txt', chunk_size=200)
        uploader.upload()
        assert uploader.request.status_code == 204

Refactor view to use fixtures from `pytest-django`.
Refactor view to use fixtures from `pytest-django`.
