<s> import unittest <EOL> import json <EOL> from lib . search . result import SearchResult <EOL> class TestResponse ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . search_result_json = """<STR_LIT>""" <EOL> self . search_result_json_huge_title = """<STR_LIT>""" <EOL> def test_parse_json ( self ) : <EOL> res = SearchResult ( ) <EOL> try : <EOL> res . parse_json ( json . loads ( self . search_result_json ) . get ( '<STR_LIT:message>' ) ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_parse_json_validate_results ( self ) : <EOL> res = SearchResult ( ) <EOL> res . parse_json ( json . loads ( self . search_result_json ) . get ( '<STR_LIT:message>' ) ) <EOL> self . assertEqual ( res . get_doi ( ) . get_identifier ( ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( res . get_score ( ) , <NUM_LIT:1.0> ) <EOL> self . assertEqual ( res . get_title ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( res . get_year ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( res . get_authors ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( res . get_type ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( res . get_publisher ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( res . get_url ( ) , '<STR_LIT>' ) <EOL> def test_parse_json_check_title_format ( self ) : <EOL> res = SearchResult ( ) <EOL> res . parse_json ( <EOL> json . loads ( self . search_result_json_huge_title ) . get ( '<STR_LIT:message>' ) ) <EOL> self . assertEqual ( res . get_title ( ) , "<STR_LIT>" ) <EOL> def test_parse_json_with_unknown_title ( self ) : <EOL> res = SearchResult ( ) <EOL> j = json . loads ( self . search_result_json ) . get ( '<STR_LIT:message>' ) <EOL> j [ '<STR_LIT:title>' ] = '<STR_LIT>' <EOL> res . parse_json ( j ) <EOL> self . assertEqual ( res . get_title ( ) , res . UNKNOWN_TITLE ) <EOL> def test_parse_json_with_unknown_year ( self ) : <EOL> res = SearchResult ( ) <EOL> j = json . loads ( self . search_result_json_huge_title ) . get ( '<STR_LIT:message>' ) <EOL> j [ '<STR_LIT>' ] = [ ] <EOL> res . parse_json ( j ) <EOL> self . assertEqual ( res . get_year ( ) , res . UNKNOWN_YEAR ) <EOL> def test_parse_json_with_unknown_authors ( self ) : <EOL> res = SearchResult ( ) <EOL> j = json . loads ( self . search_result_json_huge_title ) . get ( '<STR_LIT:message>' ) <EOL> j [ '<STR_LIT>' ] = [ ] <EOL> res . parse_json ( j ) <EOL> self . assertEqual ( res . get_authors ( ) , res . UNKNOWN_AUTHORS ) </s>
