Exemplo n.º 1
0
 def interface(self):
     return Message.to_python(
         dict(
             message='Hello there %s!',
             params=('world', ),
             formatted='Hello there world!',
         ))
Exemplo n.º 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]
Exemplo n.º 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]]
Exemplo n.º 4
0
 def interface(self):
     return Message.to_python(
         dict(
             message='Hello there %s!',
             params=('world', ),
             formatted='Hello there world!',
         )
     )
Exemplo n.º 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!'
     }
Exemplo n.º 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!'
     }
Exemplo n.º 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!'],
     }
Exemplo n.º 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!'
     }
Exemplo n.º 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!'
     }
Exemplo n.º 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'
Exemplo n.º 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'
Exemplo n.º 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]