Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

1 changed file:

Changes:

  • test/unit/test_delay_parsing.py
    1
    +import unittest
    
    2
    +
    
    3
    +from nbxmpp.protocol import Node
    
    4
    +from nbxmpp.modules.delay import parse_delay
    
    5
    +
    
    6
    +class TestHelpers(unittest.TestCase):
    
    7
    +
    
    8
    +    def test_parse_delay(self):
    
    9
    +
    
    10
    +        node = """
    
    11
    +        <message>
    
    12
    +            <delay xmlns='urn:xmpp:delay' from='capulet.com' stamp='2002-09-10T23:08:25Z' />
    
    13
    +            <delay xmlns='urn:xmpp:delay' from='romeo.com' stamp='2010-09-10T23:08:25Z' />
    
    14
    +            <delay xmlns='urn:xmpp:delay' stamp='2015-09-10T23:08:25Z' />
    
    15
    +        </message>
    
    16
    +        """
    
    17
    +        message = Node(node=node)
    
    18
    +
    
    19
    +        timestamp = parse_delay(message)
    
    20
    +        self.assertEqual(timestamp, 1031699305.0)
    
    21
    +
    
    22
    +        timestamp = parse_delay(message, from_=['capulet.com'])
    
    23
    +        self.assertEqual(timestamp, 1031699305.0)
    
    24
    +
    
    25
    +        timestamp = parse_delay(message, from_=['romeo.com'])
    
    26
    +        self.assertEqual(timestamp, 1284160105.0)
    
    27
    +
    
    28
    +        timestamp = parse_delay(message, not_from=['romeo.com'])
    
    29
    +        self.assertEqual(timestamp, 1031699305.0)