Skip to content

Commit 93f5331

Browse files
committed
Merge pull request #171 from r1chardj0n3s/legacy-daytime
Add legacy /daytime
2 parents 3f84786 + 4a34453 commit 93f5331

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

tests/legacy/test_pypi.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from __future__ import absolute_import, division, print_function
1515
from __future__ import unicode_literals
1616

17+
import time
18+
1719
import pretend
1820
import pytest
1921

@@ -69,3 +71,14 @@ def test_pypi_route_xmlrpc(monkeypatch):
6971

7072
assert xmlrpc.handle_request.calls == [pretend.call(app, request)]
7173
assert resp == 'success'
74+
75+
76+
def test_daytime(monkeypatch):
77+
app = pretend.stub()
78+
request = pretend.stub()
79+
80+
monkeypatch.setattr(time, 'time', lambda: 0)
81+
82+
resp = pypi.daytime(app, request)
83+
84+
assert resp.response[0] == '19700101T00:00:00\n'

warehouse/legacy/pypi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
from __future__ import absolute_import, division, print_function
1515
from __future__ import unicode_literals
1616

17+
import time
18+
1719
from warehouse.helpers import url_for
1820
from werkzeug.utils import redirect
21+
from warehouse.http import Response
1922

2023
from warehouse.legacy import xmlrpc
2124

@@ -34,3 +37,8 @@ def pypi(app, request):
3437
),
3538
code=301,
3639
)
40+
41+
42+
def daytime(app, request):
43+
response = time.strftime("%Y%m%dT%H:%M:%S\n", time.gmtime(time.time()))
44+
return Response(response, mimetype="text/plain")

warehouse/legacy/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
]),
2727
EndpointPrefix("warehouse.legacy.pypi.", [
2828
Rule("/pypi", methods=["GET", "POST"], endpoint="pypi"),
29+
Rule("/daytime", methods=["GET"], endpoint="daytime"),
2930
]),
3031
]

0 commit comments

Comments
 (0)