Skip to content

Commit

Permalink
Merge pull request #317 from ror-community/upgrade-es7
Browse files Browse the repository at this point in the history
mock search response in test
  • Loading branch information
lizkrznarich committed Apr 18, 2023
2 parents 134dc03 + 361507e commit a5d40bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rorapi/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def test_invalid_search_organizations(self, search_mock):
self.assertEquals(list(organizations.keys()), ['errors'])
self.assertEquals(len(organizations['errors']), 6)

def test_query_redirect(self):
@mock.patch('elasticsearch_dsl.Search.execute')
def test_query_redirect(self, search_mock):
client = Client()
search_mock.return_value = \
IterableAttrDict(self.test_data, self.test_data['hits']['hits'])

response = client.get('/organizations?query.name=query')
self.assertRedirects(response, '/organizations?query=query')
Expand Down Expand Up @@ -131,8 +134,11 @@ def test_invalid_search_organizations(self, search_mock):
self.assertEquals(list(organizations.keys()), ['errors'])
self.assertEquals(len(organizations['errors']), 6)

def test_query_redirect(self):
@mock.patch('elasticsearch_dsl.Search.execute')
def test_query_redirect(self, search_mock):
client = Client()
search_mock.return_value = \
IterableAttrDict(self.test_data, self.test_data['hits']['hits'])

response = client.get('/organizations?query.name=query')
self.assertRedirects(response, '/organizations?query=query')
Expand Down

0 comments on commit a5d40bf

Please sign in to comment.