Exemple #1
0
 def test_numbers_int_4k(self):
     s = os.path.join(self.smile_dir, 'numbers-int-4k.smile')
     j = os.path.join(self.json_dir, 'numbers-int-4k.jsn')
     b = json.load(open(j, 'rb'))
     try:
         a = pysmile.decode(open(s, 'rb').read())
     except pysmile.SMILEDecodeError, e:
         self.fail('Failed to decode:\n{!r}\n{!r}'.format(b, e.args[1]))
Exemple #2
0
 def test_json_org_sample5(self):
     s = os.path.join(self.smile_dir, 'json-org-sample5.smile')
     j = os.path.join(self.json_dir, 'json-org-sample5.jsn')
     b = json.load(open(j, 'rb'))
     try:
         a = pysmile.decode(open(s, 'rb').read())
     except pysmile.SMILEDecodeError, e:
         self.fail('Failed to decode:\n{!r}\n{!r}'.format(b, e.args[1]))
Exemple #3
0
 def test_numbers_int_64k(self):
     s = os.path.join(self.smile_dir, 'numbers-int-64k.smile')
     j = os.path.join(self.json_dir, 'numbers-int-64k.jsn')
     b = json.load(open(j, 'rb'))
     try:
         a = pysmile.decode(open(s, 'rb').read())
     except pysmile.SMILEDecodeError, e:
         self.fail('Failed to decode:\n{!r}\n{!r}'.format(b, e.args[1]))
Exemple #4
0
 def test_json_org_sample5(self):
     s = os.path.join(self.smile_dir, 'json-org-sample5.smile')
     j = os.path.join(self.json_dir, 'json-org-sample5.jsn')
     b = json.load(open(j, 'rb'))
     try:
         a = pysmile.decode(open(s, 'rb').read())
     except pysmile.SMILEDecodeError, e:
         self.fail('Failed to decode:\n{!r}\n{!r}'.format(b, e.args[1]))
Exemple #5
0
	def process_sbd_message(self, msg):
		#msg=msg[:140] # truncate message if too long
		#print msg
		#status=self.twitter.PostUpdate(msg)
		#print "%s just posted: %s" % (status.user.name, status.text)
		obj=pysmile.decode(msg)
		for command in obj:
			command, args=obj[0], obj[1:]
			if command=="tw_upd":
				self.tw_upd(args[0])
			elif command=="tw_pm":
				self.tw_pm(args[0], args[1])
			elif command=="sendmail":
				self.sendmail(args[0])
			elif command=="rtoken":
				self.rtoken(args[0], args[1])
			else:
				raise Exception("Unknown command encountered in message")
Exemple #6
0
 def test_6(self):
     a = {'a': {'b': {'c': {'d': ['e']}}}}
     b = pysmile.decode(
         ':)\n\x03\xfa\x80a\xfa\x80b\xfa\x80c\xfa\x80d\xf8@e\xf9\xfb\xfb\xfb\xfb'
     )
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #7
0
 def test_5(self):
     a = {'a': '1', 'b': 2, 'c': [3], 'd': -1, 'e': 4.20}
     b = pysmile.decode(
         ':)\n\x03\xfa\x80a@1\x80c\xf8\xc6\xf9\x80b\xc4\x80e(fL\x19\x04\x04\x80d\xc1\xfb'
     )
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #8
0
 def test_4(self):
     a = {'a': 1}
     b = pysmile.decode(':)\n\x03\xfa\x80a\xc2\xfb')
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #9
0
 def test_3(self):
     a = [1, 2, {'c': 3}]
     b = pysmile.decode(':)\n\x03\xf8\xc2\xc4\xfa\x80c\xc6\xfb\xf9')
     self.assertListEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #10
0
 def test_2(self):
     a = [1, 2]
     b = pysmile.decode(':)\n\x03\xf8\xc2\xc4\xf9')
     self.assertListEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #11
0
 def test_6(self):
     a = {'a': {'b': {'c': {'d': ['e']}}}}
     b = pysmile.decode(
             ':)\n\x03\xfa\x80a\xfa\x80b\xfa\x80c\xfa\x80d\xf8@e\xf9\xfb\xfb\xfb\xfb')
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #12
0
 def test_5(self):
     a = {'a': '1', 'b': 2, 'c': [3], 'd': -1, 'e': 4.20}
     b = pysmile.decode(
         ':)\n\x03\xfa\x80a@1\x80c\xf8\xc6\xf9\x80b\xc4\x80e(fL\x19\x04\x04\x80d\xc1\xfb')
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #13
0
 def test_4(self):
     a = {'a': 1}
     b = pysmile.decode(':)\n\x03\xfa\x80a\xc2\xfb')
     self.assertDictEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #14
0
 def test_3(self):
     a = [1, 2, {'c': 3}]
     b = pysmile.decode(':)\n\x03\xf8\xc2\xc4\xfa\x80c\xc6\xfb\xf9')
     self.assertListEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))
Exemple #15
0
 def test_2(self):
     a = [1, 2]
     b = pysmile.decode(':)\n\x03\xf8\xc2\xc4\xf9')
     self.assertListEqual(a, b, 'Expected:\n{!r}\nGot:\n{!r}'.format(a, b))