[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Help writing Python test

From: Blair Zajac <blair_at_orcaware.com>
Date: 2002-11-09 02:39:48 CET

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 <blair@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
Received on Sat Nov 9 02:46:37 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.