Skip to content

Commit

Permalink
Created custom exception classes (#778)
Browse files Browse the repository at this point in the history
* Renamed custom exception errors

Created custom exception classes

Created custom exception classes

Created custom exception classes

Fixed coding style

Created custom exception classes

* Enhance imports

* Typo

* Renamed none to null
  • Loading branch information
farzaneka authored and pylover committed May 13, 2019
1 parent 155277a commit 04bcb44
Show file tree
Hide file tree
Showing 23 changed files with 494 additions and 264 deletions.
279 changes: 278 additions & 1 deletion dolphin/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def __init__(self, related_issue_id):


class StatusResourceNotFound(HTTPKnownStatus):

def __init__(self, resource_id):
self.status = f'609 Resource not found with id: {resource_id}'

Expand Down Expand Up @@ -168,6 +167,72 @@ class StatusSummaryNotInForm(HTTPKnownStatus):
status = '799 Summary Not In Form'


class StatusReleaseNotFound(HTTPKnownStatus):
status = '607 Release Not Found'


class StatusInvalidReleaseIdType(HTTPKnownStatus):
status = '750 Invalid Release Id Type'


class StatusInvalidStatusValue(HTTPKnownStatus):
def __init__(self, statuses_values):
self.status = f'705 Invalid status value, only one of ' \
f'"{", ".join(statuses_values)}" will be accepted'


class StatusProjectNotFound(HTTPKnownStatus):
status = '601 Project Not Found'


class StatusHiddenProjectIsNotEditable(HTTPKnownStatus):
status = '746 Hidden Project Is Not Editable'


class StatusPhaseNotFound(HTTPKnownStatus):
status = '613 Phase Not Found'


class StatusInvalidWorkflowIdType(HTTPKnownStatus):
status = '743 Invalid Workflow Id Type'


class StatusWorkflowNotFound(HTTPKnownStatus):
status = '616 Workflow Not Found'


class StatusInvalidRoleValue(HTTPKnownStatus):
status = '756 Invalid Role Value'


class StatusTitleIsNull(HTTPKnownStatus):
status = '727 Title Is Null'


class StatusMaxLenghtForTitle(HTTPKnownStatus):

def __init__(self, lenght):
self.status = f'704 At Most {lenght} Characters Are Valid For Title'


class StatusEventTypeIdIsNull(HTTPKnownStatus):
status = '798 Event Type Id Is Null'


class StatusMaxLenghtForDescription(HTTPKnownStatus):
def __init__(self, lenght):
self.status = f'703 At Most {lenght} Characters Are Valid For '\
'Description'


class StatusTitleNotInForm(HTTPKnownStatus):
status = '710 Title Not In Form'


class StatusEndDateNotInForm(HTTPKnownStatus):
status = '793 End Date Not IN Form'


class StatusStartDateNotInForm(HTTPKnownStatus):
status = '792 Start Date Not In Form'

Expand Down Expand Up @@ -207,3 +272,215 @@ class StatusQueryParameterNotInFormOrQueryString(HTTPKnownStatus):
class StatusHoursMustBeGreaterThanZero(HTTPKnownStatus):
status = '914 Hours Must Be Greater Than 0'


class StatusTypeIdNotInForm(HTTPKnownStatus):
status = '794 Type Id Not In Form'


class StatusInvalidOrderType(HTTPKnownStatus):
status = '741 Invalid Order Type'


class StatusInvalidSkillIdType(HTTPKnownStatus):
status = '788 Invalid Skill Id Type'


class StatusOrderNotInForm(HTTPKnownStatus):
status = '742 Order Not In Form'


class StatusInvalidTargetIssueIdType(HTTPKnownStatus):
status = '781 Invalid Target Issue Id Type'


class StatusTargetIssueIdNotInForm(HTTPKnownStatus):
status = '780 Target Issue Id Not In Form'


class StatusTargetIssueIdIsNull(HTTPKnownStatus):
status = '779 Target Issue Id Is Null'


class StatusInvalidTitleFormat(HTTPKnownStatus):
status = '747 Invalid Title Format'


class StatusInvalidMemberIdType(HTTPKnownStatus):
status = '736 Invalid Member Id Type'


class StatusMemberIdNotInForm(HTTPKnownStatus):
status = '735 Member Id Not In Form'


class StatusMemberIdIsNull(HTTPKnownStatus):
status = '774 Member Id Is Null'


class StatusInvalidProjectIdType(HTTPKnownStatus):
status = '714 Invalid Project Id Type'


class StatusProjectIdNotInForm(HTTPKnownStatus):
status = '713 Project Id Not In Form'


class StatusAuthorizationCodeNotInForm(HTTPKnownStatus):
status = '762 Authorization Code Not In Form'


class StatusInvalidOrganizationIdType(HTTPKnownStatus):
status = '763 Invalid Organization Id Type'


class StatusOrganizationIdNotINForm(HTTPKnownStatus):
status = '761 Organization Id Not In Form'


class StatusTokenNotInForm(HTTPKnownStatus):
status = '757 Token Not In Form'


class StatusRedirectUriNotInForm(HTTPKnownStatus):
status = '766 Redirect Uri Not In From'


class StatusApplicationIdNotInForm(HTTPKnownStatus):
status = '764 Application Id Not In Form'


class StatusScopesNotInForm(HTTPKnownStatus):
status = '765 Scopes Not In Form'


class StatusRoleNotInForm(HTTPKnownStatus):
status = '755 Role Not In Form'


class StatusInvalidEmailFormat(HTTPKnownStatus):
status = '754 Invalid Email Format'


class StatusEmailNotInForm(HTTPKnownStatus):
status = '753 Email Not In Form'


class StatusInvalidPhaseIdType(HTTPKnownStatus):
status = '738 Invalid Phase Id Type'


class StatusPhaseIdNotInForm(HTTPKnownStatus):
status = '737 Phase Id Not In Form'


class StatusInvalidCutoffFormat(HTTPKnownStatus):
status = '702 Invalid Cutoff Format'


class StatusCutoffNotInForm(HTTPKnownStatus):
status = '712 Cutoff Not In Form'


class StatusFileNotInForm(HTTPKnownStatus):
status = '758 File Not In Form'


class StatusPhaseIdIsNull(HTTPKnownStatus):
status = '770 Phase Id Is Null'


class StatusInvalidResourceIdType(HTTPKnownStatus):
status = '716 Invalid Resource Id Type'


class StatusResourceIdNotInForm(HTTPKnownStatus):
status = '715 Resource Id Not In Form'


class StatusResourceIdIsNull(HTTPKnownStatus):
status = '769 Resource Id Is Null'


class StatusStatusNotInForm(HTTPKnownStatus):
status = '719 Status Not In Form'


class StatusInvalidDaysType(HTTPKnownStatus):
status = '721 Invalid Days Type'


class StatusInvalidDueDateFormat(HTTPKnownStatus):
status ='701 Invalid Due Date Format'


class StatusManagerReferenceIdNotInForm(HTTPKnownStatus):
status = '777 Manager Reference Id Not In Form'


class StatusManagerReferenceIdIsNull(HTTPKnownStatus):
status = '778 Manager Reference Id Is Null'


class StatusInvalidLaunchDateFormat(HTTPKnownStatus):
status = '784 Invalid Launch Date Format'


class StatusLaunchDateNotInForm(HTTPKnownStatus):
status = '783 Launch Date Not In Form'


class StatusInvalidGroupIdType(HTTPKnownStatus):
status = '797 Invalid Group Id Type'


class StatusGroupIdNotInForm(HTTPKnownStatus):
status = '795 Group Id Not In Form'


class StatusGroupIdIsNull(HTTPKnownStatus):
status = '796 Group Id Is Null'


class StatusManagerIdNotInForm(HTTPKnownStatus):
status = '786 Manager Id Not In Form'


class StatusManagerIdIsNull(HTTPKnownStatus):
status = '785 Manager Id Is Null'


class StatusIssueIdIsNull(HTTPKnownStatus):
status = '775 Issue Id Is Null'


class StatusInvalidIssueIdType(HTTPKnownStatus):
status = '722 Invalid Issue Id Type'


class StatusDaysNotInForm(HTTPKnownStatus):
status = '720 Days Not In Form'


class StatusKindNotInForm(HTTPKnownStatus):
status = '718 Kind Not In Form'


class StatusDueDateNotInForm(HTTPKnownStatus):
status = '711 Due Date Not In Form'


class StatusPriorityNotInForm(HTTPKnownStatus):
status = '768 Priority Not In Form'


class StatusInvalidPriority(HTTPKnownStatus):
def __init__(self, issue_priorities):
self.status = f'767 Invalid priority, only one of ' \
f'"{", ".join(issue_priorities)}" will be accepted'


class StatusInvalidKind(HTTPKnownStatus):
def __init__(self, issue_kinds):
self.status = f'717 Invalid kind, only one of ' \
f'"{", ".join(issue_kinds)}" will be accepted'

7 changes: 3 additions & 4 deletions dolphin/tests/test_draftissue_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_finalize(self):
'Project not found with integer type',
json=given | dict(projectId=0, title='New title')
)
assert status == '601 Project not found with id: 0'
assert status == '601 Project Not Found'

