Example #1
0
 def get_prev(self):
     """Previous edition of work"""
     if len(self.get('works', [])) != 1:
         return
     wkey = self.works[0].get_olid()
     if not wkey:
         return
     editions = sorted_work_editions(wkey)
     try:
         i = editions.index(self.get_olid())
     except ValueError:
         return
     if i == 0:
         return
     return editions[i - 1]
Example #2
0
 def get_next(self):
     """Next edition of work"""
     if len(self.get('works', [])) != 1:
         return
     wkey = self.works[0].get_olid()
     if not wkey:
         return
     editions = sorted_work_editions(wkey)
     try:
         i = editions.index(self.get_olid())
     except ValueError:
         return
     if i + 1 == len(editions):
         return
     return editions[i + 1]
Example #3
0
 def get_prev(self):
     """Previous edition of work"""
     if len(self.get('works', [])) != 1:
         return
     wkey = self.works[0].get_olid()
     if not wkey:
         return
     editions = sorted_work_editions(wkey)
     try:
         i = editions.index(self.get_olid())
     except ValueError:
         return
     if i == 0:
         return
     return editions[i - 1]
Example #4
0
 def get_next(self):
     """Next edition of work"""
     if len(self.get('works', [])) != 1:
         return
     wkey = self.works[0].get_olid()
     if not wkey:
         return
     editions = sorted_work_editions(wkey)
     try:
         i = editions.index(self.get_olid())
     except ValueError:
         return
     if i + 1 == len(editions):
         return
     return editions[i + 1]
Example #5
0
def test_sorted_work_editions():
    json_data = '''{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"fl":"edition_key",
"indent":"on",
"wt":"json",
"q":"key:OL100000W"}},
"response":{"numFound":1,"start":0,"docs":[
{
 "edition_key":["OL7536692M","OL7825368M","OL3026366M"]}]
}}'''
    expect = ["OL7536692M","OL7825368M","OL3026366M"]
    assert sorted_work_editions('OL100000W', json_data=json_data) == expect
def test_sorted_work_editions():
    json_data = '''{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"fl":"edition_key",
"indent":"on",
"wt":"json",
"q":"key:OL100000W"}},
"response":{"numFound":1,"start":0,"docs":[
{
 "edition_key":["OL7536692M","OL7825368M","OL3026366M"]}]
}}'''
    expect = ["OL7536692M", "OL7825368M", "OL3026366M"]
    assert sorted_work_editions('OL100000W', json_data=json_data) == expect