<s> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import unittest <EOL> from ddp . messages . server . result_message import ResultMessage <EOL> from ddp . messages . server . result_message_parser import ResultMessageParser <EOL> class ResultMessageParserTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . parser = ResultMessageParser ( ) <EOL> self . id = '<STR_LIT:id>' <EOL> self . error = '<STR_LIT:error>' <EOL> self . result = { '<STR_LIT:result>' : [ True , <NUM_LIT:1.0> ] } <EOL> def test_with_error ( self ) : <EOL> message = self . parser . parse ( { '<STR_LIT>' : '<STR_LIT:result>' , '<STR_LIT:id>' : self . id , <EOL> '<STR_LIT:error>' : self . error } ) <EOL> self . assertEqual ( message , ResultMessage ( self . id , error = self . error ) ) <EOL> def test_with_result ( self ) : <EOL> message = self . parser . parse ( { '<STR_LIT>' : '<STR_LIT:result>' , '<STR_LIT:id>' : self . id , <EOL> '<STR_LIT:result>' : self . result } ) <EOL> self . assertEqual ( message , ResultMessage ( self . id , result = self . result ) ) <EOL> def test_with_error_with_result ( self ) : <EOL> with self . assertRaises ( ValueError ) : <EOL> self . parser . parse ( { '<STR_LIT>' : '<STR_LIT:result>' , '<STR_LIT:id>' : self . id , <EOL> '<STR_LIT:error>' : self . error , '<STR_LIT:result>' : self . result } ) <EOL> def test_without_error_without_reuslt ( self ) : <EOL> message = self . parser . parse ( { '<STR_LIT>' : '<STR_LIT:result>' , '<STR_LIT:id>' : self . id } ) <EOL> self . assertEqual ( message , ResultMessage ( self . id ) ) </s>
