Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix dashboard model errors, change deprecated pytest function #160

Merged
merged 4 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/unit/api/dashboard/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def mock_proxy_results() -> Dashboard:

def mock_json_response() -> dict:
return {
"chart_names": [],
"uri": 'dashboard_uri',
"cluster": 'gold',
"group_name": 'mode_dashboard_group',
Expand All @@ -32,6 +33,7 @@ def mock_json_response() -> dict:

def default_json_response() -> dict:
return {
"chart_names": [],
"uri": None,
"cluster": None,
"group_name": None,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/document/test_document_table_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def test_delete(self, get_proxy: MagicMock, RequestParser: MagicMock) -> None:
def test_should_not_reach_delete_without_id(self) -> None:
response = self.app.test_client().delete('/document_table')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)
4 changes: 2 additions & 2 deletions tests/unit/api/document/test_document_tables_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def test_put(self, get_proxy: MagicMock, RequestParser: MagicMock) -> None:
def test_should_not_reach_create_with_id(self) -> None:
response = self.app.test_client().post('/document_table/1')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)

def test_should_not_reach_update_with_id(self) -> None:
response = self.app.test_client().put('/document_table/1')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)
2 changes: 1 addition & 1 deletion tests/unit/api/document/test_document_user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def test_delete(self, get_proxy: MagicMock, RequestParser: MagicMock) -> None:
def test_should_not_reach_delete_without_id(self) -> None:
response = self.app.test_client().delete('/document_user')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)
4 changes: 2 additions & 2 deletions tests/unit/api/document/test_document_users_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def test_put(self, get_proxy: MagicMock, RequestParser: MagicMock) -> None:
def test_should_not_reach_create_with_id(self) -> None:
response = self.app.test_client().post('/document_user/1')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)

def test_should_not_reach_update_with_id(self) -> None:
response = self.app.test_client().put('/document_user/1')

self.assertEquals(response.status_code, 405)
self.assertEqual(response.status_code, 405)
2 changes: 1 addition & 1 deletion tests/unit/proxy/test_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_search_normal(self) -> None:

