This repository has been archived by the owner on Oct 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
59 lines (44 loc) · 1.73 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
52
53
54
55
56
57
58
59
import unittest
import archivertools
import os
class MetadataTest(unittest.TestCase):
def test_run_id_autoincrement(self):
'''
tests if creating a new archiver run correctly autoincrements the run
'''
archiver = archivertools.Archiver('http://example.org', '0000')
archiver2 = archivertools.Archiver('http://example.org', '0000')
self.assertEqual(archiver.run_metadata.run_id,
archiver2.run_metadata.run_id-1)
class URLTest(unittest.TestCase):
def setUp(self):
self.archiver = archivertools.Archiver('http://example.org', '0000')
self.assertIsInstance(self.archiver, archivertools.Archiver)
def test_add_url(self):
self.archiver.addURL('http://example.org/example')
def test_add_duplicate_url(self):
try:
self.archiver.addURL('http://example.org/duplicate')
self.archiver.addURL('http://example.org/duplicate')
except:
raise
class FileTest(unittest.TestCase):
def setUp(self):
self.archiver = archivertools.Archiver('http://example.org', '0000')
self.assertIsInstance(self.archiver, archivertools.Archiver)
def test_add_file(self):
with open('test.txt', 'w') as test_file:
test_file.write('contents of test file\n')
self.archiver.addFile('test.txt')
os.remove('test.txt')
class LoginTest(unittest.TestCase):
def setUp(self):
self.archiver = archivertools.Archiver('http://example.org', '0000')
self.assertIsInstance(self.archiver, archivertools.Archiver)
def test_commit(self):
try:
self.archiver.commit()
except:
raise
if __name__ == '__main__':
unittest.main()