Exemple #1
0
 def interface(self):
     return Message.to_python(
         dict(
             message='Hello there %s!',
             params=('world', ),
             formatted='Hello there world!',
         ))
Exemple #2
0
 def test_get_hash_uses_formatted(self):
     interface = Message.to_python(dict(
         message=None,
         params=(),
         formatted='Hello there world!'
     ))
     assert interface.get_hash() == [interface.formatted]
Exemple #3
0
 def test_compute_hashes_uses_formatted(self):
     interface = Message.to_python(dict(
         message=None,
         params=(),
         formatted='Hello there world!'
     ))
     assert interface.compute_hashes() == [[interface.formatted]]
Exemple #4
0
 def interface(self):
     return Message.to_python(
         dict(
             message='Hello there %s!',
             params=('world', ),
             formatted='Hello there world!',
         )
     )
Exemple #5
0
 def test_format_braces(self):
     interface = Message.to_python(dict(
         message='Hello there {}!',
         params=('world', ),
     ))
     assert interface.to_json() == {
         'message': interface.message,
         'params': interface.params,
         'formatted': 'Hello there world!'
     }
Exemple #6
0
 def test_format_kwargs(self):
     interface = Message.to_python(dict(
         message='Hello there %(name)s!',
         params={'name': 'world'},
     ))
     assert interface.to_json() == {
         'message': interface.message,
         'params': interface.params,
         'formatted': 'Hello there world!'
     }
Exemple #7
0
 def test_grouping_component_uses_formatted(self):
     interface = Message.to_python(
         dict(message=None, params=(), formatted='Hello there world!'))
     assert interface.get_grouping_component().as_dict() == {
         'hint': None,
         'id': 'message',
         'name': 'message',
         'contributes': True,
         'values': ['Hello there world!'],
     }
Exemple #8
0
 def test_format_braces(self):
     interface = Message.to_python(dict(
         message='Hello there {}!',
         params=('world', ),
     ))
     assert interface.to_json() == {
         'message': interface.message,
         'params': interface.params,
         'formatted': 'Hello there world!'
     }
Exemple #9
0
 def test_format_kwargs(self):
     interface = Message.to_python(dict(
         message='Hello there %(name)s!',
         params={'name': 'world'},
     ))
     assert interface.to_json() == {
         'message': interface.message,
         'params': interface.params,
         'formatted': 'Hello there world!'
     }
Exemple #10
0
 def test_stringify_primitives(self):
     assert Message.to_python({'formatted': 42}).formatted == '42'
     assert Message.to_python({'formatted': True}).formatted == 'true'
     assert Message.to_python({'formatted': 4.2}).formatted == '4.2'
Exemple #11
0
 def test_stringify_primitives(self):
     assert Message.to_python({'formatted': 42}).formatted == '42'
     assert Message.to_python({'formatted': True}).formatted == 'true'
     assert Message.to_python({'formatted': 4.2}).formatted == '4.2'
Exemple #12
0
 def test_get_hash_uses_formatted(self):
     interface = Message.to_python(
         dict(message=None, params=(), formatted='Hello there world!'))
     assert interface.get_hash() == [interface.formatted]