Skip to content

Commit

Permalink
Merge pull request #4346 from guardian/an/remove-imagetype-type
Browse files Browse the repository at this point in the history
Remove the ImageType type
  • Loading branch information
andrew-nowak authored Dec 4, 2024
2 parents 041aab5 + f66347d commit 92fb060
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ object UsageRightsMetadataMapper {
byline = Some(u.photographer),
credit = Some(u.publication),
copyright = copyright,
imageType = Some(ImageType.Photograph)
imageType = Some("Photograph")
)
case u: ContractPhotographer =>
ImageMetadata(byline = Some(u.photographer), credit = u.publication, imageType = Some(ImageType.Photograph))
ImageMetadata(byline = Some(u.photographer), credit = u.publication, imageType = Some("Photograph"))
case u: CommissionedPhotographer =>
ImageMetadata(byline = Some(u.photographer), credit = u.publication, imageType = Some(ImageType.Photograph))
ImageMetadata(byline = Some(u.photographer), credit = u.publication, imageType = Some("Photograph"))
case u: ContractIllustrator =>
ImageMetadata(byline = Some(u.creator), credit = u.publication, imageType = Some(ImageType.Illustration))
ImageMetadata(byline = Some(u.creator), credit = u.publication, imageType = Some("Illustration"))
case u: StaffIllustrator =>
ImageMetadata(byline = Some(u.creator), credit = Some(u.creator), imageType = Some(ImageType.Illustration))
ImageMetadata(byline = Some(u.creator), credit = Some(u.creator), imageType = Some("Illustration"))
case u: CommissionedIllustrator =>
ImageMetadata(byline = Some(u.creator), credit = u.publication, imageType = Some(ImageType.Illustration))
case u: Composite => ImageMetadata(credit = Some(u.suppliers), imageType = Some(ImageType.Composite))
ImageMetadata(byline = Some(u.creator), credit = u.publication, imageType = Some("Illustration"))
case u: Composite => ImageMetadata(credit = Some(u.suppliers), imageType = Some("Composite"))
case u: Screengrab => ImageMetadata(credit = u.source)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,66 @@ class UsageRightsMetadataMapperTest extends AnyFunSpec with Matchers {

it("should convert StaffPhotographers adding copyright when original metadata doesn't have it") {
val ur = StaffPhotographer("Alicia Canter", "The Guardian")
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("The Guardian"), imageType = Some(ImageType.Photograph)))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("The Guardian"), imageType = Some("Photograph")))
)
}

it ("should convert StaffPhotographers changing copyright when original copyright is a publication") {
val ur = StaffPhotographer("Alicia Canter", "The Guardian")
usageRightsToMetadata(ur, metadataWithCopyright, Set("The Observer", "BBC")) should be
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("The Guardian"), imageType = Some(ImageType.Photograph)))
usageRightsToMetadata(ur, metadataWithCopyright, Set("The Observer", "BBC")) should be (
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("The Guardian"), imageType = Some("Photograph")))
)
}

it ("should convert StaffPhotographers keeping original copyright when original copyright is not a publication") {
val ur = StaffPhotographer("Alicia Canter", "The Guardian")
usageRightsToMetadata(ur, metadataWithCopyright, Set("The Observer", "BBC Studio")) should be
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("BBC"), imageType = Some(ImageType.Photograph)))
usageRightsToMetadata(ur, metadataWithCopyright, Set("The Observer", "BBC Studio")) should be (
Some(ImageMetadata(credit = Some("The Guardian"), byline = Some("Alicia Canter"), copyright = Some("BBC"), imageType = Some("Photograph")))
)
}

it ("should convert ContractPhotographers") {
val ur = ContractPhotographer("Andy Hall", Some("The Observer"), None)
usageRightsToMetadata(ur, metadataWithCopyright) should be
Some(ImageMetadata(credit = Some("The Observer"), byline = Some("Andy Hall"), imageType = Some(ImageType.Photograph)))
usageRightsToMetadata(ur, metadataWithCopyright) should be (
Some(ImageMetadata(credit = Some("The Observer"), byline = Some("Andy Hall"), imageType = Some("Photograph")))
)
}

it ("should convert CommissionedPhotographers") {
val ur = CommissionedPhotographer("Mr. Photo", Some("Weekend Magazine"))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
Some(ImageMetadata(credit = Some("Weekend Magazine"), byline = Some("Mr. Photo"), imageType = Some(ImageType.Photograph)))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(credit = Some("Weekend Magazine"), byline = Some("Mr. Photo"), imageType = Some("Photograph")))
)
}

it ("should convert ContractIllustrators") {
val ur = ContractIllustrator("First Dog on the Moon Institute")
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
Some(ImageMetadata(credit = Some("First Dog on the Moon Institute"), imageType = Some(ImageType.Illustration)))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(byline = Some("First Dog on the Moon Institute"), imageType = Some("Illustration")))
)
}

it ("should convert CommissionedIllustrators") {
val ur = CommissionedIllustrator("Roger Rabbit")
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
Some(ImageMetadata(credit = Some("Roger Rabit"), imageType = Some(ImageType.Illustration)))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(byline = Some("Roger Rabbit"), imageType = Some("Illustration")))
)

}

it ("should convert Composites") {
val ur = Composite("REX/Getty Images")
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
Some(ImageMetadata(credit = Some("REX/Getty Images"), imageType = Some(ImageType.Composite)))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(credit = Some("REX/Getty Images"), imageType = Some("Composite")))
)
}

it ("should convert Screengrabs") {
val ur = Screengrab(Some("BBC News"))
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
usageRightsToMetadata(ur, metadataWithoutCopyright) should be (
Some(ImageMetadata(credit = Some("BBC News")))
)
}

it ("should not convert Agencies") {
Expand Down

0 comments on commit 92fb060

Please sign in to comment.