def setup(self): set_cwd(tempfile.mkdtemp()) self.r = SingleFile() self.r.set_options({ "html": True, "pdf": False, })
def test_empty_pdf_windows(): set_cwd(tempfile.mkdtemp()) cuckoo_create( cfg={ "reporting": { "singlefile": { "enabled": True, "html": False, "pdf": True, }, }, }) sf = SingleFile() sf.set_path(cwd(analysis=1)) sf.set_options({ "html": True, "pdf": True, }) sf.set_task({ "id": 1, "target": "1.py", }) with pytest.raises(CuckooReportError) as e: sf.run({}) e.match("weasyprint library hasn't been installed")
class TestSingleFile(object): def setup(self): set_cwd(tempfile.mkdtemp()) self.r = SingleFile() self.r.set_options({ "html": True, "pdf": False, }) def test_combine_images(self): assert len(self.r.combine_images().split("\n")) == 1 def test_combine_screenshots(self): assert len( self.r.combine_screenshots({ "screenshots": [{ "path": "tests/files/sample_analysis_storage/shots/0001.jpg", }], })) == 1 def test_combine_js(self): lines = self.r.combine_js().split("\n") assert "jQuery v2.2.4" in lines[0] assert "Stupid jQuery table plugin" in lines[2] def test_index_fonts(self): assert len(self.r.index_fonts()) == 5
class TestSingleFile(object): def setup(self): set_cwd(tempfile.mkdtemp()) self.r = SingleFile() self.r.set_options({ "html": True, "pdf": False, }) def test_combine_images(self): assert len(self.r.combine_images().split("\n")) == 1 def test_combine_screenshots(self): assert len(self.r.combine_screenshots({ "screenshots": [{ "path": "tests/files/sample_analysis_storage/shots/0001.jpg", }], })) == 1 def test_combine_js(self): lines = self.r.combine_js().split("\n") assert "jQuery v2.2.4" in lines[0] assert "Stupid jQuery table plugin" in lines[2] def test_index_fonts(self): assert len(self.r.index_fonts()) == 5
def test_empty_pdf_windows(): set_cwd(tempfile.mkdtemp()) cuckoo_create(cfg={ "reporting": { "singlefile": { "enabled": True, "html": False, "pdf": True, }, }, }) sf = SingleFile() sf.set_path(cwd(analysis=1)) sf.set_options({ "html": True, "pdf": True, }) sf.set_task({ "id": 1, "target": "1.py", }) with pytest.raises(CuckooReportError) as e: sf.run({}) e.match("weasyprint library hasn't been installed")