def test_submit_create_binary_existing(in_process, git_repo_path, init_sha, data_file):
    call_conduit.reset_mock()
    call_conduit.side_effect = (dict(), dict(data=[dict(phid='PHID-REPO-1', fields=dict(vcs='git'))]), dict(dict(filePHID='PHID-FILE-1', upload=False)), dict(dict(phid='PHID-DIFF-1', diffid='1')), dict(), dict(object=dict(id='123')), dict())
    shutil.copyfile(str(data_file), str((git_repo_path / 'img.png')))
    git_out('add', '.')
    git_out('commit', '-m', 'IMG')
    mozphab.main(['submit', '--yes', '--bug', '1', init_sha], is_development=True)
    log = git_out('log', '--format=%s%n%n%b', '-1')
    expected = '\nBug 1 - IMG\n\nDifferential Revision: http://example.test/D123\n'
    assert (log.strip() == expected.strip())
    assert (mock.call('file.allocate', {'name': 'img.png', 'contentHash': mock.ANY, 'contentLength': 182}) in call_conduit.call_args_list)
    assert (mock.call('file.upload', mock.ANY) not in call_conduit.call_args_list)
def test_submit_create_binary_existing(in_process, git_repo_path, init_sha, data_file):
    call_conduit.reset_mock()
    call_conduit.side_effect = (dict(), dict(data=[dict(phid='PHID-REPO-1', fields=dict(vcs='git'))]), dict(dict(filePHID='PHID-FILE-1', upload=False)), dict(dict(phid='PHID-DIFF-1', diffid='1')), dict(), dict(object=dict(id='123')), dict())
    shutil.copyfile(str(data_file), str((git_repo_path / 'img.png')))
    git_out('add', '.')
    git_out('commit', '-m', 'IMG')
    mozphab.main(['submit', '--yes', '--bug', '1', init_sha], is_development=True)
    log = git_out('log', '--format=%s%n%n%b', '-1')
    expected = '\nBug 1 - IMG\n\nDifferential Revision: http://example.test/D123\n'
    assert (log.strip() == expected.strip())
    assert (mock.call('file.allocate', {'name': 'img.png', 'contentHash': mock.ANY, 'contentLength': 182}) in call_conduit.call_args_list)
    assert (mock.call('file.upload', mock.ANY) not in call_conduit.call_args_list)