photoprism/internal/meta/json_test.go
Michael Mayer 5f408f4f76 Backend: Read from JSON sidecar files (created by exiftool) #4 #243
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-13 20:53:15 +02:00

122 lines
3.1 KiB
Go

package meta
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestJSON(t *testing.T) {
t.Run("mp4.json", func(t *testing.T) {
data, err := JSON("testdata/mp4.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "4m25s", data.Duration.String())
assert.Equal(t, "2019-11-23 13:51:49 +0000 UTC", data.TakenAtLocal.String())
assert.Equal(t, 848, data.Width)
assert.Equal(t, 480, data.Height)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "", data.CameraMake)
assert.Equal(t, "", data.CameraModel)
assert.Equal(t, "", data.LensModel)
})
t.Run("photoshop.json", func(t *testing.T) {
data, err := JSON("testdata/photoshop.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "Night Shift / Berlin / 2020", data.Title)
assert.Equal(t, "Michael Mayer", data.Artist)
assert.Equal(t, "Example file for development", data.Description)
assert.Equal(t, "This is an (edited) legal notice", data.Copyright)
assert.Equal(t, "HUAWEI", data.CameraMake)
assert.Equal(t, "ELE-L29", data.CameraModel)
assert.Equal(t, "HUAWEI P30 Rear Main Camera", data.LensModel)
})
t.Run("canon_eos_6d.json", func(t *testing.T) {
data, err := JSON("testdata/canon_eos_6d.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "Canon", data.CameraMake)
assert.Equal(t, "Canon EOS 6D", data.CameraModel)
assert.Equal(t, "EF24-105mm f/4L IS USM", data.LensModel)
})
t.Run("gps-2000.json", func(t *testing.T) {
data, err := JSON("testdata/gps-2000.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "", data.CameraMake)
assert.Equal(t, "", data.CameraModel)
assert.Equal(t, "", data.LensMake)
assert.Equal(t, "", data.LensModel)
})
t.Run("ladybug.json", func(t *testing.T) {
data, err := JSON("testdata/ladybug.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "", data.CameraMake)
assert.Equal(t, "", data.CameraModel)
assert.Equal(t, "", data.LensMake)
assert.Equal(t, "", data.LensModel)
})
t.Run("iphone_7.json", func(t *testing.T) {
data, err := JSON("testdata/iphone_7.json")
if err != nil {
t.Fatal(err)
}
// t.Logf("DATA: %+v", data)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "Apple", data.CameraMake)
assert.Equal(t, "iPhone 7", data.CameraModel)
assert.Equal(t, "Apple", data.LensMake)
assert.Equal(t, "iPhone 7 back camera 3.99mm f/1.8", data.LensModel)
})
}