Skip to content

Commit 39d6a05

Browse files
committed
Update tests
1 parent 6c26719 commit 39d6a05

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

tests/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
api_dev_key = os.environ.get('PASTE_API_KEY')
4+
username = os.environ.get('PASTE_USERNAME')
5+
password = os.environ.get('PASTE_PASSWORD')

tests/tests_paste_basic.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,38 @@
11
import pastebin_python
22
import pytest
3-
import os
3+
import time
44

5+
from config import api_dev_key, username, password
56
from pastebin_python import PastebinPython
6-
7+
from tools import check_paste_in_list
78

89
@pytest.fixture(scope='module')
910
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-
1411
pbin = PastebinPython(api_dev_key=api_dev_key)
1512
pbin.createAPIUserKey(username, password)
1613

1714
return pbin
1815

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)
1920

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):
2921
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)
3224

3325
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
3826

39-
assert paste_was_created == True
27+
assert check_paste_in_list(pastes, paste_url) == True
4028

4129

4230
def test_delete_paste(login_to_pastebin):
4331
paste_text = 'This is teest paste text.'
4432
paste_url = login_to_pastebin.createPaste(api_paste_code=paste_text, api_paste_name='test_paste')
4533
api_paste_key = paste_url[21:]
4634

47-
import ipdb; ipdb.set_trace()
35+
# import ipdb; ipdb.set_trace()
4836

4937
login_to_pastebin.deletePaste(api_paste_key)
5038

tests/tools.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def check_paste_in_list(paste_list, paste_url):
2+
3+
paste_was_created = False
4+
for paste in paste_list:
5+
if paste['paste_url'] == paste_url:
6+
return True
7+
8+
return paste_was_created

0 commit comments

Comments
 (0)