def test_render(): """Test rendering.""" m = Manifest() m.add(ManifestEntry('script', ['/a.js', '/b.js'])) m.add(ManifestEntry('styles', ['/a.css', '/b.css'])) assert m.script.render() == m['script'].render() == str(m.script) == \ '<script src="/a.js"></script>' \ '<script src="/b.js"></script>' assert m.styles.render() == m['styles'].render() == \ '<link rel="stylesheet" href="/a.css"></link>' \ '<link rel="stylesheet" href="/b.css"></link>'
def test_invalid_ext(): """Test invalid entry ext.""" m = Manifest() m.add(ManifestEntry('script', ['/a.exe'])) pytest.raises(UnsupportedExtensionError, m.script.render)
def test_nonexisting_entry(): """Test non-existing entry.""" m = Manifest() pytest.raises(AttributeError, getattr, m, 'script') pytest.raises(KeyError, m.__getitem__, 'script')
def test_manifest_add_same_name(): """Test add with same name.""" m = Manifest() m.add(ManifestEntry('script', ['/a.js'])) pytest.raises(KeyError, m.add, ManifestEntry('script', ['/b.js']))
def exmanif(): m = Manifest() m.add(ManifestEntry('script', ['/a.js', '/b.js'])) m.add(ManifestEntry('styles', ['/a.css', '/b.css'])) return m