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