-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sgaynetdinov/use_post
Send payload use POST method
- Loading branch information
Showing
5 changed files
with
72 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest | ||
isort | ||
isort | ||
pytest-mock |
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,31 @@ | ||
import io | ||
|
||
import vk | ||
from vk.fetch import Session | ||
|
||
|
||
def test_url_open(mocker): | ||
mocker.patch('vk.fetch.urlopen') | ||
|
||
mock_json = mocker.patch('json.load') | ||
mock_json.return_value = {'response': [{ | ||
"id": 1, | ||
"first_name": "Павел", | ||
"last_name": "Дуров", | ||
"domain": "durov", | ||
}]} | ||
|
||
api = vk.Api('TOKEN') | ||
user = api.get_user('durov') | ||
|
||
assert user.domain == 'durov' | ||
|
||
|
||
def test_upload_photo(): | ||
file_obj = io.BytesIO(b'Python developer and blogger.') | ||
data, boundary = Session()._file_upload(file_obj) | ||
|
||
assert b'Content-Disposition: file; name="photo"; filename="photo.jpg"' in data | ||
assert b'Content-Type: application/octet-stream' in data | ||
assert b'Python developer and blogger.' in data | ||
assert boundary.encode() in data |
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
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