with patch.object(self.proxy.atlas.search_basic, 'create', result):
resp = self.proxy.fetch_table_search_results(query_term="Table")
self.assertEquals(resp.total_results, 1)
self.assertEqual(resp.total_results, 1)
self.assertIsInstance(resp.results[0], Table, "Search result received is not of 'Table' type!")
self.assertDictEqual(vars(resp.results[0]), vars(expected.results[0]),
"Search Result doesn't match with expected result!")
Expand Down
62 changes: 31 additions & 31 deletions tests/unit/proxy/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def test_search_with_one_table_result(self,

resp = self.es_proxy.fetch_table_search_results(query_term='test_query_term')

self.assertEquals(resp.total_results, expected.total_results,
"search result is not of length 1")
self.assertEqual(resp.total_results, expected.total_results,
"search result is not of length 1")
self.assertIsInstance(resp.results[0],
Table,
"Search result received is not of 'Table' type!")
Expand Down Expand Up @@ -280,8 +280,8 @@ def test_search_with_multiple_result(self,

resp = self.es_proxy.fetch_table_search_results(query_term='test_query_term')

self.assertEquals(resp.total_results, expected.total_results,
"search result is not of length 2")
self.assertEqual(resp.total_results, expected.total_results,
"search result is not of length 2")
for i in range(2):
self.assertIsInstance(resp.results[i],
Table,
Expand Down Expand Up @@ -320,15 +320,15 @@ def test_search_table_filter(self, mock_search: MagicMock) -> None:
}
resp = self.es_proxy.fetch_search_results_with_filter(search_request=search_request, query_term='test')

self.assertEquals(resp.total_results, expected.total_results)
self.assertEqual(resp.total_results, expected.total_results)
self.assertIsInstance(resp.results[0], Table)
self.assertDictEqual(vars(resp.results[0]), vars(expected.results[0]))

def test_search_table_filter_return_no_results_if_no_search_request(self) -> None:
resp = self.es_proxy.fetch_search_results_with_filter(search_request=None, query_term='test')

self.assertEquals(resp.total_results, 0)
self.assertEquals(resp.results, [])
self.assertEqual(resp.total_results, 0)
self.assertEqual(resp.results, [])

def test_search_table_filter_return_no_results_if_dsl_conversion_error(self) -> None:
search_request = {
Expand All @@ -340,14 +340,14 @@ def test_search_table_filter_return_no_results_if_dsl_conversion_error(self) ->
resp = self.es_proxy.fetch_search_results_with_filter(search_request=search_request,
query_term='test')

self.assertEquals(resp.total_results, 0)
self.assertEquals(resp.results, [])
self.assertEqual(resp.total_results, 0)
self.assertEqual(resp.results, [])

def test_get_model_by_index_table(self) -> None:
self.assertEquals(self.es_proxy.get_model_by_index(TABLE_INDEX), Table)
self.assertEqual(self.es_proxy.get_model_by_index(TABLE_INDEX), Table)

def test_get_model_by_index_user(self) -> None:
self.assertEquals(self.es_proxy.get_model_by_index(USER_INDEX), User)
self.assertEqual(self.es_proxy.get_model_by_index(USER_INDEX), User)

def test_get_model_by_index_raise_exception(self) -> None:
self.assertRaises(Exception, self.es_proxy.convert_query_json_to_query_dsl, 'some_fake_index')
Expand All @@ -365,15 +365,15 @@ def test_parse_filters_return_results(self) -> None:
"AND name.raw:(*amundsen*) " \
"AND column_names.raw:(*ds*) " \
"AND tags:(test-tag)"
self.assertEquals(self.es_proxy.parse_filters(filter_list,
index=TABLE_INDEX), expected_result)
self.assertEqual(self.es_proxy.parse_filters(filter_list,
index=TABLE_INDEX), expected_result)

def test_parse_filters_return_no_results(self) -> None:
filter_list = {
'unsupported_category': ['fake']
}
self.assertEquals(self.es_proxy.parse_filters(filter_list,
index=TABLE_INDEX), '')
self.assertEqual(self.es_proxy.parse_filters(filter_list,
index=TABLE_INDEX), '')

def test_validate_wrong_filters_values(self) -> None:
search_request = {
Expand All @@ -385,7 +385,7 @@ def test_validate_wrong_filters_values(self) -> None:
"query_term": "",
"page_index": 0
}
self.assertEquals(self.es_proxy.validate_filter_values(search_request), False)
self.assertEqual(self.es_proxy.validate_filter_values(search_request), False)

def test_validate_accepted_filters_values(self) -> None:
search_request = {
Expand All @@ -397,16 +397,16 @@ def test_validate_accepted_filters_values(self) -> None:
"query_term": "a",
"page_index": 0
}
self.assertEquals(self.es_proxy.validate_filter_values(search_request), True)
self.assertEqual(self.es_proxy.validate_filter_values(search_request), True)

def test_parse_query_term(self) -> None:
term = 'test'
expected_result = "(name:(*test*) OR name:(test) OR schema:(*test*) OR " \
"schema:(test) OR description:(*test*) OR description:(test) OR " \
"column_names:(*test*) OR column_names:(test) OR " \
"column_descriptions:(*test*) OR column_descriptions:(test))"
self.assertEquals(self.es_proxy.parse_query_term(term,
index=TABLE_INDEX), expected_result)
self.assertEqual(self.es_proxy.parse_query_term(term,
index=TABLE_INDEX), expected_result)

def test_convert_query_json_to_query_dsl_term_and_filters(self) -> None:
term = 'test'
Expand All @@ -427,7 +427,7 @@ def test_convert_query_json_to_query_dsl_term_and_filters(self) -> None:
ret_result = self.es_proxy.convert_query_json_to_query_dsl(search_request=search_request,
query_term=term,
index=TABLE_INDEX)
self.assertEquals(ret_result, expected_result)
self.assertEqual(ret_result, expected_result)

def test_convert_query_json_to_query_dsl_no_term(self) -> None:
term = ''
Expand All @@ -443,7 +443,7 @@ def test_convert_query_json_to_query_dsl_no_term(self) -> None:
ret_result = self.es_proxy.convert_query_json_to_query_dsl(search_request=search_request,
query_term=term,
index=TABLE_INDEX)
self.assertEquals(ret_result, expected_result)
self.assertEqual(ret_result, expected_result)

def test_convert_query_json_to_query_dsl_no_filters(self) -> None:
term = 'test'
Expand All @@ -456,7 +456,7 @@ def test_convert_query_json_to_query_dsl_no_filters(self) -> None:
ret_result = self.es_proxy.convert_query_json_to_query_dsl(search_request=search_request,
query_term=term,
index=TABLE_INDEX)
self.assertEquals(ret_result, expected_result)
self.assertEqual(ret_result, expected_result)

def test_convert_query_json_to_query_dsl_raise_exception_no_term_or_filters(self) -> None:
term = ''
Expand Down Expand Up @@ -490,8 +490,8 @@ def test_search_with_one_user_result(self,
resp = self.es_proxy.fetch_user_search_results(query_term='test_query_term',
index='user_search_index')

self.assertEquals(resp.total_results, expected.total_results,
"search result is not of length 1")
self.assertEqual(resp.total_results, expected.total_results,
"search result is not of length 1")
self.assertIsInstance(resp.results[0],
User,
"Search result received is not of 'Table' type!")
Expand All @@ -502,7 +502,7 @@ def test_create_document_with_no_data(self) -> None:
expected = ''
result = self.es_proxy.create_document(data=None, index='table_search_index')
print('result: {}'.format(result))
self.assertEquals(expected, result)
self.assertEqual(expected, result)

@patch('uuid.uuid4')
def test_create_document(self, mock_uuid: MagicMock) -> None:
Expand Down Expand Up @@ -576,13 +576,13 @@ def test_create_document(self, mock_uuid: MagicMock) -> None:

expected_alias = 'table_search_index'
result = self.es_proxy.create_document(data=start_data, index=expected_alias)
self.assertEquals(expected_alias, result)
self.assertEqual(expected_alias, result)
mock_elasticsearch.bulk.assert_called_with(expected_data)

def test_update_document_with_no_data(self) -> None:
expected = ''
result = self.es_proxy.update_document(data=None, index='table_search_index')
self.assertEquals(expected, result)
self.assertEqual(expected, result)

@patch('uuid.uuid4')
def test_update_document(self, mock_uuid: MagicMock) -> None:
Expand Down Expand Up @@ -628,7 +628,7 @@ def test_update_document(self, mock_uuid: MagicMock) -> None:
}
]
result = self.es_proxy.update_document(data=data, index=expected_alias)
self.assertEquals(expected_alias, result)
self.assertEqual(expected_alias, result)
mock_elasticsearch.bulk.assert_called_with(expected_data)

@patch('uuid.uuid4')
Expand All @@ -646,7 +646,7 @@ def test_delete_table_document(self, mock_uuid: MagicMock) -> None:
]
result = self.es_proxy.delete_document(data=data, index=expected_alias)

self.assertEquals(expected_alias, result)
self.assertEqual(expected_alias, result)
mock_elasticsearch.bulk.assert_called_with(expected_data)

@patch('uuid.uuid4')
Expand All @@ -664,7 +664,7 @@ def test_delete_user_document(self, mock_uuid: MagicMock) -> None:
]
result = self.es_proxy.delete_document(data=data, index=expected_alias)

self.assertEquals(expected_alias, result)
self.assertEqual(expected_alias, result)
mock_elasticsearch.bulk.assert_called_with(expected_data)

def test_get_instance_string(self) -> None:
Expand Down Expand Up @@ -712,7 +712,7 @@ def test_fetch_dashboard_search_results(self,
resp = self.es_proxy.fetch_dashboard_search_results(query_term='test_query_term',
page_index=0,
index='dashboard_search_index')
self.assertEquals(resp.total_results, expected.total_results)
self.assertEqual(resp.total_results, expected.total_results)

self.assertDictEqual(vars(resp.results[0]),
vars(expected.results[0]),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def tearDown(self) -> None:

def test_should_get_swagger_docs(self) -> None:
response = self.app.test_client().get('/apidocs/')
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_should_get_swagger_json(self) -> None:
response = self.app.test_client().get('/apispec_1.json')

self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_should_have_a_component_from_each_reference(self) -> None:
response = self.app.test_client().get('/apispec_1.json')
Expand Down