when(
'Relate issue not found with string type',
Expand Down Expand Up @@ -217,8 +217,7 @@ def test_finalize(self):
'Title is repetitive',
json=Update(title='First issue')
)
assert status == '600 Another issue with title: "First issue" '\
'is already exists.'
assert status == '600 Repetitive Title'

when(
'Title length is more than limit',
Expand Down Expand Up @@ -284,7 +283,7 @@ def test_finalize(self):
json=given | dict(status='progressing') | \
dict(title='Another title')
)
assert status == '705 Invalid status, only one of "to-do, ' \
assert status == '705 Invalid status value, only one of "to-do, ' \
'in-progress, on-hold, complete, done" will be accepted'

when(
Expand Down
2 changes: 1 addition & 1 deletion dolphin/tests/test_draftissue_relate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_relate(self):
'Trying to pass with none issue id',
json=dict(targetIssueId=None)
)
assert status == '779 Target Issue Id Is None'
assert status == '779 Target Issue Id Is Null'

when(
'Trying to pass with invalid issue id type',
Expand Down
4 changes: 2 additions & 2 deletions dolphin/tests/test_event_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def test_add(self):
'Title length is more than limit',
json=given | dict(title=((50 + 1) * 'a'))
)
assert status == '704 At Most 50 Characters Valid For Title'
assert status == '704 At Most 50 Characters Are Valid For Title'

