Skip to content

Commit

Permalink
Support to run test servers in different ports 🍰
Browse files Browse the repository at this point in the history
  • Loading branch information
amitt001 committed Jul 12, 2018
1 parent ed29bb7 commit c6fd2f4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pygmy/config/pygmy_test.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pygmy]
schema = http
host = 0.0.0.0
port = 9119
port = 9118
debug = True
flask_secret = CvJHGFVBj*&^TRGBHDdBV836bdy73JJDHGV
short_url = 127.0.0.1
Expand Down
6 changes: 0 additions & 6 deletions pygmyui/pygmy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ def short_link_stats(request, code):
key=operator.itemgetter(1),
reverse=True)
context = dict(clickmeta=clickmeta)
except UnAuthorized:
# return redirect('/link/secret?next={}'.format(code))
return render(request, '404.html',
context=API_ERROR(dict(
error='Secret link stats are not yet supported.')
), status=404)
except (ObjectNotFound, LinkExpired) as e:
return render(request, '404.html',
context=API_ERROR(e.args[0]), status=404)
Expand Down
4 changes: 4 additions & 0 deletions pygmyui/pygmyui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,7 @@
PYGMY_API_PASSWORD = 'admin'

HOSTNAME = '127.0.0.1:8000'

# Load tests if PYGMYUI_TEST environment variable is set
if os.environ.get('PYGMYUI_TEST') is not None:
from pygmyui.settings_tests import * # pylint: disable=W0614, E0611, E0401
10 changes: 10 additions & 0 deletions pygmyui/pygmyui/settings_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Pygmy Test Settings
PYGMY_API_ADDRESS = 'http://127.0.0.1:9118'

PYGMY_API_AUTH = 'BasicAuth'

PYGMY_API_USER = 'admin'

PYGMY_API_PASSWORD = 'admin'

HOSTNAME = '127.0.0.1:8001'
1 change: 1 addition & 0 deletions tests/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def terminate_pygmy_ui_server(cls):
@pytest.fixture(scope='class')
def run_test_server(request):
# Setup
os.environ.setdefault('PYGMYUI_TEST', 'true')
request.cls.pygmyapi_proc = PygmyApiTestServer.start_pygmy_api_server()
request.cls.pygmyui_proc = PygmyUiTestServer.start_pygmy_ui_server()
yield
Expand Down
26 changes: 13 additions & 13 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ def test_custom_links(self):
# secret_url = self.url + '/link/secret?next={}'.format(short_url.split('/')[-1])
# resp = sess.get(short_url)
# self.assertTrue(resp.url, secret_url)
#

# headers = self.headers
# headers['Cookie'] = 'csrftoken={}'.format(resp.cookies['csrftoken'])
# import pdb
# pdb.set_trace()
#

# resp = sess.post(self.url + '/link/secret', json={'code':short_url.split('/')[-1],'secret_key': data['secret_key'], 'csrfmiddlewaretoken': resp.cookies['csrftoken']}, headers=headers)
# self.assertEqual(resp.status_code, 200)
# self.assertTrue('value="{}"'.format(short_url) in response.text)
Expand All @@ -303,27 +303,27 @@ def test_custom_links(self):
# data['remember_time'] = 1 # 1 second
# response = requests.post(self.url + '/shorten', data=data, headers=self.headers)
# short_url = self._get_short_url_from_response(response)
#

# self.assertEqual(requests.get(short_url).url, self.data['long_url'])
# self.assertEqual(response.status_code, 200)
# import time
# time.sleep(1)
# self.assertEqual(requests.get(short_url).status_code, 404)

def test_custom_secret_links(self):
pass
# def test_custom_secret_links(self):
# pass

def test_custom_expiry_links(self):
pass
# def test_custom_expiry_links(self):
# pass

def test_secret_expiry_links(self):
pass
# def test_secret_expiry_links(self):
# pass

def test_custom_secret_expiry_links(self):
pass
# def test_custom_secret_expiry_links(self):
# pass

def test_invalid_char_custom_link(self):
pass
# def test_invalid_char_custom_link(self):
# pass

# ############
# # Link stats
Expand Down

0 comments on commit c6fd2f4

Please sign in to comment.