-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_data.py
More file actions
45 lines (33 loc) · 1.35 KB
/
test_data.py
File metadata and controls
45 lines (33 loc) · 1.35 KB
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
from learnpython.app import pages
from .common import TestCase
class TestData(TestCase):
def check_flow(self, name, archive=False):
prefix = 'flows' if not archive else 'archive/{0}'.format(archive)
fullname = '{0}/{1}'.format(prefix, name)
flow = self.check_page(fullname)
self.assertIn('active', flow.meta)
self.assertIn('order', flow.meta)
def check_page(self, mixed):
page = pages.get(mixed) if isinstance(mixed, basestring) else mixed
self.assertIsNotNone(page)
self.assertIn('title', page.meta)
self.assertNotEqual(page.body, '')
self.assertNotEqual(page.html, '')
return page
def test_archive(self):
data = filter(lambda page: page.path.startswith('archive/1'), pages)
self.assertEqual(len(data), 2)
def test_flows(self):
data = filter(lambda page: page.path.startswith('flows/'), pages)
self.assertEqual(len(data), 3)
self.check_flow('async')
self.check_flow('optimization')
self.check_flow('web')
def test_pages(self):
data = filter(lambda page: not '/' in page.path, pages)
self.assertEqual(len(data), 6)
self.check_page('about')
self.check_page('archive')
self.check_page('contacts')
self.check_page('index')
self.check_page('subscribe')