when(
'Trying to pass with none title',
json=given | dict(title=None)
)
assert status == '727 Title Is None'
assert status == '727 Title Is Null'

when(
'Trying to pass without start date',
Expand Down
4 changes: 2 additions & 2 deletions dolphin/tests/test_event_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def test_add(self):
'Title length is more than limit',
json=given | dict(title=((50 + 1) * 'a'))
)
assert status == '704 At Most 50 Characters Valid For Title'
assert status == '704 At Most 50 Characters Are Valid For Title'

when(
'Trying to pass with none title',
json=given | dict(title=None)
)
assert status == '727 Title Is None'
assert status == '727 Title Is Null'

when(
'Start date format is wrong',
Expand Down
4 changes: 2 additions & 2 deletions dolphin/tests/test_eventtype_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def test_create(self):
'Title length is more than limit',
json=dict(title=((50 + 1) * 'a'))
)
assert status == '704 At Most 50 Characters Valid For Title'
assert status == '704 At Most 50 Characters Are Valid For Title'

when(
'Trying to pass with none title',
json=dict(title=None)
)
assert status == '727 Title Is None'
assert status == '727 Title Is Null'

when(
'Description length is less than limit',
Expand Down
4 changes: 2 additions & 2 deletions dolphin/tests/test_eventtype_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_update(self):
'Title length is more than limit',
json=given | dict(title=(50 + 1) * 'a')
)
assert status == '704 At Most 50 Characters Valid For Title'
assert status == '704 At Most 50 Characters Are Valid For Title'

when('Invalid parameter is in the form', json=dict(a='a'))
assert status == '707 Invalid field, only following fields are ' \
Expand All @@ -87,7 +87,7 @@ def test_update(self):
'Trying to pass with none title',
json=dict(title=None)
)
assert status == '727 Title Is None'
assert status == '727 Title Is Null'

when(
'Description length is less than limit',
Expand Down
Loading

0 comments on commit 04bcb44

Please sign in to comment.