diff --git a/api/v1/album.go b/api/v1/album.go index 7dd0eb0..2b3d6ad 100644 --- a/api/v1/album.go +++ b/api/v1/album.go @@ -146,6 +146,6 @@ func (v1 *V1Client) DeletePhotosFromAlbum(albumUUID string, photoIDs []string) e func (v1 *V1Client) GetAlbumDownload(uuid string) ([]byte, error) { // NOTE: Even though this method is singular GetAlbum // if will call the "albums" plural endpoint. - resp := v1.GET("/api/v1/albums/%s", uuid) + resp := v1.GET("/api/v1/albums/%s?t=%s", uuid, v1.downloadToken) return resp.Body, resp.Error } diff --git a/sample-app/photoprism/storage/albums/album/aqoe4m9204aigugh.yml b/sample-app/photoprism/storage/albums/album/aqoe4m9204aigugh.yml index bffede1..0ca2805 100755 --- a/sample-app/photoprism/storage/albums/album/aqoe4m9204aigugh.yml +++ b/sample-app/photoprism/storage/albums/album/aqoe4m9204aigugh.yml @@ -6,6 +6,4 @@ Order: oldest Country: zz CreatedAt: 2021-02-12T00:42:10Z UpdatedAt: 2021-02-12T00:42:10Z -Photos: -- UID: pqnzigq351j2fqgn - CreatedAt: 2021-02-12T00:42:09.791065836Z +DeletedAt: 2021-02-12T01:19:49.19521169Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe68w1gxzard2c.yml b/sample-app/photoprism/storage/albums/album/aqoe68w1gxzard2c.yml new file mode 100755 index 0000000..d2b8cca --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe68w1gxzard2c.yml @@ -0,0 +1,9 @@ +UID: aqoe68w1gxzard2c +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:17:21Z +UpdatedAt: 2021-02-12T01:17:21Z +DeletedAt: 2021-02-12T01:17:20.582731838Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe68w1lzpyk5zg.yml b/sample-app/photoprism/storage/albums/album/aqoe68w1lzpyk5zg.yml new file mode 100755 index 0000000..b2f5ef0 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe68w1lzpyk5zg.yml @@ -0,0 +1,9 @@ +UID: aqoe68w1lzpyk5zg +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:17:21Z +UpdatedAt: 2021-02-12T01:17:21Z +DeletedAt: 2021-02-12T01:17:20.549276966Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe68w245je8zni.yml b/sample-app/photoprism/storage/albums/album/aqoe68w245je8zni.yml new file mode 100755 index 0000000..928842c --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe68w245je8zni.yml @@ -0,0 +1,9 @@ +UID: aqoe68w245je8zni +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:17:21Z +UpdatedAt: 2021-02-12T01:17:21Z +DeletedAt: 2021-02-12T01:17:20.626364883Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe68wxhb91hvje.yml b/sample-app/photoprism/storage/albums/album/aqoe68wxhb91hvje.yml new file mode 100755 index 0000000..87bbfac --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe68wxhb91hvje.yml @@ -0,0 +1,10 @@ +UID: aqoe68wxhb91hvje +Slug: testalbum +Type: album +Title: TestAlbum +Description: An updated album description +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:17:20Z +UpdatedAt: 2021-02-12T01:17:20.480072684Z +DeletedAt: 2021-02-12T01:17:20.493622671Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe6k91z2qayg4w.yml b/sample-app/photoprism/storage/albums/album/aqoe6k91z2qayg4w.yml new file mode 100755 index 0000000..0eceb8d --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe6k91z2qayg4w.yml @@ -0,0 +1,9 @@ +UID: aqoe6k91z2qayg4w +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:24:10Z +UpdatedAt: 2021-02-12T01:24:10Z +DeletedAt: 2021-02-12T01:24:09.719043974Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe6k922s2v6yp1.yml b/sample-app/photoprism/storage/albums/album/aqoe6k922s2v6yp1.yml new file mode 100755 index 0000000..caecb9e --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe6k922s2v6yp1.yml @@ -0,0 +1,9 @@ +UID: aqoe6k922s2v6yp1 +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:24:10Z +UpdatedAt: 2021-02-12T01:24:10Z +DeletedAt: 2021-02-12T01:24:09.794949796Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe6k93d879bjgg.yml b/sample-app/photoprism/storage/albums/album/aqoe6k93d879bjgg.yml new file mode 100755 index 0000000..d3f8c16 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe6k93d879bjgg.yml @@ -0,0 +1,10 @@ +UID: aqoe6k93d879bjgg +Slug: testalbum +Type: album +Title: TestAlbum +Description: An updated album description +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:24:10Z +UpdatedAt: 2021-02-12T01:24:09.652930019Z +DeletedAt: 2021-02-12T01:24:09.664933038Z diff --git a/sample-app/photoprism/storage/albums/album/aqoe6k9k0kkmx79g.yml b/sample-app/photoprism/storage/albums/album/aqoe6k9k0kkmx79g.yml new file mode 100755 index 0000000..0d545ac --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqoe6k9k0kkmx79g.yml @@ -0,0 +1,9 @@ +UID: aqoe6k9k0kkmx79g +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-12T01:24:10Z +UpdatedAt: 2021-02-12T01:24:10Z +DeletedAt: 2021-02-12T01:24:09.744169818Z diff --git a/sample-app/photoprism/storage/cache/sessions.json b/sample-app/photoprism/storage/cache/sessions.json index 573218c..6bf2e4c 100644 --- a/sample-app/photoprism/storage/cache/sessions.json +++ b/sample-app/photoprism/storage/cache/sessions.json @@ -314,6 +314,11 @@ "tokens": null, "expiration": 1613686778812288997 }, + "5e45fef754afe86cd06fdece3654e1d096844e9bb06e656a": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613697849631150727 + }, "5fccb8ed1ac9f5ca4152b071128078b3da8810e88c1d9728": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -539,6 +544,11 @@ "tokens": null, "expiration": 1613513937752119685 }, + "a195acf32c21a87fc81c92363ed95faaa01abfc91b481179": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613697851138920617 + }, "a3139951989d33f77e643cf68bdd8e2c7cbb88f344200903": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -714,6 +724,11 @@ "tokens": null, "expiration": 1613514516062495823 }, + "dd302423a35c910b5cd65027f2fba9edb7efbf0ee0f81157": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613697440458652837 + }, "e089dfbed493744e24c0cdf9be5f06c81979a17e166d098c": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -764,6 +779,11 @@ "tokens": null, "expiration": 1613512474632135880 }, + "eed103dd37ee5347149d459bfb393d682416adceb8da887e": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613697441816718340 + }, "f27ef3af1a5139eb23ab2d2cd5adb54dd63e147c74f12208": { "user": "uqnzie01i1nypnt9", "tokens": null, diff --git a/sample-app/photoprism/storage/index.db b/sample-app/photoprism/storage/index.db index 16f3e28..4230813 100644 Binary files a/sample-app/photoprism/storage/index.db and b/sample-app/photoprism/storage/index.db differ diff --git a/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml b/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml index 33e6423..3572ade 100755 --- a/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml +++ b/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml @@ -3,7 +3,7 @@ UID: pqnzigq351j2fqgn Type: image Title: A really great photo! TitleSrc: manual -Description: 'Sample App Description: 2021-02-11 17:16:03.257337568 -0800 PST m=+6.449998955' +Description: 'Sample App Description: 2021-02-11 17:24:09.899837223 -0800 PST m=+6.509602721' DescriptionSrc: manual OriginalName: IMG_3044 Year: -1 @@ -13,5 +13,5 @@ Details: Keywords: green, tambourine KeywordsSrc: manual CreatedAt: 2021-02-04T03:17:14.613092062Z -UpdatedAt: 2021-02-12T01:16:03.266957884Z -EditedAt: 2021-02-12T01:16:03Z +UpdatedAt: 2021-02-12T01:24:09.908530756Z +EditedAt: 2021-02-12T01:24:10Z diff --git a/test/album_test.go b/test/album_test.go index 3e8efee..808e9cd 100644 --- a/test/album_test.go +++ b/test/album_test.go @@ -179,74 +179,91 @@ func TestSadCloneAlbum(t *testing.T) { // TestAlbumAddDeletePhoto is a giant integration test // that will exercise many methods in the SDK -//func TestAlbumAddDeletePhoto(t *testing.T) { -// album := api.Album{ -// AlbumTitle: WellKnownAlbumTitle, -// } // -// newAlbum, err := Client.V1().CreateAlbum(album) -// if err != nil { -// t.Errorf("expected success creating album: %v", err) -// t.FailNow() -// } -// -// // Add Photos -// photos := []string{ -// WellKnownPhotoID, -// } -// err = Client.V1().AddPhotosToAlbum(newAlbum.AlbumUID, photos) -// if err != nil { -// t.Errorf("expected to add photos to album: %v", err) -// // Note: We do NOT FailNow() here because we want to clean up -// } -// -// // Get the photos by album -// updatedPhotos, err := Client.V1().GetPhotos(&api.PhotoOptions{ -// Count: 100, -// AlbumUID: newAlbum.AlbumUID, -// }) -// if err != nil { -// t.Errorf("expecting to list photos by album: %v", err) -// // Note: We do NOT FailNow() here because we want to clean up -// } -// -// var updatedPhotoIDs []string -// for _, photo := range updatedPhotos { -// updatedPhotoIDs = append(updatedPhotoIDs, photo.PhotoUID) -// } -// if len(updatedPhotos) != 1 { -// t.Errorf("expecting 1 well known photo in album, found: %d", len(updatedPhotos)) -// } -// -// err = Client.V1().DeletePhotosFromAlbum(newAlbum.AlbumUID, updatedPhotoIDs) -// if err != nil { -// t.Errorf("expected to delete newly created photos from album: %v", err) -// // Note: We do NOT FailNow() here because we want to clean up -// } -// -// // Get the photos by album -// updatedPhotos, err = Client.V1().GetPhotos(&api.PhotoOptions{ -// Count: 100, -// AlbumUID: newAlbum.AlbumUID, -// }) -// if err != nil { -// t.Errorf("expecting to list photos by album: %v", err) -// // Note: We do NOT FailNow() here because we want to clean up -// } -// -// if len(updatedPhotos) != 0 { -// t.Errorf("expected empty album, found %d photos", len(updatedPhotos)) -// // Note: We do NOT FailNow() here because we want to clean up -// } -// -// err = Client.V1().DeleteAlbums([]string{newAlbum.AlbumUID}) -// if err != nil { -// t.Errorf("expected delete album %s, album not deleted: %v", newAlbum.AlbumUID, err) -// t.FailNow() -// } -//} +// This is the most complete integration test in the suite +// and is the test that will also exercise adding and deleting +// photos from an album +func TestAlbumAddDeletePhoto(t *testing.T) { + album := api.Album{ + AlbumTitle: WellKnownAlbumTitle, + } -// AddPhotosToAlbum -// DeletePhotosFromAlbum + newAlbum, err := Client.V1().CreateAlbum(album) + if err != nil { + t.Errorf("expected success creating album: %v", err) + t.FailNow() + } -// GetAlbumDownload + // Add Photos + photos := []string{ + WellKnownPhotoID, + } + err = Client.V1().AddPhotosToAlbum(newAlbum.AlbumUID, photos) + if err != nil { + t.Errorf("expected to add photos to album: %v", err) + // Note: We do NOT FailNow() here because we want to clean up + } + + // Get the photos by album + updatedPhotos, err := Client.V1().GetPhotos(&api.PhotoOptions{ + Count: 100, + AlbumUID: newAlbum.AlbumUID, + }) + if err != nil { + t.Errorf("expecting to list photos by album: %v", err) + // Note: We do NOT FailNow() here because we want to clean up + } + + var updatedPhotoIDs []string + for _, photo := range updatedPhotos { + updatedPhotoIDs = append(updatedPhotoIDs, photo.PhotoUID) + } + if len(updatedPhotos) != 1 { + t.Errorf("expecting 1 well known photo in album, found: %d", len(updatedPhotos)) + } + + err = Client.V1().DeletePhotosFromAlbum(newAlbum.AlbumUID, updatedPhotoIDs) + if err != nil { + t.Errorf("expected to delete newly created photos from album: %v", err) + // Note: We do NOT FailNow() here because we want to clean up + } + + // Get the photos by album + updatedPhotos, err = Client.V1().GetPhotos(&api.PhotoOptions{ + Count: 100, + AlbumUID: newAlbum.AlbumUID, + }) + if err != nil { + t.Errorf("expecting to list photos by album: %v", err) + // Note: We do NOT FailNow() here because we want to clean up + } + + if len(updatedPhotos) != 0 { + t.Errorf("expected empty album, found %d photos", len(updatedPhotos)) + // Note: We do NOT FailNow() here because we want to clean up + } + + err = Client.V1().DeleteAlbums([]string{newAlbum.AlbumUID}) + if err != nil { + t.Errorf("expected delete album %s, album not deleted: %v", newAlbum.AlbumUID, err) + t.FailNow() + } +} + +func TestHappyGetAlbumDownload(t *testing.T) { + // GetAlbumDownload should return a .zip file + bytes, err := Client.V1().GetAlbumDownload(WellKnownAlbumID) + if err != nil { + t.Errorf("expecting album download: %v", err) + t.FailNow() + } + t.Logf("bytes of .zip file downloaded: %db", len(bytes)) +} + +func TestSadGetAlbumDownload(t *testing.T) { + _, err := Client.V1().GetPhotoDownload(UnknownAlbumID) + if err == nil { + t.Errorf("expected failure getting well known album: %v", err) + t.FailNow() + } +}