forked from ObjectProfile/PythonBridge
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPBDeserializeTest.class.st
More file actions
69 lines (60 loc) · 1.94 KB
/
PBDeserializeTest.class.st
File metadata and controls
69 lines (60 loc) · 1.94 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Class {
#name : #PBDeserializeTest,
#superclass : #TestCase,
#instVars : [
'mapper',
'application'
],
#category : #'PythonBridge-Tests'
}
{ #category : #running }
PBDeserializeTest >> application [
^ application ifNil: [ application := PBStubApplication new ]
]
{ #category : #running }
PBDeserializeTest >> deserialize: anObject [
^ self deserializer deserialize: anObject
]
{ #category : #running }
PBDeserializeTest >> deserializer [
^ mapper deserializer
serializerWrapper: PBPlatform current class httpMessageBrokerClass serializer;
yourself
]
{ #category : #running }
PBDeserializeTest >> setUp [
super setUp.
mapper := LanguageLinkMapperFactory forExecutionHandler: self stubExecutionHandler
]
{ #category : #running }
PBDeserializeTest >> stubExecutionHandler [
^ PBExecutionHandler application: self application
]
{ #category : #tests }
PBDeserializeTest >> testDeserializeArray [
self assert: (self deserialize: '[33,"foo"]') equals: #(33 'foo')
]
{ #category : #tests }
PBDeserializeTest >> testDeserializeNull [
self assert: (self deserialize: 'null') equals: nil
]
{ #category : #tests }
PBDeserializeTest >> testDeserializeProxy [
| proxy |
proxy := self deserialize: '{"__pyclass__":"MyClass","__pyid__":"abcde12345"}'.
self assert: proxy pythonClass equals: #MyClass.
self assert: proxy application equals: self deserializer application.
self assert: proxy application equals: self application.
self assert: proxy pythonVariable equals: 'abcde12345' asP3GI
]
{ #category : #tests }
PBDeserializeTest >> testDeserializeProxyInArray [
| proxy arr |
arr := self deserialize: '[{"__pyclass__":"MyClass","__pyid__":"abcde12345"}]'.
self assert: arr size equals: 1.
proxy := arr first.
self assert: proxy pythonClass equals: #MyClass.
self assert: proxy application equals: self deserializer application.
self assert: proxy application equals: self application.
self assert: proxy pythonVariable equals: 'abcde12345' asP3GI
]