comparison tests/test_data_assetor.py @ 85:3471ffa059b2

Add a `BakeScheduler` to handle build dependencies. Add unit-tests.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 03 Sep 2014 17:27:50 -0700
parents 485682a6de50
children eb958151c8dc
comparison
equal deleted inserted replaced
84:b3ce11b2cf36 85:3471ffa059b2
18 {'one': 'one', 'two': 'two'}) 18 {'one': 'one', 'two': 'two'})
19 ]) 19 ])
20 def test_assets(fs, expected): 20 def test_assets(fs, expected):
21 with mock_fs_scope(fs): 21 with mock_fs_scope(fs):
22 page = MagicMock() 22 page = MagicMock()
23 page.app = fs.getApp() 23 page.app = fs.getApp(cache=False)
24 page.app.env.base_asset_url_format = '%uri%' 24 page.app.env.base_asset_url_format = '%uri%'
25 page.path = fs.path('/kitchen/pages/foo/bar.md') 25 page.path = fs.path('/kitchen/pages/foo/bar.md')
26 assetor = Assetor(page, '/foo/bar') 26 assetor = Assetor(page, '/foo/bar')
27 for en in expected.keys(): 27 for en in expected.keys():
28 assert hasattr(assetor, en) 28 assert hasattr(assetor, en)
34 def test_missing_asset(): 34 def test_missing_asset():
35 with pytest.raises(KeyError): 35 with pytest.raises(KeyError):
36 fs = mock_fs().withPage('pages/foo/bar') 36 fs = mock_fs().withPage('pages/foo/bar')
37 with mock_fs_scope(fs): 37 with mock_fs_scope(fs):
38 page = MagicMock() 38 page = MagicMock()
39 page.app = fs.getApp() 39 page.app = fs.getApp(cache=False)
40 page.path = fs.path('/kitchen/pages/foo/bar.md') 40 page.path = fs.path('/kitchen/pages/foo/bar.md')
41 assetor = Assetor(page, '/foo/bar') 41 assetor = Assetor(page, '/foo/bar')
42 assetor['this_doesnt_exist'] 42 assetor['this_doesnt_exist']
43 43
44 44
48 .withPage('pages/foo/bar') 48 .withPage('pages/foo/bar')
49 .withPageAsset('pages/foo/bar', 'one.txt', 'one text') 49 .withPageAsset('pages/foo/bar', 'one.txt', 'one text')
50 .withPageAsset('pages/foo/bar', 'one.jpg', 'one picture')) 50 .withPageAsset('pages/foo/bar', 'one.jpg', 'one picture'))
51 with mock_fs_scope(fs): 51 with mock_fs_scope(fs):
52 page = MagicMock() 52 page = MagicMock()
53 page.app = fs.getApp() 53 page.app = fs.getApp(cache=False)
54 page.path = fs.path('/kitchen/pages/foo/bar.md') 54 page.path = fs.path('/kitchen/pages/foo/bar.md')
55 assetor = Assetor(page, '/foo/bar') 55 assetor = Assetor(page, '/foo/bar')
56 assetor['one'] 56 assetor['one']
57 57
58 58