Skip to content

Commit

Permalink
raise correct error when from and until parameters have different gra…
Browse files Browse the repository at this point in the history
…nularities

--HG--
extra : convert_revision : svn%3A882ca7fe-3cf8-0310-95c5-f9aabef819dd/pyoai/trunk%4034776
  • Loading branch information
jasper@882ca7fe-3cf8-0310-95c5-f9aabef819dd committed Apr 24, 2009
1 parent 039b9d0 commit 184f36e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
6 changes: 5 additions & 1 deletion HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
oaipmh changelog
================

2.4 (unreleased)
2.3.1 (2009-04-24)
================

Changes
-------

* Raise correct error when from and until parameters have different granularities
2.3 (2009-04-23)
================

Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

setup(
name='pyoai',
version='2.4dev',
version='2.3.1',
author='Infrae',
author_email='[email protected]',
url='http://www.infrae.com/download/oaipmh',
classifiers=["Development Status :: 4 - Beta",
"Programming Language :: Python",
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
"Environment :: Web Environment"],
description="""\
The oaipmh module is a Python implementation of an "Open Archives
Initiative Protocol for Metadata Harvesting" (version 2) client and server.
Expand Down
9 changes: 8 additions & 1 deletion src/oaipmh/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,14 @@ def handleRequest(self, request_kw):
raise error.BadArgumentError(
"The value '%s' of the argument "
"'%s' is not valid." %(until, 'until'))


if from_ is not None and until is not None:
if (('T' in from_ and not 'T' in until) or
('T' in until and not 'T' in from_)):
raise error.BadArgumentError(
"The request has different granularities for"
" the from and until parameters")

# now validate parameters
try:
validation.validateResumptionArguments(verb, request_kw)
Expand Down
12 changes: 12 additions & 0 deletions src/oaipmh/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ def test_badDateArgument(self):
"The value 'junk' of the argument 'until' is not valid.")],
xml)


def testDifferentGranularities(self):
xml = self._server.handleRequest({'verb': 'ListRecords',
'metadataPrefix': 'oai_dc',
'from': '2006-01-01',
'until': '2008-01-01T00:00:00Z'})
self.assertErrors(
[('badArgument',
"The request has different granularities for the from"
" and until parameters")],
xml)


def assertErrors(self, errors, xml):
self.assertEquals(errors, self.findErrors(xml))
Expand Down

0 comments on commit 184f36e

Please sign in to comment.