~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-28 10:45:53 UTC
  • mfrom: (1829 trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: coles.david@gmail.com-20100728104553-5z3nxt0l6kyfqfh5
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

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