Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increasing code coverage #697

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions ppa/archive/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ def test_metadata_from_marc(self):

def test_index_item_type(self):
assert DigitizedWork.index_item_type() == "work"
assert DigitizedWork().index_item_type() == "work"


def test_index_data(self):
digwork = DigitizedWork.objects.create(
Expand Down Expand Up @@ -676,9 +678,10 @@ def test_count_pages_nonhathi(self):
def test_count_pages_eebo(self, mock_eebo_page_count):
work = DigitizedWork(source_id="A1234", source=DigitizedWork.EEBO)
mock_eebo_page_count.return_value = 123
work.count_pages()
result = work.count_pages()
assert result == 123
assert work.page_count == 123
mock_eebo_page_count.assert_called_with(work.source_id)
mock_eebo_page_count.assert_called_once_with(work.source_id)

def test_count_pages_excerpt(self):
work = DigitizedWork(source_id="CW79279237", pages_digital="1-10")
Expand Down Expand Up @@ -889,6 +892,10 @@ def test_is_public(self):
work = DigitizedWork(source_id="chi.79279237")
# default status for new records is public
assert work.is_public()

work.status = DigitizedWork.PUBLIC
assert work.is_public()

work.status = DigitizedWork.SUPPRESSED
assert not work.is_public()

Expand Down Expand Up @@ -1250,6 +1257,12 @@ def test_gale_page_index_data(self, mock_gale_get_item_pages):
page_data = list(Page.page_index_data(gale_excerpt))
assert len(page_data) == 2

def test_cluster_str():
cluster_id = "group-one"
assert str(Cluster(cluster_id=cluster_id)) == cluster_id


def test_cluster_repr():
@patch.object(Cluster, "__str__")
def test_cluster_repr(mock_str):
mock_str.return_value = "group-one"
assert repr(Cluster(cluster_id="group-one")) == "<cluster group-one>"
Loading