-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmediaphoto_test.go
255 lines (245 loc) · 7.89 KB
/
mediaphoto_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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package goprowifi
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestClient_GetPhotoInformation(t *testing.T) {
type fields struct {
myDoer Doer
}
type args struct {
folder string
file string
}
tests := []struct {
name string
fields fields
args args
wantReply PhotoInformation
wantHTTPStatus int
wantErr error
}{
{
name: "Hero5 OK",
fields: fields{
myDoer: testDoer{
responseCode: 200,
response: `{
"cre": "1539960075",
"s": "3843146",
"hc": "0",
"us": "0",
"eis": "0",
"wdr": "0",
"raw": "0",
"tr": "0",
"gumi": "96f1af231bed1a6e5e81fb46f0738678",
"w": "4000",
"h": "3000"
}`,
},
},
args: args{
folder: "100GOPRO",
file: "GOPR1147.JPG",
},
wantReply: PhotoInformation{
EpochTimestamp: "1539960075",
Eis: "0",
Gumi: "96f1af231bed1a6e5e81fb46f0738678",
Hight: "3000",
Hc: "0",
Raw: "0",
S: "3843146",
Tr: "0",
Us: "0",
Width: "4000",
Wdr: "0",
},
wantHTTPStatus: 200,
wantErr: nil,
// wantErr: errors.New("got false response"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
hero := CreateTestRestClient(tt.fields.myDoer)
gotReply, gotHTTPStatus, err := hero.GetPhotoInformation(tt.args.folder, tt.args.file)
if err == nil {
assert.Equal(t, tt.wantHTTPStatus, gotHTTPStatus, "HTTPStatus did not match")
assert.Equal(t, tt.wantReply, gotReply, "Reply did not match")
}
})
}
}
func TestClient_GetPhotoEXIFInformation(t *testing.T) {
type fields struct {
myDoer Doer
}
type args struct {
folder string
file string
}
tests := []struct {
name string
fields fields
args args
wantReply PhotoEXIFInformation
wantHTTPStatus int
wantErr error
}{
{
name: "Hero5 OK",
fields: fields{
myDoer: testDoer{
responseCode: 200,
response: `{
"exif": {
"ImageDescription": "DCIM\\100GOPROGOPR1147.JPG",
"Make": "GoPro",
"Model": "HERO5 Black",
"Orientation": "Top-left",
"XResolution": "72",
"YResolution": "72",
"ResolutionUnit": "Inch",
"Software": "HD5.02.02.60.00",
"DateTime": "2018:10:19 14:41:31",
"YCbCrPositioning": "Centered",
"Compression": "JPEG compression",
"ExposureTime": "1/100 sec.",
"FNumber": "f/2.8",
"ExposureProgram": "Normal program",
"ISOSpeedRatings": "530",
"ExifVersion": "Exif Version 2.21",
"DateTimeOriginal": "2018:10:19 14:41:31",
"DateTimeDigitized": "2018:10:19 14:41:31",
"ComponentsConfiguration": "Y Cb Cr -",
"CompressedBitsPerPixel": "14461165.980",
"ShutterSpeedValue": "6.64 EV (1/99 sec.)",
"ApertureValue": "2.97 EV (f/2.8)",
"ExposureBiasValue": "0.00 EV",
"MaxApertureValue": "2.97 EV (f/2.8)",
"SubjectDistance": "0.0 m",
"MeteringMode": "Unknown",
"LightSource": "Unknown",
"Flash": "No flash function",
"FocalLength": "3.0 mm",
"MakerNote": "0d0011400180864500004c4145383034323931363630313337300000000000000000000000000000000000000000000000000000000000000000efefefefefef",
"FlashPixVersion": "FlashPix Version 1.0",
"ColorSpace": "sRGB",
"PixelXDimension": "4000",
"PixelYDimension": "3000",
"ExposureIndex": "0/0",
"SensingMethod": "One-chip color area sensor",
"FileSource": "DSC",
"SceneType": "Directly photographed",
"CustomRendered": "Normal process",
"ExposureMode": "Auto exposure",
"WhiteBalance": "Auto white balance",
"DigitalZoomRatio": "1.000",
"FocalLengthIn35mmFilm": "15",
"SceneCaptureType": "Landscape",
"GainControl": "Normal",
"Contrast": "Normal",
"Saturation": "Normal",
"Sharpness": "Hard",
"DeviceSettingDescription": "4 bytes undefined data",
"SubjectDistanceRange": "Unknown",
"GPSLatitudeRef": "S",
"GPSLatitude": "27, 2, 31.3598400",
"GPSLongitudeRef": "E",
"GPSLongitude": "153, 8, 39.0991199",
"GPSAltitudeRef": "Sea level",
"GPSAltitude": "59.616",
"GPSTimeStamp": "03:41:19.00",
"GPSDateStamp": "2018:10:19",
"InteroperabilityIndex": "R98",
"InteroperabilityVersion": "0100"
}
}`,
},
},
args: args{
folder: "100GOPRO",
file: "GOPR1147.JPG",
},
wantReply: PhotoEXIFInformation{
Exif{
ApertureValue: "2.97 EV (f/2.8)",
ColorSpace: "sRGB",
ComponentsConfiguration: "Y Cb Cr -",
CompressedBitsPerPixel: "14461165.980",
Compression: "JPEG compression",
Contrast: "Normal",
CustomRendered: "Normal process",
DateTime: "2018:10:19 14:41:31",
DateTimeDigitized: "2018:10:19 14:41:31",
DateTimeOriginal: "2018:10:19 14:41:31",
DeviceSettingDescription: "4 bytes undefined data",
DigitalZoomRatio: "1.000",
ExifVersion: "Exif Version 2.21",
ExposureBiasValue: "0.00 EV",
ExposureIndex: "0/0",
ExposureMode: "Auto exposure",
ExposureProgram: "Normal program",
ExposureTime: "1/100 sec.",
FNumber: "f/2.8",
FileSource: "DSC",
Flash: "No flash function",
FlashPixVersion: "FlashPix Version 1.0",
FocalLength: "3.0 mm",
FocalLengthIn35mmFilm: "15",
GPSAltitude: "59.616",
GPSAltitudeRef: "Sea level",
GPSDateStamp: "2018:10:19",
GPSLatitude: "27, 2, 31.3598400",
GPSLatitudeRef: "S",
GPSLongitude: "153, 8, 39.0991199",
GPSLongitudeRef: "E",
GPSTimeStamp: "03:41:19.00",
GainControl: "Normal",
ISOSpeedRatings: "530",
ImageDescription: "DCIM\\100GOPROGOPR1147.JPG",
InteroperabilityIndex: "R98",
InteroperabilityVersion: "0100",
LightSource: "Unknown",
Make: "GoPro",
MakerNote: "0d0011400180864500004c4145383034323931363630313337300000000000000000000000000000000000000000000000000000000000000000efefefefefef",
MaxApertureValue: "2.97 EV (f/2.8)",
MeteringMode: "Unknown",
Model: "HERO5 Black",
Orientation: "Top-left",
PixelXDimension: "4000",
PixelYDimension: "3000",
ResolutionUnit: "Inch",
Saturation: "Normal",
SceneCaptureType: "Landscape",
SceneType: "Directly photographed",
SensingMethod: "One-chip color area sensor",
Sharpness: "Hard",
ShutterSpeedValue: "6.64 EV (1/99 sec.)",
Software: "HD5.02.02.60.00",
SubjectDistance: "0.0 m",
SubjectDistanceRange: "Unknown",
WhiteBalance: "Auto white balance",
XResolution: "72",
YCbCrPositioning: "Centered",
YResolution: "72",
},
},
wantHTTPStatus: 200,
wantErr: nil,
// wantErr: errors.New("got false response"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
hero := CreateTestRestClient(tt.fields.myDoer)
gotReply, gotHTTPStatus, err := hero.GetPhotoEXIFInformation(tt.args.folder, tt.args.file)
if err == nil {
assert.Equal(t, tt.wantHTTPStatus, gotHTTPStatus, "HTTPStatus did not match")
assert.Equal(t, tt.wantReply, gotReply, "Reply did not match")
}
})
}
}