|
| 1 | +from unittest.mock import patch |
| 2 | + |
| 3 | +from tapipy.errors import BaseTapyException |
| 4 | + |
| 5 | +from portal.apps.site_search.api.views import SiteSearchApiView |
| 6 | + |
| 7 | + |
1 | 8 | def test_search_unauthenticated(client, regular_user):
|
2 |
| - response = client.get('/search/') |
| 9 | + response = client.get("/search/") |
3 | 10 | assert response.status_code == 200
|
4 |
| - assert response.context['setup_complete'] is False |
| 11 | + assert response.context["setup_complete"] is False |
5 | 12 |
|
6 | 13 |
|
7 | 14 | def test_search_authenticated_without_setup_complete(client, authenticated_user):
|
8 |
| - response = client.get('/search/') |
| 15 | + response = client.get("/search/") |
9 | 16 | assert response.status_code == 200
|
10 |
| - assert response.context['setup_complete'] is False |
| 17 | + assert response.context["setup_complete"] is False |
11 | 18 |
|
12 | 19 |
|
13 | 20 | def test_search_authenticated_with_setup_complete(client, authenticated_user):
|
14 | 21 | authenticated_user.profile.setup_complete = True
|
15 | 22 | authenticated_user.profile.save()
|
16 |
| - response = client.get('/search/') |
| 23 | + response = client.get("/search/") |
17 | 24 | assert response.status_code == 200
|
18 |
| - assert response.context['setup_complete'] |
| 25 | + assert response.context["setup_complete"] |
| 26 | + |
| 27 | + |
| 28 | +@patch("portal.apps.site_search.api.views.logger") |
| 29 | +def test_handle_tapis_ssh_exception_files_client_ssh_op_err1(mock_logger): |
| 30 | + view = SiteSearchApiView() |
| 31 | + message = "FILES_CLIENT_SSH_OP_ERR1" |
| 32 | + exception = BaseTapyException(message) |
| 33 | + view._handle_tapis_ssh_exception(exception) |
| 34 | + mock_logger.exception.assert_called_once_with( |
| 35 | + f"Error retrieving search results due to TAPIS SSH related error: message: {message}" |
| 36 | + ) |
0 commit comments