Skip to content

Commit

Permalink
first part of test improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
voisardf committed Nov 27, 2023
1 parent f8dd968 commit 0587958
Showing 1 changed file with 0 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,50 +185,3 @@ def query(self, term):

yield Session


def test_get_symbol_binary_content(theme_config, one_result_binary_session, png_binary):
with patch(
'pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=one_result_binary_session()):
body, content_type = get_symbol({'identifier': "1"}, theme_config)
assert content_type == 'image/png'
assert body == b64.decode(binascii.b2a_base64(png_binary).decode('ascii'))


def test_get_symbol_no_symbol_content(theme_config, one_result_no_symbol_session):
with patch(
'pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=one_result_no_symbol_session()):
with pytest.raises(HTTPServerError):
get_symbol({'identifier': "1"}, theme_config)


def test_get_symbol_wrong_param(theme_config, one_result_no_symbol_session):
with patch(
'pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=one_result_no_symbol_session()):
with pytest.raises(HTTPServerError):
get_symbol({'identif': "1"}, theme_config)


def test_get_symbol_no_legend_entry(theme_config, no_result_session):
with patch(
'pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=no_result_session()):
with pytest.raises(HTTPNotFound):
get_symbol({'identifier': "2"}, theme_config)


def test_get_symbol_wrong_content(theme_config, one_result_wrong_content_session):
with patch('pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=one_result_wrong_content_session()):
with pytest.raises(HTTPServerError):
get_symbol({'identifier': "1"}, theme_config)


def test_get_symbol_b64_content(theme_config, one_result_b64_session, png_binary):
with patch('pyramid_oereb.core.adapter.DatabaseAdapter.get_session',
return_value=one_result_b64_session()):
body, content_type = get_symbol({'identifier': "1"}, theme_config)
assert content_type == 'image/png'
assert body == b64.decode(binascii.b2a_base64(png_binary).decode('ascii'))

0 comments on commit 0587958

Please sign in to comment.