| |
@@ -206,6 +206,80 @@
|
| |
self.assertEqual(result.status_code, 302)
|
| |
self.assertEqual(urlparse(result.location).path, "/")
|
| |
|
| |
+ def test_hub_add_widget_get_no_args(self):
|
| |
+ result = self.app.get('/ralph/add', follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 400)
|
| |
+ expected_str = 'Invalid position provided'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ def test_hub_add_widget_get_with_args(self):
|
| |
+ result = self.app.get('/ralph/add?position=right',
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(result.status_code, 200)
|
| |
+ expected_str = 'Adding widget to hub: ralph'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+ expected_str = "url: 'add/' + $('#widget').val() + '?position=right',"
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ def test_hub_add_widget_post_no_widget_name(self):
|
| |
+ data = {}
|
| |
+ result = self.app.post('/ralph/add', data=data, follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 400)
|
| |
+ expected_str = 'Invalid request sent'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ def test_hub_add_widget_post_invalid_widget_name(self):
|
| |
+ data = {'widget_name': 'invalid_widget_name'}
|
| |
+ result = self.app.post('/ralph/add', data=data, follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 404)
|
| |
+ expected_str = 'Unknown widget called'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ def test_hub_add_widget_post_valid_widget_name_no_args(self):
|
| |
+ user = tests.FakeAuthorization('ralph')
|
| |
+ with tests.auth_set(app, user):
|
| |
+ data = {'widget_name': 'about'}
|
| |
+ result = self.app.post('/ralph/add', data=data,
|
| |
+ follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 200)
|
| |
+ expected_str = '<h6 class="dropdown-header">Account Information</h6>'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+ expected_str = '<a href="#" class="dropdown-item">Full Name: fullname: ralph</a>'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ def test_hub_add_widget_post_valid_widget_name_with_args(self):
|
| |
+ user = tests.FakeAuthorization('ralph')
|
| |
+ with tests.auth_set(app, user):
|
| |
+ data = {'widget_name': 'about', 'text': 'text of widget'}
|
| |
+ result = self.app.post('/ralph/add', data=data,
|
| |
+ follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 200)
|
| |
+ expected_str = '<h6 class="dropdown-header">Account Information</h6>'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+ expected_str = '<a href="#" class="dropdown-item">Full Name: fullname: ralph</a>'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ 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)
|
| |
+ self.assertEqual(result.status_code, 200)
|
| |
+ expected_str = '<input id="fmn_context" class="form-control" type="text"'
|
| |
+ self.assertTrue(expected_str in result.data)
|
| |
+
|
| |
+ @unittest.skip("Authorization layer not present yet")
|
| |
+ def test_hub_edit_widget_get_logged_out(self):
|
| |
+ result = self.app.get('/ralph/31/edit', follow_redirects=True)
|
| |
+ self.assertEqual(result.status_code, 403)
|
| |
+
|
| |
+ def test_hub_edit_widget_post_empty_data_logged_in(self):
|
| |
+ user = tests.FakeAuthorization('ralph')
|
| |
+ with tests.auth_set(app, user):
|
| |
+ data = {}
|
| |
+ url = '/ralph/31/edit'
|
| |
+ result = self.app.post(url, data=data, follow_redirects=False)
|
| |
+ self.assertEqual(result.status_code, 302)
|
| |
+ self.assertEqual(urlparse(result.location).path, '/ralph/')
|
| |
|
| |
if __name__ == '__main__':
|
| |
unittest.main()
|
| |
fixing skipped tests so they pass and added test for /hub/add test
adding post tests for hub/add/ widget
added hubs edit post with valid minimum valid data
working on hubs edit widget testing Should be at 64% coverage