Skip to content

Commit

Permalink
Merge pull request #137 from unt-libraries/remove-unused-views
Browse files Browse the repository at this point in the history
Remove unused views
  • Loading branch information
madhuBayy authored Nov 8, 2019
2 parents 4a54bb8 + 217af95 commit 93b8ae6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 86 deletions.
5 changes: 0 additions & 5 deletions coda/coda_mdstore/presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
from . import exceptions
from coda_mdstore.models import Bag, Bag_Info, Node, External_Identifier


pairtreeCandidateList = [
"http://example.com/data3/coda-001/store/pairtree_root/",
"http://example.com/data4/coda-002/store/pairtree_root/",
]
XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml/"
XHTML = "{%s}" % XHTML_NAMESPACE
XHTML_NSMAP = {None: XHTML_NAMESPACE}
Expand Down
14 changes: 1 addition & 13 deletions coda/coda_mdstore/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from django.core.paginator import Paginator, Page
from django.core.paginator import Page
from django.conf import settings
from lxml import etree, objectify
from codalib import bagatom
Expand Down Expand Up @@ -53,18 +53,6 @@ def test_return_value(self):
assert result == 50.0


class TestBagFullTextSearch:
"""
Tests for coda_mdstore.views.bagFullTextSearch.
"""

@pytest.mark.django_db
def test_returns_paginator_object(self):
factories.FullBagFactory.create_batch(15)
paginator = views.bagFullTextSearch('test search')
assert isinstance(paginator, Paginator)


@pytest.mark.django_db
class TestBagSearch:
"""
Expand Down
38 changes: 0 additions & 38 deletions coda/coda_mdstore/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,44 +609,6 @@ def test_returns_status_code_200(self):
assert 0


class TestBagURLListScrapeView:
"""
Tests for coda_mdstore.views.bagURLListScrape.
"""

@pytest.fixture(autouse=True)
def setup_fixtures(self, monkeypatch):
file_handle = mock.Mock()
file_handle.info().getheader.side_effect = ['text/plain', '255']

self.getFileHandle = mock.Mock(return_value=file_handle)
monkeypatch.setattr(
'coda_mdstore.views.getFileHandle', self.getFileHandle)

def test_raises_not_found_when_object_not_found(self, rf):
request = rf.get('/')
response = views.bagURLListScrape(request, 'ark:/00001/id')

assert response.status_code == 404
assert isinstance(response, http.HttpResponseNotFound)
assert response.content == "There is no bag with id 'ark:/00001/id'."

@pytest.mark.xfail(reason='pairtreeCandidateList is not available '
'in scope.')
def test_raises_http404_file_handle_is_falsy(self, rf):
FullBagFactory.create()
self.getFileHandle.return_value = False
request = rf.get('/')

with pytest.raises(http.Http404):
views.bagURLListScrape(request, 'ark:/00001/id')

@pytest.mark.xfail(reason='pairtreeCandidateList is not available '
'in scope.')
def test_response_content(self):
assert 0


class TestBagFullTextSearchHTMLView:
"""
Tests for coda_mdstore.views.bagFullTextSearchHTML.
Expand Down
30 changes: 0 additions & 30 deletions coda/coda_mdstore/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from django.core.urlresolvers import reverse

from coda_mdstore import exceptions
from coda_mdstore.presentation import pairtreeCandidateList

MAINTENANCE_MSG = settings.MAINTENANCE_MSG
utf8_decoder = codecs.getdecoder("utf-8")
Expand Down Expand Up @@ -606,26 +605,6 @@ def bagURLList(request, identifier):
return resp


def bagURLListScrape(request, identifier):
"""
Scrape the index to get a list of files
"""

try:
Bag.objects.get(name=identifier)
except Bag.DoesNotExist:
return HttpResponseNotFound(
"There is no bag with id '%s'." % identifier
)
handle = getFileHandle(identifier, "", pairtreeCandidateList)
if not handle:
raise Http404("Unable to browse bag contents.")
fileList = getFileList(handle.url)
fileListString = "\n".join(fileList)
resp = HttpResponse(fileListString)
return resp


def bagProxy(request, identifier, filePath):
"""
Attempt to proxy a file from within the given bag
Expand Down Expand Up @@ -751,15 +730,6 @@ def bagFullTextSearchHTML(request):
)


def bagFullTextSearch(searchString, listSize=50):
"""
Generic interface to take a search string and return a feed of bags
"""

bagList = bagSearch(searchString)
return Paginator(bagList, listSize)


def percent(numerator, denominator):
"""
calculate the percentage from numerator and denominator
Expand Down

0 comments on commit 93b8ae6

Please sign in to comment.