Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
most of these weren't actually running their tests - the `be` without
a bracket just referenced the test function, then the expected value, without
returning or asserting anything!

a couple of these tests were failing without an update, so handy to fix
  • Loading branch information
andrew-nowak committed Oct 7, 2024
1 parent bcb0913 commit f66347d
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +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("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
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("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
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
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("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("Illustration"))))
Some(ImageMetadata(byline = Some("Roger Rabbit"), imageType = Some("Illustration")))
)

}

it ("should convert Composites") {
val ur = Composite("REX/Getty Images")
usageRightsToMetadata(ur, metadataWithoutCopyright) should be
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 f66347d

Please sign in to comment.