2020-05-08 15:41:01 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-21 18:08:41 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
|
|
)
|
|
|
|
|
2020-06-23 07:55:33 +02:00
|
|
|
func TestPhotoSearch(t *testing.T) {
|
2020-05-14 14:18:28 +02:00
|
|
|
t.Run("search all", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
for _, r := range photos {
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.IsType(t, PhotoResult{}, r)
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-05-14 14:18:28 +02:00
|
|
|
t.Run("search for ID and merged", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.ID = "pt9jtdre2lvl0yh7"
|
|
|
|
frm.Merged = true
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for ID with merged false", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.ID = "pt9jtdre2lvl0yh7"
|
|
|
|
frm.Merged = false
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Run("label query dog", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "label:dog"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2020-05-29 18:04:30 +02:00
|
|
|
assert.Equal(t, "dog not found", err.Error())
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.Empty(t, photos)
|
|
|
|
})
|
|
|
|
t.Run("label query landscape", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "label:landscape Order:relevance"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
if err != nil {
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Fatal(err)
|
2020-05-08 15:41:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("invalid label query", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "label:xxx"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
assert.Empty(t, photos)
|
|
|
|
|
|
|
|
if err != nil {
|
2020-05-29 18:04:30 +02:00
|
|
|
assert.Equal(t, err.Error(), "xxx not found")
|
2020-05-08 15:41:01 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("form.location true", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Geo = true
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-14 14:18:28 +02:00
|
|
|
})
|
|
|
|
t.Run("form.location true and keyword", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "bridge"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Geo = true
|
|
|
|
frm.Error = false
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for keyword", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "bridge"
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for label in query", func(t *testing.T) {
|
2021-02-07 19:04:17 +01:00
|
|
|
var frm form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "flower"
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(frm)
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for archived", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Archived = true
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for private", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Private = true
|
2020-05-18 15:45:55 +02:00
|
|
|
f.Error = true
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for public", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Public = true
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for review", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Review = true
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for quality", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
2020-05-25 19:10:44 +02:00
|
|
|
f.Quality = 3
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Private = false
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for file error", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Error = true
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.camera", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Query = ""
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Camera = 1000003
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.color", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
f.Color = "blue"
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.favorites", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-05-14 19:03:12 +02:00
|
|
|
f.Query = "favorite:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.country", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "country:zz"
|
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.title", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "title:Neckarbrücke"
|
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.hash", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "hash:2cad9168fa6acc5c5c2965ddf6ec465ca42fd818"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("form.portrait", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "portrait:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-07-18 13:09:22 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
t.Run("form.mono", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = "mono:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Archived = true
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
|
|
|
t.Run("form.chroma >9 Order:similar", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "chroma:25 Order:similar"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Run("form.chroma <9", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
var f form.PhotoSearch
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "chroma:4"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
2020-05-18 15:45:55 +02:00
|
|
|
f.Error = true
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.fmin and Order:oldest", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Fmin:5 Order:oldest"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.fmax and Order:newest", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Fmax:2 Order:newest"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.Lat and form.Lng and Order:imported", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Lat:33.45343166666667 Lng:25.764711666666667 Dist:2000 Order:imported"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
|
|
|
})
|
|
|
|
t.Run("form.Lat and form.Lng and Order:imported Dist:6000", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Lat:33.45343166666667 Lng:25.764711666666667 Dist:6000 Order:imported"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
|
|
|
})
|
|
|
|
t.Run("form.Before and form.After Order:relevance", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Before:2016-01-01 After:2013-01-01 Order:relevance"
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Merged = true
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for diff", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "Diff:800"
|
|
|
|
f.Count = 5000
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for lens, month, year, album", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Lens = 1000000
|
|
|
|
f.Month = 2
|
|
|
|
f.Year = 2790
|
|
|
|
f.Album = "at9lxuqxpogaaba8"
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
photos, _, err := PhotoSearch(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-29 18:04:30 +02:00
|
|
|
t.Run("search for state", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.State = "KwaZulu-Natal"
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("STATE SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for category", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Category = "botanical garden"
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for labels", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
2020-12-14 22:57:07 +01:00
|
|
|
f.Label = "botanical-garden|nature|landscape|park"
|
2020-05-29 18:04:30 +02:00
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
t.Run("search for primary files", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Primary = true
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for landscape", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Query = "landscape"
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search with multiple parameters", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Hidden = true
|
|
|
|
f.Scan = true
|
|
|
|
f.Year = 2010
|
|
|
|
f.Day = 1
|
|
|
|
f.Photo = true
|
|
|
|
f.Name = "xxx"
|
|
|
|
f.Original = "xxyy"
|
|
|
|
f.Path = "/xxx/xxx/"
|
|
|
|
f.Order = entity.SortOrderName
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.IsType(t, PhotoResults{}, photos)
|
|
|
|
})
|
|
|
|
t.Run("search with multiple parameters", func(t *testing.T) {
|
|
|
|
var f form.PhotoSearch
|
|
|
|
f.Hidden = true
|
|
|
|
f.Scan = true
|
|
|
|
f.Year = 2010
|
|
|
|
f.Day = 1
|
|
|
|
f.Video = true
|
|
|
|
f.Name = "xxx"
|
|
|
|
f.Original = "xxyy"
|
2020-12-14 22:57:07 +01:00
|
|
|
f.Path = "/xxx|xxx"
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Type = "mp4"
|
2020-07-13 15:59:54 +02:00
|
|
|
f.Stack = true
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Unsorted = true
|
|
|
|
f.Filter = ""
|
|
|
|
f.Order = entity.SortOrderAdded
|
|
|
|
|
|
|
|
photos, _, err := PhotoSearch(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("CATEGORY SEARCH: %+v", photos)
|
|
|
|
|
|
|
|
assert.IsType(t, PhotoResults{}, photos)
|
|
|
|
})
|
2020-05-08 15:41:01 +02:00
|
|
|
}
|