~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/tests/test_chat.py

  • Committer: David Coles
  • Date: 2010-07-17 11:32:50 UTC
  • Revision ID: coles.david@gmail.com-20100717113250-vi18n50bcjmfmzrt
Show warning for CGI header field-names which contain restricted characters.

Forbidden characters are the separators defined by RFC3875. This is mainly to 
fix an issue where printing a dictionary (with no CGI headers) could be 
assumed to be a CGI header with no warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import random
21
21
 
22
 
try:
23
 
    import json
24
 
except ImportError:
25
 
    import simplejson as json
26
 
 
 
22
import cjson
27
23
from nose.tools import assert_equal, raises
28
24
 
29
25
import ivle.chat
97
93
        """
98
94
        MESSAGE = {}
99
95
        MAGIC = "3EE"
100
 
        content = json.dumps(MESSAGE)
 
96
        content = cjson.encode(MESSAGE)
101
97
        # Digest can be formed with `echo -n "${content}${MAGIC}" | md5sum`
102
98
        DIGEST = '2b59b68e1ac0852b87fb7e64946f2658'
103
99
        expected = {'digest': DIGEST,
104
100
                'content': content}
105
101
        encoded = ivle.chat.encode(MESSAGE, MAGIC)
106
 
        assert_equal(json.loads(encoded), expected)
 
102
        assert_equal(cjson.decode(encoded), expected)
107
103
 
108
104
    def test_encode_decode(self):
109
105
        """Check that a round trip encoding and decoding works