diff options
author | Mikhail Zabaluev <mikhail.zabaluev@nokia.com> | 2011-01-03 17:56:45 +0200 |
---|---|---|
committer | Mikhail Zabaluev <mikhail.zabaluev@nokia.com> | 2011-01-03 17:56:45 +0200 |
commit | 79ff96db9d46dfe0c94442b954cf8b5c67b7df0b (patch) | |
tree | a7c8f2d5ffa5d7a1fdd6d04c8a9270ef44b50d0f | |
parent | 248b7a0c9b0efac2653c3e2659cbec1eda01d238 (diff) |
Test the message-sent timestamp header with a fixed value
-rw-r--r-- | tests/twisted/test-message.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/twisted/test-message.py b/tests/twisted/test-message.py index 055cccf..01c401c 100644 --- a/tests/twisted/test-message.py +++ b/tests/twisted/test-message.py @@ -6,6 +6,7 @@ from sofiatest import go, exec_test import twisted.protocols.sip import dbus +import email.utils import time import uuid @@ -87,7 +88,7 @@ def test(q, bus, conn, sip): conn.ReleaseHandles(1, [handle]) call_id = 'XYZ@localhost' - send_message(sip, ua_via, 'Hi', call_id=call_id) + send_message(sip, ua_via, 'Hi', call_id=call_id, time=1234567890) incoming_obj, handle = test_new_channel (q, bus, conn, target_uri=FROM_URL, @@ -104,7 +105,7 @@ def test(q, bus, conn, sip): now = time.time() assert msg[0]['message-token'] == "%s;cseq=%u" % (call_id, cseq_num) assert now - 10 < msg[0]['message-received'] < now + 10 - assert now - 10 < msg[0]['message-sent'] < now + 10 + assert msg[0]['message-sent'] == 1234567890 assert msg[1]['content-type'] == 'text/plain' assert msg[1]['content'] == 'Hi' @@ -202,7 +203,7 @@ def test(q, bus, conn, sip): cseq_num = 1 def send_message(sip, destVia, body, - encoding=None, sender=FROM_URL, call_id=None): + encoding=None, sender=FROM_URL, call_id=None, time=None): global cseq_num cseq_num += 1 url = twisted.protocols.sip.parseURL('sip:testacc@127.0.0.1') @@ -218,7 +219,8 @@ def send_message(sip, destVia, body, msg.addHeader('content-type', 'text/plain; charset=%s' % encoding) msg.addHeader('content-length', '%d' % len(msg.body)) msg.addHeader('call-id', call_id or uuid.uuid4().hex) - msg.addHeader('date', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())) + if time is not None: + msg.addHeader('date', email.utils.formatdate(time, False, True)) via = sip.getVia() via.branch = 'z9hG4bKXYZ' msg.addHeader('via', via.toString()) |