-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pook | ||
import requests | ||
|
||
|
||
@pook.activate | ||
def test_simple_pook_request(): | ||
pook.get('server.com/foo').reply(204) | ||
res = requests.get('http://server.com/foo') | ||
assert res.status_code == 204 | ||
|
||
|
||
def test_enable_engine(): | ||
pook.get('server.com/foo').reply(204) | ||
res = requests.get('http://server.com/foo') | ||
assert res.status_code == 204 | ||
|
||
|
||
@pook.get('server.com/foo', reply=204) | ||
def test_decorator(): | ||
res = requests.get('http://server.com/foo') | ||
assert res.status_code == 204 | ||
|
||
|
||
def test_context_manager(): | ||
with pook.use(): | ||
pook.get('server.com/bar', reply=204) | ||
res = requests.get('http://server.com/bar') | ||
assert res.status_code == 204 | ||
|
||
|
||
def test_no_match_exception(): | ||
pook.get('server.com/bar', reply=204) | ||
try: | ||
requests.get('http://server.com/baz') | ||
except: | ||
pass | ||
else: | ||
raise RuntimeError('expected to fail') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import requests | ||
import pook | ||
import requests | ||
|
||
|
||
@pook.activate | ||
|