Mercurial > piecrust2
comparison tests/test_data_assetor.py @ 36:485682a6de50
New site layout support.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 20 Aug 2014 23:16:51 -0700 |
parents | 62c7a97c8340 |
children | 3471ffa059b2 |
comparison
equal
deleted
inserted
replaced
35:e4c345dcf33c | 36:485682a6de50 |
---|---|
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() |
24 page.app.env.base_asset_url_format = '%uri%' | 24 page.app.env.base_asset_url_format = '%uri%' |
25 page.path = fs.path('/kitchen/_content/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) |
29 path = '/foo/bar/%s.txt' % en | 29 path = '/foo/bar/%s.txt' % en |
30 assert getattr(assetor, en) == path | 30 assert getattr(assetor, en) == path |
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() |
40 page.path = fs.path('/kitchen/_content/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 |
45 def test_multiple_assets_with_same_name(): | 45 def test_multiple_assets_with_same_name(): |
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() |
54 page.path = fs.path('/kitchen/_content/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 |
59 @pytest.mark.parametrize('url_format, pretty_urls, uri, expected', [ | 59 @pytest.mark.parametrize('url_format, pretty_urls, uri, expected', [ |