'Basic test of porcelain push where self.repo is the remote.  First
clone the remote, commit a file to the clone, then push the changes
back to the remote.'

def test_simple(self):

    outstream = BytesIO()
    errstream = BytesIO()
    porcelain.commit(repo=self.repo.path, message='init', author='', committer='')
    clone_path = tempfile.mkdtemp()
    self.addCleanup(shutil.rmtree, clone_path)
    target_repo = porcelain.clone(self.repo.path, target=clone_path, errstream=errstream)
    try:
        self.assertEqual(target_repo['HEAD'], self.repo['HEAD'])
    finally:
        target_repo.close()
    (handle, fullpath) = tempfile.mkstemp(dir=clone_path)
    os.close(handle)
    porcelain.add(repo=clone_path, paths=[fullpath])
    porcelain.commit(repo=clone_path, message='push', author='', committer='')
    refs_path = 'refs/heads/foo'
    new_id = self.repo['HEAD'].id
    self.assertNotEqual(new_id, ZERO_SHA)
    self.repo.refs[refs_path] = new_id
    porcelain.push(clone_path, self.repo.path, ('HEAD:' + refs_path), outstream=outstream, errstream=errstream)
    with Repo(clone_path) as r_clone:
        self.assertEqual({'HEAD': new_id, 'refs/heads/foo': r_clone['HEAD'].id, 'refs/heads/master': new_id}, self.repo.get_refs())
        self.assertEqual(r_clone['HEAD'].id, self.repo[refs_path].id)
        change = list(tree_changes(self.repo, self.repo['HEAD'].tree, self.repo['refs/heads/foo'].tree))[0]
        self.assertEqual(os.path.basename(fullpath), change.new.path.decode('ascii'))
