|
1 | 1 | import pastebin_python
|
2 | 2 | import pytest
|
3 |
| -import os |
| 3 | +import time |
4 | 4 |
|
| 5 | +from config import api_dev_key, username, password |
5 | 6 | from pastebin_python import PastebinPython
|
6 |
| - |
| 7 | +from tools import check_paste_in_list |
7 | 8 |
|
8 | 9 | @pytest.fixture(scope='module')
|
9 | 10 | def login_to_pastebin(request):
|
10 |
| - api_dev_key = os.environ.get('PASTE_API_KEY') |
11 |
| - username = os.environ.get('PASTE_USERNAME') |
12 |
| - password = os.environ.get('PASTE_PASSWORD') |
13 |
| - |
14 | 11 | pbin = PastebinPython(api_dev_key=api_dev_key)
|
15 | 12 | pbin.createAPIUserKey(username, password)
|
16 | 13 |
|
17 | 14 | return pbin
|
18 | 15 |
|
| 16 | +@pytest.mark.parametrize('paste_name', |
| 17 | + ['', 'my_name', 'my name', '12345']) |
| 18 | +def test_create_paste(login_to_pastebin, paste_name): |
| 19 | + time.sleep(5) |
19 | 20 |
|
20 |
| -def test_version(): |
21 |
| - assert pastebin_python.__version__ == '1.2' |
22 |
| - |
23 |
| - |
24 |
| -# def test_listUserPastes(login_to_pastebin): |
25 |
| -# assert len(login_to_pastebin.listUserPastes()) == 3 |
26 |
| - |
27 |
| - |
28 |
| -def test_create_paste(login_to_pastebin): |
29 | 21 | paste_text = 'This is teest paste text.'
|
30 |
| - |
31 |
| - paste_url = login_to_pastebin.createPaste(api_paste_code=paste_text, api_paste_name='test_paste') |
| 22 | + print("PASTE_NAME", paste_name) |
| 23 | + paste_url = login_to_pastebin.createPaste(api_paste_code=paste_text, api_paste_name=paste_name) |
32 | 24 |
|
33 | 25 | pastes = login_to_pastebin.listUserPastes()
|
34 |
| - paste_was_created = False |
35 |
| - for paste in pastes: |
36 |
| - if paste['paste_url'] == paste_url: |
37 |
| - paste_was_created = True |
38 | 26 |
|
39 |
| - assert paste_was_created == True |
| 27 | + assert check_paste_in_list(pastes, paste_url) == True |
40 | 28 |
|
41 | 29 |
|
42 | 30 | def test_delete_paste(login_to_pastebin):
|
43 | 31 | paste_text = 'This is teest paste text.'
|
44 | 32 | paste_url = login_to_pastebin.createPaste(api_paste_code=paste_text, api_paste_name='test_paste')
|
45 | 33 | api_paste_key = paste_url[21:]
|
46 | 34 |
|
47 |
| - import ipdb; ipdb.set_trace() |
| 35 | + # import ipdb; ipdb.set_trace() |
48 | 36 |
|
49 | 37 | login_to_pastebin.deletePaste(api_paste_key)
|
50 | 38 |
|
|
0 commit comments