| |
@@ -1,5 +1,6 @@
|
| |
import flask
|
| |
import unittest
|
| |
+ from urlparse import urlparse
|
| |
|
| |
import hubs.tests
|
| |
import hubs.models
|
| |
@@ -12,12 +13,12 @@
|
| |
class TestHubSubscribe(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_subscribe_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/subscribe'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/subscribe'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_subscribe_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
@@ -33,12 +34,12 @@
|
| |
class TestHubUnsubscribe(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_unsubscribe_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/unsubscribe'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/unsubscribe'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_unsubscribe_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
@@ -59,12 +60,12 @@
|
| |
class TestHubStar(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_star_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/star'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/star'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_star_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
@@ -80,12 +81,12 @@
|
| |
class TestHubUnstar(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_unstar_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/unstar'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/unstar'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_unstar_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
@@ -107,12 +108,12 @@
|
| |
class TestHubJoin(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_join_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/join'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/join'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_join_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
@@ -128,12 +129,12 @@
|
| |
class TestHubLeave(hubs.tests.APPTest):
|
| |
user = hubs.tests.FakeAuthorization('decause')
|
| |
|
| |
- @unittest.skip('Need to handle redirects')
|
| |
def test_leave_redirects_when_logged_out(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
- resp = self.app.post('/api/hub/{}/leave'.format(hub.idx))
|
| |
+ resp = self.app.post('/api/hub/{}/leave'.format(hub.name),
|
| |
+ follow_redirects=False)
|
| |
self.assertEqual(resp.status_code, 302)
|
| |
- self.assertEqual(resp.location, flask.url_for('fedora.login'))
|
| |
+ self.assertEqual(urlparse(resp.location).path, '/login/fedora')
|
| |
|
| |
def test_star_when_logged_in(self):
|
| |
hub = hubs.models.Hub.by_name(self.session, 'infra')
|
| |
Thanks to the changes that were made in an earlier PR, the tests
api/hubs/
routes can be tested as a logged out user.