Skip to content

Commit 6c26719

Browse files
committed
Add tests
1 parent c94718a commit 6c26719

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

pastebin_python/pastebin.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ def __parsePaste(self, xmlString):
303303

304304
return retList
305305

306-
307306
def __parseXML(self, xml, isPaste=True):
308307
"""This will handle all of the xml string parsing
309308
@@ -324,7 +323,6 @@ def __parseXML(self, xml, isPaste=True):
324323

325324
return retList
326325

327-
328326
def deletePaste(self, api_paste_key):
329327
"""This will delete pastes created by certain users
330328
@@ -354,7 +352,6 @@ def deletePaste(self, api_paste_key):
354352

355353
return False
356354

357-
358355
def getUserInfos(self):
359356
"""You can obtain a users personal info and certain settings by calling this function
360357

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests

tests/__init__.py

Whitespace-only changes.

tests/test_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
ipython

tests/tests_paste_basic.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pastebin_python
2+
import pytest
3+
import os
4+
5+
from pastebin_python import PastebinPython
6+
7+
8+
@pytest.fixture(scope='module')
9+
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+
pbin = PastebinPython(api_dev_key=api_dev_key)
15+
pbin.createAPIUserKey(username, password)
16+
17+
return pbin
18+
19+
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+
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')
32+
33+
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+
39+
assert paste_was_created == True
40+
41+
42+
def test_delete_paste(login_to_pastebin):
43+
paste_text = 'This is teest paste text.'
44+
paste_url = login_to_pastebin.createPaste(api_paste_code=paste_text, api_paste_name='test_paste')
45+
api_paste_key = paste_url[21:]
46+
47+
import ipdb; ipdb.set_trace()
48+
49+
login_to_pastebin.deletePaste(api_paste_key)
50+
51+
pastes = login_to_pastebin.listUserPastes()
52+
paste_was_deleted = True
53+
for paste in pastes:
54+
if paste['paste_url'] == paste_url:
55+
paste_was_deleted = False
56+
57+
assert paste_was_deleted == True

0 commit comments

Comments
 (0)