-
Notifications
You must be signed in to change notification settings - Fork 41
/
tests.py
51 lines (37 loc) · 1.18 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding=utf-8
import os
import shutil
import tempfile
import unittest
import putiopy
class TestCase(unittest.TestCase):
def setUp(self):
self.client = putiopy.Client('123456')
self.destination = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.destination)
def _download_file(self, name):
f = self.client.File({
'id': 'file',
'name': name,
'size': 0,
'content_type': 'text/plain',
'crc32': '00000000',
})
f.download(self.destination)
def _file_exists(self, name):
filepath = os.path.join(self.destination, name)
return os.path.exists(filepath)
def _test_file_download(self, name):
self._download_file(name)
self.assertTrue(self._file_exists(name))
def test_regular_text(self):
self._test_file_download('Robyn')
def test_unicode_text(self):
self._test_file_download(u'Robyn')
def test_regular_non_ascii(self):
self._test_file_download('Röyksopp')
def test_regular_non_ascii_unicode(self):
self._test_file_download(u'Röyksopp')
if __name__ == '__main__':
unittest.main()