Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Feb 27, 2019
1 parent 180c700 commit 018b626
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions unrest/tests/crud/get_pk.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,19 @@ def get(payload, fruit_id=None):
'tree_id': 2,
}
]

def test_declare_without_method(self):
rest = UnRest(self.app, self.session, framework=self.__framework__)
tree = rest(Tree)

@tree.declare('POST')
def post(payload, id=None):
return {'Hey': 'Overridden'}

assert post is not None

code, json = self.fetch(
'/api/tree', method="POST", json={'name': 'cedar'}
)
assert code == 200
assert json == {'Hey': 'Overridden'}
21 changes: 21 additions & 0 deletions unrest/tests/features/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ def test_endpoint_options(self):
'methods': ['GET', 'OPTIONS'],
}

def test_endpoint_options_no_methods(self):
rest = UnRest(self.app, self.session, framework=self.__framework__)
rest(Tree, methods=[])
code, json = self.fetch('/api/tree', method="OPTIONS")
assert code == 404

def test_endpoint_options_no_methods_but_declare(self):
rest = UnRest(self.app, self.session, framework=self.__framework__)
tree = rest(Tree, methods=[])

@tree.declare('GET')
def get(payload, id=None):
return {'Hey': 'Overridden'}

@tree.declare('POST')
def post(payload, id=None):
return {'Hey': 'Overridden'}

code, json = self.fetch('/api/tree', method="OPTIONS")
assert code == 200

def test_openapi(self):
rest = UnRest(
self.app,
Expand Down

0 comments on commit 018b626

Please sign in to comment.