2021-09-18 15:32:39 +02:00
|
|
|
package search
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-05-13 11:57:54 +02:00
|
|
|
"time"
|
2020-01-28 22:16:59 +01:00
|
|
|
|
2022-04-03 09:45:05 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-08-19 21:12:38 +02:00
|
|
|
|
2022-04-03 09:45:05 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
2020-01-28 22:16:59 +01:00
|
|
|
)
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
func TestGeo(t *testing.T) {
|
2021-11-26 21:10:52 +01:00
|
|
|
t.Run("Near", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("near:pt9jtdre2lvl0y43")
|
2021-11-26 21:10:52 +01:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
if result, err := PhotosGeo(query); err != nil {
|
2021-11-26 21:10:52 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
t.Logf("RESULT: %#v", result)
|
|
|
|
assert.LessOrEqual(t, 4, len(result))
|
|
|
|
}
|
|
|
|
})
|
2021-09-23 14:23:00 +02:00
|
|
|
t.Run("UnknownFaces", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("face:none")
|
2021-09-23 14:23:00 +02:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
if result, err := PhotosGeo(query); err != nil {
|
2021-09-23 14:23:00 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.Equal(t, 0, len(result))
|
|
|
|
}
|
|
|
|
})
|
2021-08-29 16:16:49 +02:00
|
|
|
t.Run("form.keywords", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("keywords:bridge")
|
2021-08-29 16:16:49 +02:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
if result, err := PhotosGeo(query); err != nil {
|
2021-08-29 16:16:49 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.GreaterOrEqual(t, len(result), 1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("form.subjects", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("subjects:John")
|
2021-08-29 16:16:49 +02:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
if result, err := PhotosGeo(query); err != nil {
|
2021-08-29 16:16:49 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.GreaterOrEqual(t, len(result), 0)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("find_all", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("")
|
2020-01-28 22:16:59 +01:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
if result, err := PhotosGeo(query); err != nil {
|
2020-05-13 11:57:54 +02:00
|
|
|
t.Fatal(err)
|
2021-08-29 16:16:49 +02:00
|
|
|
} else {
|
|
|
|
assert.LessOrEqual(t, 4, len(result))
|
2020-05-13 11:57:54 +02:00
|
|
|
}
|
2020-01-28 22:16:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for bridge", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("q:bridge Before:3006-01-02")
|
2022-08-01 15:57:19 +02:00
|
|
|
|
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(query)
|
2020-05-25 19:10:44 +02:00
|
|
|
t.Logf("RESULT: %+v", result)
|
2020-01-28 22:16:59 +01:00
|
|
|
|
2020-05-13 11:57:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-16 17:15:06 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(result))
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
})
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
t.Run("search for date range", func(t *testing.T) {
|
2022-09-30 19:15:10 +02:00
|
|
|
query := form.NewSearchPhotosGeo("After:2014-12-02 Before:3006-01-02")
|
2022-08-01 15:57:19 +02:00
|
|
|
|
|
|
|
// Parse query string and filter.
|
|
|
|
if err := query.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(query)
|
2020-01-28 22:16:59 +01:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
// t.Logf("RESULT: %+v", result)
|
|
|
|
|
2020-05-13 11:57:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-01-28 22:16:59 +01:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.Equal(t, "Reunion", result[0].PhotoTitle)
|
2020-01-28 22:16:59 +01:00
|
|
|
})
|
2020-05-25 19:10:44 +02:00
|
|
|
|
2020-05-13 11:57:54 +02:00
|
|
|
t.Run("search for review true, quality 0", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-05-13 11:57:54 +02:00
|
|
|
Query: "",
|
|
|
|
Before: time.Time{},
|
|
|
|
After: time.Time{},
|
|
|
|
Favorite: true,
|
|
|
|
Lat: 1.234,
|
|
|
|
Lng: 4.321,
|
|
|
|
S2: "",
|
|
|
|
Olc: "",
|
|
|
|
Dist: 0,
|
|
|
|
Quality: 0,
|
|
|
|
Review: true,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-05-13 11:57:54 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(result))
|
|
|
|
assert.IsType(t, GeoResults{}, result)
|
2021-09-03 20:14:11 +02:00
|
|
|
|
|
|
|
if len(result) > 0 {
|
|
|
|
assert.Equal(t, "1000017", result[0].ID)
|
|
|
|
}
|
2020-05-13 11:57:54 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for review false, quality > 0", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-05-13 11:57:54 +02:00
|
|
|
Query: "",
|
|
|
|
Before: time.Time{},
|
|
|
|
After: time.Time{},
|
|
|
|
Favorite: false,
|
|
|
|
Lat: 0,
|
|
|
|
Lng: 0,
|
|
|
|
S2: "",
|
|
|
|
Olc: "",
|
|
|
|
Dist: 0,
|
|
|
|
Quality: 3,
|
|
|
|
Review: false,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-05-13 11:57:54 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-08-16 17:15:06 +02:00
|
|
|
assert.LessOrEqual(t, 3, len(result))
|
2020-05-13 11:57:54 +02:00
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
|
|
|
t.Run("search for s2", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-05-13 11:57:54 +02:00
|
|
|
Query: "",
|
|
|
|
Before: time.Time{},
|
|
|
|
After: time.Time{},
|
|
|
|
Favorite: false,
|
|
|
|
Lat: 0,
|
|
|
|
Lng: 0,
|
|
|
|
S2: "85",
|
|
|
|
Olc: "",
|
|
|
|
Dist: 0,
|
|
|
|
Quality: 0,
|
|
|
|
Review: false,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-05-13 11:57:54 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.Empty(t, result)
|
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
|
|
|
t.Run("search for Olc", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-05-13 11:57:54 +02:00
|
|
|
Query: "",
|
|
|
|
Before: time.Time{},
|
|
|
|
After: time.Time{},
|
|
|
|
Favorite: false,
|
|
|
|
Lat: 0,
|
|
|
|
Lng: 0,
|
|
|
|
S2: "",
|
|
|
|
Olc: "9",
|
|
|
|
Dist: 0,
|
|
|
|
Quality: 0,
|
|
|
|
Review: false,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-05-13 11:57:54 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
2020-07-13 12:29:11 +02:00
|
|
|
t.Run("query for label flower", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-07-13 12:29:11 +02:00
|
|
|
Query: "flower",
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-07-13 12:29:11 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
|
|
|
t.Run("query for label landscape", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-07-13 12:29:11 +02:00
|
|
|
Query: "landscape",
|
|
|
|
Album: "test",
|
|
|
|
Camera: 123,
|
|
|
|
Lens: 123,
|
2021-09-20 23:32:35 +02:00
|
|
|
Year: "2010",
|
|
|
|
Month: "12",
|
2020-07-13 12:29:11 +02:00
|
|
|
Color: "red",
|
2021-08-19 21:12:38 +02:00
|
|
|
Country: entity.UnknownID,
|
2020-07-13 12:29:11 +02:00
|
|
|
Type: "jpg",
|
|
|
|
Video: true,
|
2020-07-13 13:12:32 +02:00
|
|
|
Path: "/xxx/xxx/",
|
2020-07-13 12:29:11 +02:00
|
|
|
Name: "xxx",
|
|
|
|
Archived: false,
|
|
|
|
Private: true,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-07-13 12:29:11 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
|
|
|
t.Run("search with multiple parameters", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-07-13 12:29:11 +02:00
|
|
|
Query: "landscape",
|
|
|
|
Photo: true,
|
2020-07-13 13:12:32 +02:00
|
|
|
Path: "/xxx,xxx",
|
2020-07-13 12:29:11 +02:00
|
|
|
Name: "xxx",
|
|
|
|
Archived: false,
|
|
|
|
Private: false,
|
|
|
|
Public: true,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-07-13 12:29:11 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-07-13 13:12:32 +02:00
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
|
|
|
t.Run("search for archived true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
f := form.SearchPhotosGeo{
|
2020-07-13 13:12:32 +02:00
|
|
|
Query: "landscape",
|
|
|
|
Photo: true,
|
|
|
|
Path: "/xxx/xxx/",
|
|
|
|
Name: "xxx",
|
|
|
|
Archived: true,
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
result, err := PhotosGeo(f)
|
2020-07-13 13:12:32 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-07-13 12:29:11 +02:00
|
|
|
assert.IsType(t, GeoResults{}, result)
|
|
|
|
})
|
2021-08-31 16:33:55 +02:00
|
|
|
t.Run("faces:true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-05-26 10:46:32 +02:00
|
|
|
f.Query = "faces:true"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-05-26 10:46:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-02 17:44:27 +02:00
|
|
|
assert.GreaterOrEqual(t, len(photos), 4)
|
2021-05-26 10:46:32 +02:00
|
|
|
})
|
2021-08-31 16:33:55 +02:00
|
|
|
t.Run("faces:yes", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Faces = "Yes"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-02 17:44:27 +02:00
|
|
|
assert.GreaterOrEqual(t, len(photos), 4)
|
2021-08-31 16:33:55 +02:00
|
|
|
})
|
2021-10-22 18:00:09 +02:00
|
|
|
t.Run("face:yes", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
f.Face = "Yes"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 4)
|
|
|
|
})
|
|
|
|
t.Run("f.Faces:new", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
f.Faces = "New"
|
|
|
|
f.Face = ""
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 3)
|
|
|
|
})
|
2021-08-31 16:33:55 +02:00
|
|
|
t.Run("faces:no", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Faces = "No"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-02 17:44:27 +02:00
|
|
|
assert.GreaterOrEqual(t, len(photos), 8)
|
2021-08-31 16:33:55 +02:00
|
|
|
})
|
|
|
|
t.Run("faces:2", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Faces = "2"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
})
|
2021-10-22 18:00:09 +02:00
|
|
|
t.Run("face: TOSCDXCS4VI3PGIUTCNIQCNI6HSFXQVZ", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
f.Face = "TOSCDXCS4VI3PGIUTCNIQCNI6HSFXQVZ"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 2)
|
|
|
|
})
|
2021-08-31 16:33:55 +02:00
|
|
|
t.Run("day", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-09-20 23:32:35 +02:00
|
|
|
f.Day = "18"
|
|
|
|
f.Month = "4"
|
2021-08-31 16:33:55 +02:00
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
})
|
|
|
|
t.Run("subject uid in query", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Query = "Actress"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
})
|
2022-03-24 18:30:59 +01:00
|
|
|
t.Run("Album", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-03-24 18:30:59 +01:00
|
|
|
f.Album = "Berlin"
|
2021-08-31 16:33:55 +02:00
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
assert.Equal(t, 1, len(photos))
|
2021-08-31 16:33:55 +02:00
|
|
|
})
|
2022-03-24 18:30:59 +01:00
|
|
|
t.Run("Albums", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-03-24 18:30:59 +01:00
|
|
|
f.Albums = "Holiday|Christmas"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2022-03-24 18:30:59 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, 2, len(photos))
|
2022-09-05 15:35:02 +02:00
|
|
|
})
|
|
|
|
t.Run("City", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotosGeo
|
|
|
|
f.City = "Teotihuacán"
|
|
|
|
|
|
|
|
photos, err := PhotosGeo(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, 8, len(photos))
|
2022-03-24 18:30:59 +01:00
|
|
|
})
|
|
|
|
t.Run("PathOrPath", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Path = "1990/04" + "|" + "2015/11"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 3)
|
|
|
|
})
|
|
|
|
t.Run("name or name", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-08-31 16:33:55 +02:00
|
|
|
f.Name = "20151101_000000_51C501B5" + "|" + "Video"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-08-31 16:33:55 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 2)
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("query: videos", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "videos"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "video", r.PhotoType)
|
|
|
|
}
|
|
|
|
})
|
2021-10-22 18:00:09 +02:00
|
|
|
t.Run("query: video", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Query = "video"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "video", r.PhotoType)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: live", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Query = "live"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "live", r.PhotoType)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: raws", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Query = "raws"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "raw", r.PhotoType)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: panoramas", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Query = "panoramas"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: scans", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Query = "scans"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("query: faces", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "faces"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: people", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "people"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: favorites", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "favorites"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.True(t, r.PhotoFavorite)
|
|
|
|
}
|
|
|
|
})
|
2021-09-21 11:04:43 +02:00
|
|
|
t.Run("keywords:kuh|bridge > keywords:bridge&kuh", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
f.Query = "keywords:kuh|bridge"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
f.Query = "keywords:bridge&kuh"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos2, err2 := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Greater(t, len(photos), len(photos2))
|
|
|
|
})
|
|
|
|
t.Run("albums and and or search", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
f.Query = "albums:Holiday|Berlin"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
f.Query = "albums:\"Berlin&Holiday|Christmas\""
|
2021-09-21 11:04:43 +02:00
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos2, err2 := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
assert.Greater(t, len(photos), len(photos2))
|
|
|
|
})
|
2021-10-22 18:00:09 +02:00
|
|
|
t.Run("f.Album = uid", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Album = "at9lxuqxpogaaba9"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Run("subjects and and or search", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Subjects = "Actor A|Actress A"
|
|
|
|
|
|
|
|
t.Logf("S1: %s", f.SerializeAll())
|
2021-09-21 11:04:43 +02:00
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Subjects = "Actor A&Actress A"
|
|
|
|
|
|
|
|
t.Logf("S2: %s", f.SerializeAll())
|
2021-09-21 11:04:43 +02:00
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos2, err2 := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Greater(t, len(photos), len(photos2))
|
|
|
|
})
|
|
|
|
t.Run("people = subjects & person = subject", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
f.People = "Actor"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2022-04-14 08:39:52 +02:00
|
|
|
var f2 form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
f2.Subjects = "Actor"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err = f2.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos2, err2 := PhotosGeo(f2)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, len(photos), len(photos2))
|
|
|
|
|
2022-04-14 08:39:52 +02:00
|
|
|
var f3 form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
f3.Person = "Actor A"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err = f3.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos3, err3 := PhotosGeo(f3)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err3 != nil {
|
|
|
|
t.Fatal(err3)
|
|
|
|
}
|
|
|
|
|
2022-04-14 08:39:52 +02:00
|
|
|
var f4 form.SearchPhotosGeo
|
2021-09-21 11:04:43 +02:00
|
|
|
f4.Subject = "Actor A"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err = f4.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos4, err4 := PhotosGeo(f4)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
if err4 != nil {
|
|
|
|
t.Fatal(err4)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, len(photos3), len(photos4))
|
|
|
|
assert.Equal(t, len(photos), len(photos4))
|
2021-10-22 18:00:09 +02:00
|
|
|
|
2022-04-14 08:39:52 +02:00
|
|
|
var f5 form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
f5.Subject = "jqy1y111h1njaaad"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err = f5.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos5, err5 := PhotosGeo(f5)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err5 != nil {
|
|
|
|
t.Fatal(err5)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, len(photos5), len(photos4))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("f.Scan = true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Scan = true
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.Panorama = true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Panorama = true
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.Raw = true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Raw = true
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.Live = true", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Live = true
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.Title = phototobebatchapproved2", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
frm.Title = "phototobebatchapproved2"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
|
|
|
})
|
2022-01-17 16:07:31 +01:00
|
|
|
t.Run("QueryP", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var frm form.SearchPhotosGeo
|
2021-10-22 18:00:09 +02:00
|
|
|
frm.Query = "p"
|
|
|
|
frm.Title = ""
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(frm)
|
2021-10-22 18:00:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, GeoResult{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
}
|
2021-09-21 11:04:43 +02:00
|
|
|
})
|
2022-04-13 09:48:51 +02:00
|
|
|
t.Run("Panorama", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
f.Query = "panorama:true"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("Portrait", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
f.Query = "portrait:true"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("Landscape", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
f.Query = "landscape:true"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("Square", func(t *testing.T) {
|
2022-04-14 08:39:52 +02:00
|
|
|
var f form.SearchPhotosGeo
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
f.Query = "square:true"
|
|
|
|
|
2022-04-14 14:13:54 +02:00
|
|
|
photos, err := PhotosGeo(f)
|
2022-04-13 09:48:51 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-01-28 22:16:59 +01:00
|
|
|
}
|