示例#1
0
 def test_list_records_verb_return_bad_argument_without_metadata_prefix(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#2
0
 def test_list_records_verb_return_bad_argument_if_invalid_argument(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'x': 'a'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#3
0
 def test_any_verb_return_bad_argument_if_cant_parse_dates(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-0207', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#4
0
 def test_any_verb_return_bad_argument_if_cant_parse_dates(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-0207', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#5
0
 def test_any_verb_return_cannot_diss_format_if_metadata_prefix_is_not_oai_dc(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_marc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="cannotDisseminateFormat"/>', resp)
示例#6
0
 def test_any_verb_return_cannot_diss_format_if_metadata_prefix_is_not_oai_dc(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_marc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="cannotDisseminateFormat"/>', resp)
示例#7
0
 def test_list_records_verb_return_bad_argument_if_invalid_argument(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'x': 'a'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#8
0
 def test_list_records_verb_return_bad_argument_without_metadata_prefix(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#9
0
 def test_get_record_verb_return_bad_argument_without_identifier(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#10
0
 def test_get_record_verb_return_bad_argument_without_identifier(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#11
0
 def test_any_verb_returns_bad_resumption_token_with_invalid_resumption_token(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc', 'resumptionToken': '3'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badResumptionToken"/>', resp)
示例#12
0
 def test_deleted_register_show_only_header_info(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'metadataPrefix': 'oai_dc', 'identifier': '37t'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<header status="deleted">', resp)
     self.assertNotIn('<metadata>', resp)
示例#13
0
 def test_list_sets_verb_return_success_without_invalid_argument(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListSets'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<setSpec>edufba</setSpec>', resp)
示例#14
0
 def test_list_identifiers_verb_return_success_with_metadata_prefix(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListIdentifiers', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<setSpec>edufba</setSpec>', resp)
示例#15
0
 def test_list_metadata_formats_verb_return_bad_argument_if_invalid_argument(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListMetadataFormats', 'x': 'a'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#16
0
 def test_any_verb_return_no_record_match_if_search_returns_empty(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-02-07', 'until': '2014-02-08', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="noRecordsMatch"/>', resp)
示例#17
0
 def test_any_verb_return_id_not_exist_if_inexistent_id(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'identifier': 'bla', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="idDoesNotExist">No matching identifier</error>', resp)
示例#18
0
 def test_any_verb_returns_bad_resumption_token_with_invalid_resumption_token(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc', 'resumptionToken': '3'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badResumptionToken"/>', resp)
示例#19
0
 def test_list_identifiers_verb_return_success_with_metadata_prefix(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListIdentifiers', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<setSpec>edufba</setSpec>', resp)
示例#20
0
 def test_any_verb_return_id_not_exist_if_inexistent_id(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'identifier': 'bla', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="idDoesNotExist">No matching identifier</error>', resp)
示例#21
0
 def test_list_sets_verb_return_success_without_invalid_argument(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListSets'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<setSpec>edufba</setSpec>', resp)
示例#22
0
 def test_list_metadata_formats_verb_with_identifier_returns_success(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListMetadataFormats', 'identifier': '38t'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<metadataPrefix>oai_dc</metadataPrefix>', resp)
示例#23
0
 def test_list_metadata_formats_verb_with_identifier_returns_success(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListMetadataFormats', 'identifier': '38t'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<metadataPrefix>oai_dc</metadataPrefix>', resp)
示例#24
0
 def test_any_verb_return_no_record_match_if_search_returns_empty(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-02-07', 'until': '2014-02-08', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="noRecordsMatch"/>', resp)
示例#25
0
 def test_deleted_register_show_only_header_info(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'metadataPrefix': 'oai_dc', 'identifier': '37t'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<header status="deleted">', resp)
     self.assertNotIn('<metadata>', resp)
示例#26
0
 def test_list_metadata_formats_verb_return_bad_argument_if_invalid_argument(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListMetadataFormats', 'x': 'a'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badArgument"/>', resp)
示例#27
0
 def test_resumption_token_show_last_page(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc', 'resumptionToken': '2'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('40t', resp)
示例#28
0
 def test_list_records_with_from_and_until(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-02-04', 'until': '2014-02-04', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('<datestamp>2014-02-04</datestamp>', resp)
示例#29
0
 def test_list_records_with_set(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'set': 'bla-x-ble', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('<setSpec>bla-x-ble</setSpec>', resp)
示例#30
0
 def test_list_records_with_from_and_until(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'from': '2014-02-04', 'until': '2014-02-04', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('<datestamp>2014-02-04</datestamp>', resp)
示例#31
0
 def test_list_records_with_set(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'set': 'bla-x-ble', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('<setSpec>bla-x-ble</setSpec>', resp)
示例#32
0
 def test_resumption_token_show_last_page(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc', 'resumptionToken': '2'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 1)
     self.assertIn('40t', resp)
示例#33
0
 def test_resumption_token_limit_results(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 2)
     self.assertIn('36t', resp)
     self.assertIn('37t', resp)
示例#34
0
 def test_resumption_token_limit_results(self):
     request = testing.DummyRequest()
     request.registry.settings = settings
     request.db = settings['db_conn']
     request.params = {'verb': 'ListRecords', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertEqual(resp.count('<record>'), 2)
     self.assertIn('36t', resp)
     self.assertIn('37t', resp)
示例#35
0
 def test_get_record_with_identifier(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.params = {'verb': 'GetRecord', 'identifier': '37t', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<identifier>37t</identifier>', resp)
     self.assertIn(
     '<request verb="GetRecord" metadataPrefix="oai_dc" identifier="37t">http://books.scielo.org/oai/</request>',
     resp)
     self.assertEqual(resp.count('<record>'), 1)
示例#36
0
 def test_get_record_with_identifier(self):
     request = testing.DummyRequest()
     request.db = settings['db_conn']
     request.url = 'http://localhost:6543/oai-pmh?'
     request.params = {'verb': 'GetRecord', 'identifier': '37t', 'metadataPrefix': 'oai_dc'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<identifier>37t</identifier>', resp)
     self.assertIn(
     '<request verb="GetRecord" metadataPrefix="oai_dc" identifier="37t">http://localhost:6543/oai-pmh</request>',
     resp)
     self.assertEqual(resp.count('<record>'), 1)
示例#37
0
 def test_invalid_verb_return_bad_verb_error(self):
     request = testing.DummyRequest()
     request.params = {'verb':'bla'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badVerb">Illegal OAI verb</error>', resp)
示例#38
0
 def test_invalid_verb_return_bad_verb_error(self):
     request = testing.DummyRequest()
     request.params = {'verb':'bla'}
     resp = oai_pmh(request)
     resp = str(resp)
     self.assertIn('<error code="badVerb">Illegal OAI verb</error>', resp)