def test_jpeg_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = [ 'snapshot', HTML_FILE, 'jpeg'] with patch.object(sys, 'argv', args): main() assert(filecmp.cmp('output.jpeg', get_fixture('sample.jpeg')))
def test_unknown_file_type_at_command_line(fake_popen): fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = [ 'snapshot', os.path.join("tests", "fixtures", "render.html"), 'moonwalk' ] with patch.object(sys, 'argv', args): main()
def test_windows_file_name(fake_popen): fake_popen.side_effect = Exception("Enough test. Abort") args = ['snapshot', "tests\\fixtures\\render.html", 'jpeg', '0.1'] try: with patch.object(sys, 'argv', args): main() except Exception: eq_(fake_popen.call_args[0][0][2], 'tests/fixtures/render.html')
def test_default_delay_value(self): self.fake_popen.side_effect = CustomTestException("Enough test. Abort") args = ['snapshot', HTML_FILE, 'jpeg'] try: with patch.object(sys, 'argv', args): main() except CustomTestException: print(self.fake_popen.call_args) eq_(self.fake_popen.call_args[0][0][4], '1500')
def test_jpeg_at_command_line(fake_popen): fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = [ 'snapshot', os.path.join("tests", "fixtures", "render.html"), 'jpeg' ] with patch.object(sys, 'argv', args): main() assert (filecmp.cmp('output.jpeg', get_fixture('sample.jpeg')))
def test_default_delay_value(self): self.fake_popen.side_effect = CustomTestException("Enough test. Abort") args = ["snapshot", HTML_FILE, "jpeg"] try: with patch.object(sys, "argv", args): main() except CustomTestException: print(self.fake_popen.call_args) eq_(self.fake_popen.call_args[0][0][4], "1500")
def test_delay_option(self): self.fake_popen.side_effect = Exception("Enough test. Abort") sample_delay = 0.1 args = ["snapshot", HTML_FILE, "jpeg", str(sample_delay)] try: with patch.object(sys, "argv", args): main() except Exception: eq_(self.fake_popen.call_args[0][0][4], "100")
def test_default_delay_value(self): self.fake_popen.side_effect = CustomTestException("Enough test. Abort") args = ["snapshot", HTML_FILE, "jpeg"] try: with patch.object(sys, "argv", args): main() except CustomTestException: expected = SNAPSHOT_JS % ("jpeg", 2, 1500) eq_(self.fake_popen.call_args[0][1], expected)
def test_pixel_option(self): self.fake_popen.side_effect = Exception("Enough test. Abort") pixel_ratio = 5 args = ["snapshot", HTML_FILE, "jpeg", "0.1", str(pixel_ratio)] try: with patch.object(sys, "argv", args): main() except Exception: expected = SNAPSHOT_JS % ("jpeg", pixel_ratio, 100) eq_(self.fake_popen.call_args[0][1], expected)
def test_delay_option(self): self.fake_popen.side_effect = Exception("Enough test. Abort") sample_delay = 0.1 args = ['snapshot', HTML_FILE, 'jpeg', str(sample_delay)] try: with patch.object(sys, 'argv', args): main() except Exception: print(self.fake_popen.call_args) eq_(self.fake_popen.call_args[0][0][4], '100')
def test_pixcel_option(self): self.fake_popen.side_effect = Exception("Enough test. Abort") pixel_ratio = 5 args = ["snapshot", HTML_FILE, "jpeg", "0.1", str(pixel_ratio)] try: with patch.object(sys, "argv", args): main() except Exception: print(self.fake_popen.call_args) eq_(self.fake_popen.call_args[0][0][5], str(pixel_ratio))
def test_default_delay_value(fake_popen): fake_popen.side_effect = CustomTestException("Enough test. Abort") args = [ 'snapshot', os.path.join("tests", "fixtures", "render.html"), 'jpeg' ] try: with patch.object(sys, 'argv', args): main() except CustomTestException: eq_(fake_popen.call_args[0][0][4], '500')
def test_windows_file_name(self): self.fake_popen.side_effect = Exception("Enough test. Abort") args = ['snapshot', "tests\\fixtures\\render.html", 'jpeg', '0.1'] try: with patch.object(sys, 'argv', args): main() except Exception: print(self.fake_popen.call_args) assert self.fake_popen.call_args[0][0][2].startswith('file:////') assert self.fake_popen.call_args[0][0][2].endswith( 'tests/fixtures/render.html')
def test_windows_file_name(self): self.fake_popen.side_effect = Exception("Enough test. Abort") args = ["snapshot", "tests\\fixtures\\render.html", "jpeg", "0.1"] try: with patch.object(sys, "argv", args): main() except Exception: print(self.fake_popen.call_args) assert self.fake_popen.call_args[0][0][2].startswith("file:////") assert self.fake_popen.call_args[0][0][2].endswith( "tests/fixtures/render.html")
def test_pdf_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = [ 'snapshot', HTML_FILE, 'pdf'] with patch.object(sys, 'argv', args): main() if PY27: # do binary comaprision assert(filecmp.cmp('output.pdf', get_fixture('sample.pdf'))) else: # otherwise test the file is produced assert(os.path.exists('output.pdf'))
def test_delay_option(fake_popen): fake_popen.side_effect = Exception("Enough test. Abort") sample_delay = 0.1 args = [ 'snapshot', os.path.join("tests", "fixtures", "render.html"), 'jpeg', str(sample_delay) ] try: with patch.object(sys, 'argv', args): main() except Exception: eq_(fake_popen.call_args[0][0][4], '100')
def test_unknown_file_type_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = [ 'snapshot', HTML_FILE, 'moonwalk'] with patch.object(sys, 'argv', args): main()
def test_svg_at_command_line(): args = ["snapshot", SVG_HTML_FILE, "svg"] with patch.object(sys, "argv", args): main() assert os.path.exists("output.svg")
def test_no_params(self): args = ["snapshot"] with patch.object(sys, "argv", args): main()
def test_jpeg_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = ["snapshot", HTML_FILE, "jpeg"] with patch.object(sys, "argv", args): main() assert filecmp.cmp("output.jpeg", get_fixture("sample.jpeg"))
def test_pdf_at_command_line(self): args = ["snapshot", HTML_FILE, "pdf"] with patch.object(sys, "argv", args): main() assert os.path.exists("output.pdf")
def test_svg_at_command_line(): args = [ 'snapshot', SVG_HTML_FILE, 'svg'] with patch.object(sys, 'argv', args): main() assert os.path.exists('output.svg')
def test_no_phantomjs(self): self.fake_call.side_effect = OSError args = ["snapshot", "a", "png"] with patch.object(sys, "argv", args): main()
def test_jpeg_at_command_line(self): args = ["snapshot", HTML_FILE, "jpeg"] with patch.object(sys, "argv", args): main() assert filecmp.cmp("output.jpeg", get_fixture("sample.jpeg"))
def test_pdf_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = ['snapshot', HTML_FILE, 'pdf'] with patch.object(sys, 'argv', args): main() assert (os.path.exists('output.pdf'))
def test_no_params(self): args = ['snapshot'] with patch.object(sys, 'argv', args): main()
def test_no_phamtonjs(self): self.fake_call.side_effect = OSError args = ['snapshot', 'a', 'b'] with patch.object(sys, 'argv', args): main()
def test_help(self): args = ['snapshot', 'help'] with patch.object(sys, 'argv', args): main()
def test_help(self): args = ["snapshot", "help"] with patch.object(sys, "argv", args): main()
def test_pdf_at_command_line(self): self.fake_popen.return_value.stdout = BytesIO(get_base64_image()) args = ["snapshot", HTML_FILE, "pdf"] with patch.object(sys, "argv", args): main() assert os.path.exists("output.pdf")