Skip to content

Commit cea05a4

Browse files
committed
SMA-523 Add unit test
1 parent 9bd4a80 commit cea05a4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core/tests/test_opds.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,33 @@ def test_license_tags_show_self_hosted_books(self):
16251625
assert 'status' in tags[0].attrib
16261626
assert 'available' == tags[0].attrib['status']
16271627

1628+
def test_license_tags_open_access(self):
1629+
# Arrange
1630+
edition, pool = self._edition(with_license_pool=True)
1631+
pool.open_access = True
1632+
pool.self_hosted = False
1633+
pool.unlimited_access = False
1634+
creation_time = datetime.datetime.utcnow()
1635+
1636+
# Act
1637+
tags = AcquisitionFeed.license_tags(
1638+
pool, None, None
1639+
)
1640+
1641+
# Assert
1642+
assert 1 == len(tags)
1643+
1644+
[tag] = tags
1645+
1646+
assert ('status' in tag.attrib) == True
1647+
assert 'available' == tag.attrib['status']
1648+
assert 'since' in tag.attrib
1649+
assert tag.attrib['since'] == pool.availability_time.strftime('%Y-%m-%dT%H:%M:%S+00:00')
1650+
assert 'until' in tag.attrib
1651+
assert tag.attrib['until'] == (creation_time + datetime.timedelta(days=21)).strftime('%Y-%m-%dT%H:%M:%SZ')
1652+
assert ('holds' in tag.attrib) == False
1653+
assert ('copies' in tag.attrib) == False
1654+
16281655
def test_single_entry(self):
16291656

16301657
# Here's a Work with two LicensePools.

0 commit comments

Comments
 (0)