From 35ce576aef8ec1012a4b579fc8bd7a20d21996db Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Thu, 28 Nov 2019 18:06:07 -0500 Subject: [PATCH] Change the name of the project from phial to fwx, to avoid pypi conflict --- phial.py => fwx.py | 0 main.py | 6 +- setup.py | 10 ++-- test_phial.py | 135 --------------------------------------------- 4 files changed, 9 insertions(+), 142 deletions(-) rename phial.py => fwx.py (100%) delete mode 100644 test_phial.py diff --git a/phial.py b/fwx.py similarity index 100% rename from phial.py rename to fwx.py diff --git a/main.py b/main.py index f0bc2bc..d2d758a 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,11 @@ -import phial +import fwx def handler(request): - return phial.TextResponse( + return fwx.TextResponse( content='Hello, world\n', ) -app = phial.App(handler) +app = fwx.App(handler) if __name__ == '__main__': from twisted.internet import reactor diff --git a/setup.py b/setup.py index 905fc49..8d1b9e3 100644 --- a/setup.py +++ b/setup.py @@ -4,19 +4,21 @@ with open('README.md', 'r') as fh: long_description = fh.read() setuptools.setup( - name='phial', + name='fwx', version='0.0.1', - scripts=['phial.py'] , + scripts=['fwx.py'] , author='David Kerkeslager', author_email='kerkeslager+pypi@gmail.com', description='A minimalist functional web framework', long_description=long_description, long_description_content_type='text/markdown', - url='https://github.com/kerkeslager/phial', + url='https://github.com/kerkeslager/fwx', packages=setuptools.find_packages(), classifiers=[ 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: MIT License', + 'License :: OSI Approved :: GNU Affero General Public License v3', + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', 'Operating System :: OS Independent', ], ) diff --git a/test_phial.py b/test_phial.py deleted file mode 100644 index 672be96..0000000 --- a/test_phial.py +++ /dev/null @@ -1,135 +0,0 @@ -import unittest -from unittest import mock - -import phial - -class RequestTests(unittest.TestCase): - def test_GET(self): - request = phial.Request({ - 'REQUEST_METHOD': 'GET', - 'QUERY_STRING': 'foo=bar&baz=qux', - }) - - self.assertEqual(request.GET['foo'], ['bar']) - self.assertEqual(request.GET['baz'], ['qux']) - - def test_parameters(self): - request = phial.Request({ - 'REQUEST_METHOD': 'GET', - 'QUERY_STRING': 'foo=bar&baz=qux', - }) - - self.assertEqual(request.parameters['foo'], ['bar']) - self.assertEqual(request.parameters['baz'], ['qux']) - -class ResponseTests(unittest.TestCase): - def test_content_can_be_positional_argument(self): - response = phial.Response('Hello, world\n', content_type='text/plain') - - self.assertEqual(response.content, 'Hello, world\n') - - def test_content_can_be_keyword_argument(self): - response = phial.Response(content='Hello, world\n', content_type='text/plain') - - self.assertEqual(response.content, 'Hello, world\n') - - def test_status_defaults_to_200(self): - response = phial.Response( - content_type='text/plain', - content='Hello, world\n', - ) - - self.assertEqual(response.status, 200) - - def test_headers(self): - response = phial.Response( - content_type='text/plain', - content='Hello, world\n', - ) - - self.assertEqual( - response.headers, - ( - ('Content-Type', 'text/plain'), - ), - ) - -class HTMLResponseTests(unittest.TestCase): - def test_sets_content_type(self): - response = phial.HTMLResponse('Hello, world') - self.assertEqual(response.content_type, 'text/html') - -class JSONResponseTests(unittest.TestCase): - def test_sets_content_type(self): - response = phial.JSONResponse({ 'foo': 'bar', 'baz': 42 }) - self.assertEqual(response.content_type, 'application/json') - - def test_sets_content(self): - response = phial.JSONResponse({ 'foo': 'bar', 'baz': 42 }) - self.assertEqual(response.content, '{"foo": "bar", "baz": 42}') - - def test_sets_content_json(self): - response = phial.JSONResponse({ 'foo': 'bar', 'baz': 42 }) - self.assertEqual(response.content_json, {"foo": "bar", "baz": 42}) - -class TextResponseTests(unittest.TestCase): - def test_sets_content_type(self): - response = phial.TextResponse('Hello, world\n') - self.assertEqual(response.content_type, 'text/plain') - -class RedirectResponse(unittest.TestCase): - def test_takes_location_as_positional_argument(self): - response = phial.RedirectResponse('/location') - self.assertEqual(response.location, '/location') - - def test_takes_location_as_keyword_argument(self): - response = phial.RedirectResponse(location='/location') - self.assertEqual(response.location, '/location') - - def test_permanent_defaults_to_true(self): - response = phial.RedirectResponse('/location') - self.assertEqual(response.permanent, True) - - def test_status(self): - self.assertEqual( - phial.RedirectResponse('/location', permanent=True).status, - 308, - ) - self.assertEqual( - phial.RedirectResponse('/location', permanent=False).status, - 307, - ) - - def test_headers(self): - self.assertEqual( - phial.RedirectResponse('/location').headers, - (('Location','/location'),), - ) - - def test_content(self): - self.assertEqual( - phial.RedirectResponse('/location').content, - (b'',), - ) - -class _get_status_Tests(unittest.TestCase): - def test_basic(self): - self.assertEqual(phial._get_status(mock.MagicMock(status=200)), '200 OK') - self.assertEqual(phial._get_status(mock.MagicMock(status=307)), '307 Temporary Redirect') - self.assertEqual(phial._get_status(mock.MagicMock(status=308)), '308 Permanent Redirect') - -class _get_content_Tests(unittest.TestCase): - def test_bytes(self): - self.assertEqual( - phial._get_content(mock.MagicMock(content=b'Hello, world\n')), - (b'Hello, world\n',), - ) - - def test_str(self): - self.assertEqual( - phial._get_content(mock.MagicMock(content='Hello, world\n')), - (b'Hello, world\n',), - ) - -if __name__ == '__main__': - unittest.main() -- 2.20.1