Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Improved error when start_at and end_at and duration specified
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-gravgaard committed Jan 29, 2014
1 parent 6a1ccd7 commit df477d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions backdrop/read/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ def validate(self, request_args, context):
duration = request_args.get('duration')

if start_at and end_at and duration:
self.add_error("Absolute ('start_at' and 'end_at') and relative "
"('duration') time cannot be requested at the "
"same time")
self.add_error("Absolute and relative time cannot be requested at "
"the same time - either ask for 'start_at' and "
"'end_at', or ask for 'start_at'/'end_at' with "
"'duration'")

if start_at and end_at is None and duration is None:
self.add_error("Use of 'start_at' requires 'end_at' or 'duration'")
Expand Down
5 changes: 3 additions & 2 deletions tests/read/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ def test_duration_start_and_end_isnt_allowed(self):
})

assert_that(validation_result, is_invalid_with_message(
"Absolute ('start_at' and 'end_at') and relative ('duration') time "
"cannot be requested at the same time"))
"Absolute and relative time cannot be requested at the same time "
"- either ask for 'start_at' and 'end_at', or ask for "
"'start_at'/'end_at' with 'duration'"))

def test_duration_is_a_valid_number(self):
validation_result = validate_request_args({
Expand Down

0 comments on commit df477d4

Please sign in to comment.