Repository: rgalanakis/hostthedocs

Issue:
Linking to latest doesn't work
The link to latest version is not working

Below is the debug log
(sample2 is the project name that contains only one version 0.1.2)


127.0.0.1 - - [02/Jul/2019 15:49:54] "GET /sample2/latest HTTP/1.1" 308 -
127.0.0.1 - - [02/Jul/2019 15:51:01] "GET /sample2/latest/ HTTP/1.1" 302 -
127.0.0.1 - - [02/Jul/2019 15:52:19] "GET /sample2/latest/static/docfiles/sample2/0.1.2/index.html HTTP/1.1" 302 -
127.0.0.1 - - [02/Jul/2019 15:52:31] "GET /sample2/latest/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/index.html HTTP/1.1" 302 -
127.0.0.1 - - [02/Jul/2019 15:52:56] "GET /sample2/latest/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/static/docfiles/sample2/0.1.2/index.html HTTP/1.1" 302 - 

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index 040f5d8..fc31a23 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,11 @@
 language: python
 python:
-    - "2.6"
-    - "2.7"
     # See https://github.com/rgalanakis/hostthedocs/pull/24 for details
     # - "3.3"
     - "3.4"
     - "3.5"
     - "3.6"
-    - "pypy"
+    - "3.7"
     - "pypy3"
 install:
   - pip install tox-travis
diff --git a/hostthedocs/__init__.py b/hostthedocs/__init__.py
index f6d860c..67e09cd 100644
--- a/hostthedocs/__init__.py
+++ b/hostthedocs/__init__.py
@@ -63,5 +63,4 @@ def latest(project, path):
         latestlink = '%s/%s' % (os.path.dirname(latestindex), path)
     else:
         latestlink = latestindex
-    # Should it be a 302 or something else?
-    return redirect(latestlink)
+    return redirect('/' + latestlink)
diff --git a/tox.ini b/tox.ini
index fe685f6..91b8465 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py26, py27, py33, py34, py35, py36, pypy, pypy3
+envlist = py33, py34, py35, py36, py37, pypy3
 
 [testenv]
 commands = nosetests
@@ -7,40 +7,11 @@ deps =
     nose
     mock
 
-[testenv:py26]
-basepython = python2.6
-deps =
-   {[testenv]deps}
-    unittest2
-
-[testenv:py27]
-basepython = python2.7
-
-[testenv:py33]
-basepython = python3.3
-
-[testenv:py34]
-basepython = python3.4
-
-[testenv:py35]
-basepython = python3.5
-
-[testenv:py36]
-basepython = python3.6
-
-[testenv:pypy]
-basepython = pypy
-
-[testenv:pypy3]
-basepython = pypy3
-
 [travis]
 python =
-  2.6: py26
-  2.7: py27
   3.3: py33
   3.4: py34
   3.5: py35
   3.6: py36
-  pypy: pypy
-  pypy3: pypy3
\ No newline at end of file
+  3.7: py37
+  pypy3: pypy3


Test patch:
diff --git a/tests/test_hostthedocs.py b/tests/test_hostthedocs.py
index 631bc6d..485f76b 100644
--- a/tests/test_hostthedocs.py
+++ b/tests/test_hostthedocs.py
@@ -51,12 +51,15 @@ class LatestTests(Base):
 
     def assert_redirect(self, path, code, location):
         resp = self.app.get(path)
-        self.assertEqual(resp.status_code, code)
+        if isinstance(code, list):
+            self.assertIn(resp.status_code, code)
+        else:
+            self.assertEqual(resp.status_code, code)
         gotloc = urlparse.urlsplit(dict(resp.headers)['Location']).path
         self.assertEqual(gotloc, location)
 
     def test_latest_noslash(self):
-        self.assert_redirect('/foo/latest', 301, '/foo/latest/')
+        self.assert_redirect('/foo/latest', [301, 308], '/foo/latest/')
 
     def test_latest_root(self):
             self.assert_redirect('/Project2/latest/', 302, '/linkroot/Project2/2.0.3/index.html')