basic unit testing

This commit is contained in:
richard 2013-05-16 01:07:14 +01:00
parent 58aed39d06
commit 42f7736bbf
2 changed files with 6 additions and 12 deletions

View file

@ -84,7 +84,7 @@ class Mega(object):
data = [data] data = [data]
req = requests.post( req = requests.post(
'{0}://eu.api.{1}/cs'.format(self.schema, self.domain), '{0}://g.api.{1}/cs'.format(self.schema, self.domain),
params=params, params=params,
data=json.dumps(data), data=json.dumps(data),
timeout=self.timeout) timeout=self.timeout)

View file

@ -22,12 +22,11 @@ TEST_FOLDER = 'mega.py_testfolder_{0}'.format(random.random())
def pre_test(): def pre_test():
global FIND_RESP
try:
m.upload(TEST_FILE) m.upload(TEST_FILE)
# cached response to lower API requests for testing
FIND_RESP = m.find(TEST_FILE)
if FIND_RESP:
return True return True
else: except:
raise ValueError('Pre-test functions failed!') raise ValueError('Pre-test functions failed!')
@ -55,13 +54,8 @@ class TestMega(unittest.TestCase):
files = m.get_files() files = m.get_files()
self.assertTrue(isinstance(files, dict)) self.assertTrue(isinstance(files, dict))
def test_find(self):
file = FIND_RESP
if file:
self.assertTrue(isinstance(file, tuple))
def test_get_link(self): def test_get_link(self):
file = FIND_RESP file = m.find(TEST_FILE)
if file: if file:
link = m.get_link(file) link = m.get_link(file)
self.assertTrue(isinstance(link, str)) self.assertTrue(isinstance(link, str))