forked from jsgoecke/tesla
-
Notifications
You must be signed in to change notification settings - Fork 18
/
commands_test.go
155 lines (127 loc) · 4.16 KB
/
commands_test.go
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package tesla
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
var (
CommandResponseJSON = `{"response":{"reason":"","result":true}}`
WakeupResponseJSON = `{"response":{"color":null,"display_name":"Macak","id":900,"option_codes":"MS04,RENA,AU01,BC0R,BP01,BR01,BS00,CDM0,CH00,PBSB,CW02,DA02,DCF0,DRLH,DSH7,DV4W,FG02,HP00,IDPB,IX01,LP01,ME02,MI00,PA00,PF01,PI01,PK00,PS01,PX00,PX4D,QNEB,RFP2,SC01,SP00,SR01,SU01,TM00,TP03,TR01,UTAB,WTSG,WTX0,X001,X003,X007,X011,X013,X019,X024,X027,X028,X031,X037,X040,YF01,COUS","user_id":789,"vehicle_id":456,"vin":"abc123","tokens":["1","2"],"state":"online","id_s":"123","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true,"backseat_token":null,"backseat_token_updated_at":null}}`
ChargeAlreadySetJSON = `{"response":{"reason":"already_standard","result":false}}`
ChargedJSON = `{"response":{"reason":"complete","result":false}}`
)
func TestCommandsSpec(t *testing.T) {
ts := serveHTTP(t)
defer ts.Close()
client := NewTestClient(ts)
vehicles, err := client.Vehicles()
if err != nil {
t.Fatal(err)
}
vehicle := vehicles[0]
Convey("Should auto park abort Autopark", t, func() {
err := vehicle.AutoparkAbort()
So(err, ShouldBeNil)
})
Convey("Should auto park car forward", t, func() {
err := vehicle.AutoparkForward()
So(err, ShouldBeNil)
})
Convey("Should auto park car reverse", t, func() {
err := vehicle.AutoparkReverse()
So(err, ShouldBeNil)
})
Convey("Should turn on sentry mode", t, func() {
err := vehicle.EnableSentry()
So(err, ShouldBeNil)
})
Convey("Should toggle the garage door based on Homelink", t, func() {
err := vehicle.TriggerHomelink()
So(err, ShouldBeNil)
})
Convey("Should wakeup the car", t, func() {
_, err := vehicle.Wakeup()
So(err, ShouldBeNil)
})
Convey("Should flash lights", t, func() {
err := vehicle.FlashLights()
So(err, ShouldBeNil)
})
Convey("Should honk the horn", t, func() {
err := vehicle.HonkHorn()
So(err, ShouldBeNil)
})
Convey("Should open the charge port", t, func() {
err := vehicle.OpenChargePort()
So(err, ShouldBeNil)
})
Convey("Should reset the valet pin", t, func() {
err := vehicle.ResetValetPIN()
So(err, ShouldBeNil)
})
Convey("Should set the car charge limit", t, func() {
err := vehicle.SetChargeLimit(50)
So(err, ShouldBeNil)
})
Convey("Should set the car to standard charge level", t, func() {
err := vehicle.SetChargeLimitStandard()
So(err.Error(), ShouldEqual, "already_standard")
})
Convey("Should set the car charging amps", t, func() {
err := vehicle.SetChargingAmps(12)
So(err, ShouldBeNil)
})
Convey("Should attempt to charge the car", t, func() {
err := vehicle.StartCharging()
So(err.Error(), ShouldEqual, "complete")
})
Convey("Should attempt to stop charging the car", t, func() {
err := vehicle.StopCharging()
So(err, ShouldBeNil)
})
Convey("Should set charge limit maximum", t, func() {
err := vehicle.SetChargeLimitMax()
So(err, ShouldBeNil)
})
Convey("Should set air conditioning on", t, func() {
err := vehicle.StartAirConditioning()
So(err, ShouldBeNil)
})
Convey("Should set air conditioning off", t, func() {
err := vehicle.StopAirConditioning()
So(err, ShouldBeNil)
})
Convey("Should unlock the doors", t, func() {
err := vehicle.UnlockDoors()
So(err, ShouldBeNil)
})
Convey("Should lock the doors", t, func() {
err := vehicle.LockDoors()
So(err, ShouldBeNil)
})
Convey("Should set the temperature", t, func() {
err := vehicle.SetTemperature(72.0, 72.0)
So(err, ShouldBeNil)
})
Convey("Should start the car", t, func() {
err := vehicle.Start("foo")
So(err, ShouldBeNil)
})
Convey("Should move the Pano Roof around", t, func() {
Convey("Should vent the pano roof", func() {
err := vehicle.MovePanoRoof("vent", 0)
So(err, ShouldBeNil)
})
Convey("Should open the pano roof", func() {
err := vehicle.MovePanoRoof("open", 0)
So(err, ShouldBeNil)
})
Convey("Should move the pano roof to 50", func() {
err := vehicle.MovePanoRoof("move", 50)
So(err, ShouldBeNil)
})
Convey("Should close the pano roof", func() {
err := vehicle.MovePanoRoof("close", 0)
So(err, ShouldBeNil)
})
})
}