forked from d-dd/Yukari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cyClientMisc.py
47 lines (40 loc) · 1.63 KB
/
test_cyClientMisc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
from cyClient import CyProtocol
from ext.rinception import Lr
class TestParseAdd(unittest.TestCase):
def setUp(self):
self.prot = CyProtocol()
def test(self):
command = '-u yukarin -t Kasane Teto -n 3 -T true -n true'
title = self.prot.parseTitle(command)
correct = ('Kasane Teto', '-u yukarin -n 3 -T true -n true')
self.assertEqual(title, correct)
command = '-u yukarin -t Kasane Teto -n 3 -T true -n true'
title = self.prot.parseTitle(command)
correct = (' Kasane Teto', '-u yukarin -n 3 -T true -n true')
self.assertEqual(title, correct)
command = '-t Kasane Teto'
title = self.prot.parseTitle(command)
self.assertEqual(title, ('Kasane Teto', ''))
command = '-u yukarin -t Kasane Teto'
title = self.prot.parseTitle(command)
self.assertEqual(title, ('Kasane Teto', '-u yukarin '))
command = '-n 2'
title = self.prot.parseTitle(command)
self.assertEqual(title, (None, '-n 2'))
class TestParseDict(unittest.TestCase):
def setUp(self):
self.rec = Lr(None)
def test(self):
requestd = {"callType":"mediaById", "args":{"mediaId":123}}
req = self.rec.parseDict(requestd)
callType, args = req
self.assertEqual(callType, 'mediaById')
self.assertEqual(args, {'mediaId':123})
###
requestd = {"calltype":"mediaById", "args":{"mediaId":123}}
req = self.rec.parseDict(requestd)
self.assertEqual(req, False)
if __name__ == '__main__':
unittest.main()
#request = '{"callType":"mediaById", "args":"{"mediaId":123}}'