-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
53 lines (47 loc) · 1.52 KB
/
test.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
import unittest
import utils as ren
index = [
{
'in_pth': 'source/how-residual-shortcuts-speed-up-learning/how-residual-shortcuts-speed-up-learning.ipynb',
'type': 'article',
'format': 'ipynb',
'publish': True
},
{
'in_pth': 'https://github.com/a-martyn/pix2pix/',
'type': 'project',
'format': 'url',
'publish': False
},
{
'in_pth': 'source/ml-curriculum/ml-curriculum.md',
'type': 'article',
'format': 'md',
'publish': True
},
{
'in_pth': 'source/ml-learning-log/ml-learning-log.md',
'type': 'article',
'format': 'md',
'publish': True
},
]
class Tests(unittest.TestCase):
def test_filter(self):
self.assertEqual(len(ren.filter('publish', False, index)), 1)
self.assertEqual(len(ren.filter('format', 'md', index)), 2)
def test_add_urls(self):
result = ren.add_urls(index)
self.assertEqual(result[1]['out_pth'],
'https://github.com/a-martyn/pix2pix/')
def test_assets_validate(self):
assets = ren.Assets(index, ['md', 'ipynb'], '')
# Happy path
assets.assets = [('a', 'x/y/a'), ('b', 'z/x/b')]
assets.validate()
# Failure mode: duplicated filename
assets.assets = [('a', 'x/y/a'), ('a', 'z/x/b')]
with self.assertRaises(NameError):
assets.validate()
suite = unittest.TestLoader().loadTestsFromTestCase(Tests)
unittest.TextTestRunner(verbosity=2).run(suite)