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')))
Esempio n. 2
0
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()
Esempio n. 3
0
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')
Esempio n. 5
0
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')))
Esempio n. 6
0
 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")
Esempio n. 7
0
 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')
Esempio n. 11
0
 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))
Esempio n. 12
0
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')
Esempio n. 14
0
 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")
Esempio n. 15
0
 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'))
Esempio n. 16
0
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')
Esempio n. 17
0
 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()
Esempio n. 18
0
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")
Esempio n. 19
0
 def test_no_params(self):
     args = ["snapshot"]
     with patch.object(sys, "argv", args):
         main()
Esempio n. 20
0
 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"))
Esempio n. 21
0
 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")
Esempio n. 22
0
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')
Esempio n. 23
0
 def test_no_phantomjs(self):
     self.fake_call.side_effect = OSError
     args = ["snapshot", "a", "png"]
     with patch.object(sys, "argv", args):
         main()
Esempio n. 24
0
 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'))
Esempio n. 26
0
 def test_no_params(self):
     args = ['snapshot']
     with patch.object(sys, 'argv', args):
         main()
Esempio n. 27
0
 def test_no_phamtonjs(self):
     self.fake_call.side_effect = OSError
     args = ['snapshot', 'a', 'b']
     with patch.object(sys, 'argv', args):
         main()
Esempio n. 28
0
 def test_help(self):
     args = ['snapshot', 'help']
     with patch.object(sys, 'argv', args):
         main()
Esempio n. 29
0
 def test_help(self):
     args = ["snapshot", "help"]
     with patch.object(sys, "argv", args):
         main()
Esempio n. 30
0
 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")