photoprism/internal/entity/photo_quality_test.go

45 lines
1.3 KiB
Go
Raw Normal View History

2020-05-08 14:18:11 +02:00
package entity
import (
"testing"
2020-11-21 18:08:41 +01:00
"github.com/stretchr/testify/assert"
2020-05-08 14:18:11 +02:00
)
func TestPhoto_QualityScore(t *testing.T) {
t.Run("PhotoFixture19800101_000002_D640C559", func(t *testing.T) {
2021-08-05 12:33:52 +02:00
assert.Equal(t, 3, PhotoFixtures.Pointer("19800101_000002_D640C559").QualityScore())
2020-05-08 14:18:11 +02:00
})
t.Run("PhotoFixturePhoto01 - favorite true - taken at before 2008", func(t *testing.T) {
assert.Equal(t, 7, PhotoFixtures.Pointer("Photo01").QualityScore())
2020-05-08 14:18:11 +02:00
})
t.Run("PhotoFixturePhoto06 - taken at after 2012 - resolution 2", func(t *testing.T) {
assert.Equal(t, 3, PhotoFixtures.Pointer("Photo06").QualityScore())
2020-05-08 14:18:11 +02:00
})
t.Run("PhotoFixturePhoto07 - score < 3 bit edited", func(t *testing.T) {
assert.Equal(t, 3, PhotoFixtures.Pointer("Photo07").QualityScore())
2020-05-08 14:18:11 +02:00
})
2020-05-12 13:52:09 +02:00
t.Run("PhotoFixturePhoto15 - description with blacklist", func(t *testing.T) {
assert.Equal(t, 2, PhotoFixtures.Pointer("Photo15").QualityScore())
})
2020-05-08 14:18:11 +02:00
}
2021-02-25 15:42:20 +01:00
func TestPhoto_UpdateQuality(t *testing.T) {
t.Run("nil", func(t *testing.T) {
p := &Photo{PhotoQuality: -1}
err := p.UpdateQuality()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, -1, p.PhotoQuality)
})
t.Run("low quality expected", func(t *testing.T) {
p := &Photo{PhotoQuality: 0, PhotoFavorite: true}
err := p.UpdateQuality()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 5, p.PhotoQuality)
})
}