From b6898dd41b93f325d173c91bf3b81d7157b49f9d Mon Sep 17 00:00:00 2001 From: skrzepto Date: Nov 05 2016 21:38:41 +0000 Subject: Fix unittests fixed test hub json fixing models unittests fixing string comparison ralph widget index changed, fixing to pass tests. TODO: have the index not be hardcoded in unittest --- diff --git a/hubs/app.py b/hubs/app.py index 3862a24..5a453a0 100755 --- a/hubs/app.py +++ b/hubs/app.py @@ -787,7 +787,7 @@ def plus_plus_update(user): data = {'sender': sender.username, update: update_bool_val} req = None try: - req = request('POST', url=pp_url, headers=auth_header, data=data) + req = requests.post(url=pp_url, headers=auth_header, data=data) except: flask.abort(500) diff --git a/hubs/tests/test_fedora_hubs_flask_api.py b/hubs/tests/test_fedora_hubs_flask_api.py index d2966ed..6dcfcdc 100644 --- a/hubs/tests/test_fedora_hubs_flask_api.py +++ b/hubs/tests/test_fedora_hubs_flask_api.py @@ -1,5 +1,6 @@ import unittest from urlparse import urlparse +import ast # import for string to dict conversion without unicode from flask import json from os.path import dirname @@ -80,9 +81,9 @@ class HubsAPITest(hubs.tests.APPTest): "owners": ["ralph"], "subscribers": [], "summary": "Ralph", - "widgets": [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 51] + "widgets": [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 56] } - self.assertDictEqual(data, json.loads(result.data)) + self.assertDictEqual(data, ast.literal_eval(result.data)) @unittest.skip("Authorization layer not present yet") def test_hub_edit_get_logged_out(self): @@ -262,9 +263,9 @@ class HubsAPITest(hubs.tests.APPTest): def test_hub_edit_widget_get_logged_in(self): user = tests.FakeAuthorization('ralph') with tests.auth_set(app, user): - result = self.app.get('/ralph/31/edit', follow_redirects=True) + result = self.app.get('/ralph/37/edit', follow_redirects=True) self.assertEqual(result.status_code, 200) - expected_str = 'ralph/" + u"edit_url": u"/ralph/57/edit", + u"source_url": u"/source/library", + u"urls": [ + u"ralph/" ], - "widget_url": "/ralph/52" + u"widget_url": u"/ralph/57" }, "description": None, "hub": "ralph",