You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Blair Zajac <bl...@orcaware.com> on 2002/11/09 01:39:48 UTC
Help writing Python test
I could use some help in finishing this simple test. I'm stuck in
setting up the expected_* variables properly. I'm not a Python
expert by no means and am not familiar with our test suite.
This test should verify that new_file2.bin's svn:mime-type is set
to 'application/octet-stream' instead of 'image/fake_image', which
is a bug for now, but can easily be changed later on.
Thanks,
Blair
#----------------------------------------------------------------------
# Issue #976. Copying a file deemed to be binary, i.e. svn would add
# an svn:mime-type of application/octet-stream if the file were added,
# will upon a copy have its svm:mime-type reset to application/octet-stream.
def cp_binary_file_shouldnt_reset_mime_type(sbox):
"copying a binary file should not reset svn:mime-type"
# Bootstrap
if sbox.build():
return 1
wc_dir = sbox.wc_dir
orig_mime_type = 'image/fake_image'
# Create two paths
new_path1 = os.path.join(wc_dir, 'new_file1.bin')
new_path2 = os.path.join(wc_dir, 'new_file2.bin')
# Create the first path as a binary file
svntest.main.file_append(new_path1, "binary file\000\001\002\003")
svntest.main.run_svn(None, 'add', new_path1)
# Add initial svn:mime-type to the file
svntest.main.run_svn(None, 'propset', 'svn:mime-type', orig_mime_type,
new_path1)
# Commit the file
svntest.main.run_svn(None, 'ci', '-m', 'create file and set svn:mime-type',
wc_dir)
# Copy the file
svntest.main.run_svn(None, 'cp', new_path1, new_path2)
# Create expected output tree
expected_output = svntest.wc.State(wc_dir, {
'new_file2.bin' : Item(verb='Adding (bin)'),
})
# Create expected disk tree
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({'new_file2.bin' : Item()})
# expected_disk.tweak('new_file2.bin',
# props={'svn:mime-type' : orig_mime_type})
# Create expected status tree
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak(repos_rev=3)
expected_status.add({'new_file2.bin' : Item(wc_rev=5, status=' ')})
# Commit the copy
return svntest.main.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_disk,
expected_status,
None, None,
None, None,
wc_dir)
Best,
Blair
--
Blair Zajac <bl...@orcaware.com>
Web and OS performance plots - http://www.orcaware.com/orca/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Help writing Python test
Posted by Branko Čibej <br...@xbc.nu>.
Blair Zajac wrote:
>I could use some help in finishing this simple test. I'm stuck in
>setting up the expected_* variables properly. I'm not a Python
>expert by no means and am not familiar with our test suite.
>
>This test should verify that new_file2.bin's svn:mime-type is set
>to 'application/octet-stream' instead of 'image/fake_image', which
>is a bug for now, but can easily be changed later on.
>
Just don't forget to mark the test with XFail, if it tickles a known bug.
[snip]
> expected_disk.add({'new_file2.bin' : Item()})
># expected_disk.tweak('new_file2.bin',
># props={'svn:mime-type' : orig_mime_type})
>
expected_disk.add({'new_file2.bin' :
Item(props={'svn:mime-type' : orig_mime_type})})
That should do it.
--
Brane Čibej <br...@xbc.nu> http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org