forked from matiaspl/pyserv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
160 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# daemon requirements, useful for tox/pip | ||
-f https://github.com/sarnold/python-daemonizer/releases/ | ||
daemonizer>=0.3.4; platform_system!="Windows" | ||
daemonizer @ git+https://github.com/sarnold/python-daemonizer.git@0.3.5#5f6bc3c80a90344b2c8e4cc24ed0b8c098a7af50; platform_system!="Windows" | ||
appdirs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
import pathlib | ||
import sys | ||
import unittest | ||
import urllib.request | ||
|
||
import httptest | ||
import pytest | ||
|
||
from pyserv import GetHandler | ||
|
||
FILE_PATH = pathlib.Path(__file__) | ||
REAL_PATH = pathlib.Path('requirements.txt') | ||
|
||
class TestHTTPTestMethods(unittest.TestCase): | ||
|
||
class TestHTTPHandler(unittest.TestCase): | ||
|
||
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher") | ||
@httptest.Server( | ||
lambda *args: GetHandler( | ||
*args, directory=FILE_PATH.parent | ||
) | ||
) | ||
def test_call_response(self, ts=httptest.NoServer()): | ||
def test_call_response_dir(self, ts=httptest.NoServer()): | ||
with urllib.request.urlopen(ts.url() + FILE_PATH.name) as f: | ||
self.assertEqual(f.read().decode('utf-8'), FILE_PATH.read_text()) | ||
|
||
@httptest.Server(GetHandler) | ||
def test_url(self, ts=httptest.NoServer()): | ||
''' | ||
Make sure the Server.url() method works. | ||
''' | ||
url = ts.url() | ||
self.assertIn(':', url) | ||
self.assertEqual(':'.join(url.split(':')[:-1]), 'http://localhost') | ||
|
||
@httptest.Server(GetHandler) | ||
def test_call_response_no_dir(self, ts=httptest.NoServer()): | ||
with urllib.request.urlopen(ts.url() + REAL_PATH.name) as f: | ||
self.assertEqual(f.read().decode('utf-8'), REAL_PATH.read_text()) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.