def test_git_diff_driver_no_filter_without_flag(git_repo, filespath, capsys): _config_filter_driver('add_helper', capsys) fn1 = pjoin(git_repo, 'diff.ipynb') fn2 = pjoin(filespath, 'src-and-output--1.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', '--no-color', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644' ] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_no_filter.format(fn1, fn2, t1, t2)
def test_git_diff_driver(filespath, capsys, nocolor, needs_git): # Simulate a call from `git diff` to check basic driver functionality fn1 = pjoin(filespath, 'foo--1.ipynb') fn2 = pjoin(filespath, 'foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644' ] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_output.format(fn1, fn2, t1, t2)
def test_git_diff_driver_no_filter_without_flag(git_repo, filespath, capsys, nocolor): _config_filter_driver('add_helper', capsys) fn1 = pjoin(git_repo, 'diff.ipynb') fn2 = pjoin(filespath, 'src-and-output--1.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644'] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_no_filter.format(fn1, fn2, t1, t2)
def test_git_diff_driver_ignore_flags(filespath, capsys, nocolor, needs_git, reset_diff_targets): # Simulate a call from `git diff` to check basic driver functionality fn1 = pjoin(filespath, 'foo--1.ipynb') fn2 = pjoin(filespath, 'foo--2.ipynb') t1 = file_timestamp(fn1) t2 = file_timestamp(fn2) mock_argv = [ '/mock/path/git-nbdiffdriver', 'diff', '-O', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644'] with mock.patch('sys.argv', mock_argv): r = gdd_main() assert r == 0 cap_out = capsys.readouterr()[0] assert cap_out == expected_source_only.format(fn1, fn2, t1, t2)
def test_git_web_diff_driver(filespath, unique_port, reset_log): # Simulate a call from `git diff` to check basic driver functionality fn1 = os.path.join(filespath, 'foo--1.ipynb') fn2 = os.path.join(filespath, 'foo--2.ipynb') loop = ioloop.IOLoop.current() loop.call_later(0, loop.stop) mock_argv = [ 'git-nbdiffdriver', 'webdiff', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644', '--browser=disabled', '--port=%i' % unique_port ] with mock.patch('sys.argv', mock_argv): # This simply checks that the function returns 0, # but assumes that the function is routed to the web # diff entrypoint r = gdd_main() assert r == 0
def test_git_web_diff_driver(filespath, unique_port, reset_log): # Simulate a call from `git diff` to check basic driver functionality fn1 = os.path.join(filespath, 'foo--1.ipynb') fn2 = os.path.join(filespath, 'foo--2.ipynb') loop = ioloop.IOLoop.current() loop.call_later(0, loop.stop) mock_argv = [ 'git-nbdiffdriver', 'webdiff', fn1, fn1, 'invalid_mock_checksum', '100644', fn2, 'invalid_mock_checksum', '100644', '--browser=disabled', '--port=%i' % unique_port] with mock.patch('sys.argv', mock_argv): # This simply checks that the function returns 0, # but assumes that the function is routed to the web # diff entrypoint r = gdd_main() assert r == 0