Exemple #1
0
 def test_throws_key_error(self):
     qdict = {'rfr_id': ['info:sid/libx'],
              'rft.atitle': [''],
              'rft.au': ['Coleman, Gabriella'],
              'rft.aufirst': ['Gabriella'],
              'rft.aulast': ['Coleman'],
              'rft.btitle': ['Our Weirdness Is Free: The logic of Anonymous \\u2014 online army, agent of chaos, and seeker of justice'],
              'rft.genre': ['bookitem'],
              'rft.pub': ['Triple Canopy'],
              'rft_id': ['http://canopycanopycanopy.com/15/our_weirdness_is_free'],
              'rft_val_fmt': ['info:ofi/fmt:kev:mtx:book'],
              'url_ver': ['Z39.88-2004']}
     b = from_dict(qdict)
     self.assertEqual(b['title'], 'Unknown')
Exemple #2
0
 def test_missing_title(self):
     #Mock a sample request dict coming from Django.
     request_dict = {
     'rft.pub': ['Triple Canopy'],
     'rft_val_fmt': ['info:ofi/fmt:kev:mtx:book'],
     'rfr_id': ['info:sid/libx:brown'],
     'rft.au': ['Coleman, Gabriella'],
     'rft.aulast': ['Coleman'],
     'rft.aufirst': ['Gabriella'],
     'rft_id': ['http://canopycanopycanopy.com/15/our_weirdness_is_free'],
     'rft.btitle': ['Our Weirdness Is Free: The logic of Anonymous \u2014 online army, agent of chaos, and seeker of justice'],
     'url_ver': ['Z39.88-2004'],
     'rft.atitle': [''],
     'rft.genre': ['bookitem']}
     b = from_dict(request_dict)
     ourl = to_openurl(b)
     parsed_ourl = parse_qs(ourl)
     self.assertTrue('bookitem' in parsed_ourl.get('rft.genre'))
     self.assertTrue('Coleman, Gabriella' in parsed_ourl.get('rft.au'))
 def test_throws_key_error(self):
     qdict = {
         'rfr_id': ['info:sid/libx'],
         'rft.atitle': [''],
         'rft.au': ['Coleman, Gabriella'],
         'rft.aufirst': ['Gabriella'],
         'rft.aulast': ['Coleman'],
         'rft.btitle': [
             'Our Weirdness Is Free: The logic of Anonymous \\u2014 online army, agent of chaos, and seeker of justice'
         ],
         'rft.genre': ['bookitem'],
         'rft.pub': ['Triple Canopy'],
         'rft_id':
         ['http://canopycanopycanopy.com/15/our_weirdness_is_free'],
         'rft_val_fmt': ['info:ofi/fmt:kev:mtx:book'],
         'url_ver': ['Z39.88-2004']
     }
     b = from_dict(qdict)
     self.assertEqual(b['title'], 'Unknown')
Exemple #4
0
 def test_dissertation(self):
     request = {
         'ctx_enc': ['info:ofi/enc:UTF-8'],
         'ctx_ver': ['Z39.88-2004'],
         'rft.au': ['Mangla, Akshay'],
         'rft.aufirst': ['Akshay'],
         'rft.aulast': ['Mangla'],
         'rft.date': ['2013-01-01'],
         'rft.genre': ['dissertations & theses'],
         'rft.title': ['Rights for the Voiceless: The State, Civil Society and Primary Education in Rural India'],
         'rft_id': ['info:doi/'],
         'rft_val_fmt': ['info:ofi/fmt:kev:mtx:dissertation']
     }
     b = from_dict(request)
     ourl = to_openurl(b)
     parsed_ourl = parse_qs(ourl)
     self.assertTrue('dissertation' in parsed_ourl.get('rft.genre'))
     self.assertTrue('Rights for the Voiceless' in parsed_ourl.get('rft.title')[0])
     self.assertTrue('Mangla, Akshay') in parsed_ourl.get('rft.au')
     self.assertTrue('2013' in parsed_ourl.get('rft.date'))
 def test_dissertation(self):
     request = {
         'ctx_enc': ['info:ofi/enc:UTF-8'],
         'ctx_ver': ['Z39.88-2004'],
         'rft.au': ['Mangla, Akshay'],
         'rft.aufirst': ['Akshay'],
         'rft.aulast': ['Mangla'],
         'rft.date': ['2013-01-01'],
         'rft.genre': ['dissertations & theses'],
         'rft.title': [
             'Rights for the Voiceless: The State, Civil Society and Primary Education in Rural India'
         ],
         'rft_id': ['info:doi/'],
         'rft_val_fmt': ['info:ofi/fmt:kev:mtx:dissertation']
     }
     b = from_dict(request)
     ourl = to_openurl(b)
     parsed_ourl = parse_qs(ourl)
     self.assertTrue('dissertation' in parsed_ourl.get('rft.genre'))
     self.assertTrue(
         'Rights for the Voiceless' in parsed_ourl.get('rft.title')[0])
     self.assertTrue('Mangla, Akshay') in parsed_ourl.get('rft.au')
     self.assertTrue('2013' in parsed_ourl.get('rft.date'))
 def test_missing_title(self):
     #Mock a sample request dict coming from Django.
     request_dict = {
         'rft.pub': ['Triple Canopy'],
         'rft_val_fmt': ['info:ofi/fmt:kev:mtx:book'],
         'rfr_id': ['info:sid/libx:brown'],
         'rft.au': ['Coleman, Gabriella'],
         'rft.aulast': ['Coleman'],
         'rft.aufirst': ['Gabriella'],
         'rft_id':
         ['http://canopycanopycanopy.com/15/our_weirdness_is_free'],
         'rft.btitle': [
             'Our Weirdness Is Free: The logic of Anonymous \u2014 online army, agent of chaos, and seeker of justice'
         ],
         'url_ver': ['Z39.88-2004'],
         'rft.atitle': [''],
         'rft.genre': ['bookitem']
     }
     b = from_dict(request_dict)
     ourl = to_openurl(b)
     parsed_ourl = parse_qs(ourl)
     self.assertTrue('bookitem' in parsed_ourl.get('rft.genre'))
     self.assertTrue('Coleman, Gabriella' in parsed_ourl.get('rft.au'))