Metadata: Add and improve MediaFile location info tests #4714 #4725

* Address Issue #4714 with change to existing iphone_7.heic test and new iphone_xr.heic test
* Resize image and change to jpg so that GPS information can be read by GO.
This commit is contained in:
Keith Martin 2025-01-18 01:06:18 +10:00 committed by GitHub
parent d35bd7d797
commit 6c98df501e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

View file

@ -29,7 +29,10 @@ func TestMediaFile_Location(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, "高砂市", location.City())
// nominatim and photon disagree on Himeji (姫路市) and Takasago (高砂市), but both contain Shi.
// The photo is within 90m of the boundary of the two cities.
// And as this test is to validate Unicode, it's ok.
assert.Contains(t, location.City(), "市")
assert.Equal(t, "兵庫県", location.State())
assert.Equal(t, "Japan", location.CountryName())
assert.Equal(t, "", location.Category())
@ -44,7 +47,7 @@ func TestMediaFile_Location(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, "高砂市", location2.City())
assert.Contains(t, location2.City(), "市")
assert.Equal(t, "兵庫県", location2.State())
})
t.Run("iphone_15_pro.heic", func(t *testing.T) {
@ -84,6 +87,42 @@ func TestMediaFile_Location(t *testing.T) {
assert.Equal(t, "Berlin", location2.City())
assert.Equal(t, "Berlin", location2.State())
})
t.Run("iphone_xr.jpg", func(t *testing.T) {
mediaFile, err := NewMediaFile(c.ExamplesPath() + "/iphone_xr.jpg")
if err != nil {
t.Fatal(err)
}
location, err := mediaFile.Location()
if err != nil {
t.Fatal(err)
}
if err = location.Find("places"); err != nil {
t.Fatal(err)
}
// Test Unicode and City is correct.
assert.Equal(t, "白川村", location.City())
assert.Equal(t, "岐阜県", location.State())
assert.Equal(t, "Japan", location.CountryName())
assert.Equal(t, "visitor center", location.Category())
assert.True(t, strings.HasPrefix(location.ID, s2.TokenPrefix+"5ff871bf"))
location2, err := mediaFile.Location()
if err != nil {
t.Fatal(err)
}
if err = location.Find("places"); err != nil {
t.Fatal(err)
}
assert.Equal(t, "白川村", location2.City())
assert.Equal(t, "岐阜県", location2.State())
})
t.Run("cat_brown.jpg", func(t *testing.T) {
f, err := NewMediaFile(c.ExamplesPath() + "/cat_brown.jpg")