~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_export.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from StringIO import StringIO
22
22
import os
23
23
import stat
24
 
import sys
25
24
import tarfile
26
25
import time
27
26
import zipfile
29
28
 
30
29
from bzrlib import (
31
30
    export,
32
 
    osutils,
33
 
    tests,
34
31
    )
35
32
from bzrlib.tests import (
36
33
    features,
37
34
    TestCaseWithTransport,
38
35
    )
 
36
from bzrlib.tests.matchers import ContainsNoVfsCalls
39
37
 
40
38
 
41
39
class TestExport(TestCaseWithTransport):
194
192
    def test_tbz2_export(self):
195
193
        self.run_tar_export_disk_and_stdout('tbz2', 'bz2')
196
194
 
197
 
    # TODO: test_xz_export, I don't have pylzma working here to test it.
198
 
 
199
195
    def test_zip_export_unicode(self):
200
196
        self.requireFeature(features.UnicodeFilenameFeature)
201
197
        tree = self.make_branch_and_tree('zip')
407
403
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
408
404
        self.check_file_contents('latest/goodbye', 'baz')
409
405
 
 
406
    def test_export_uncommitted(self):
 
407
        """Test --uncommitted option"""
 
408
        self.example_branch()
 
409
        os.chdir('branch')
 
410
        self.build_tree_contents([('goodbye', 'uncommitted data')])
 
411
        self.run_bzr(['export', '--uncommitted', 'latest'])
 
412
        self.check_file_contents('latest/goodbye', 'uncommitted data')
 
413
 
 
414
    def test_export_uncommitted_no_tree(self):
 
415
        """Test --uncommitted option only works with a working tree."""
 
416
        tree = self.example_branch()
 
417
        tree.bzrdir.destroy_workingtree()
 
418
        os.chdir('branch')
 
419
        self.run_bzr_error(
 
420
            ['bzr: ERROR: --uncommitted requires a working tree'],
 
421
            'export --uncommitted latest')
 
422
 
410
423
    def test_zip_export_per_file_timestamps(self):
411
424
        tree = self.example_branch()
412
425
        self.build_tree_contents([('branch/har', 'foo')])
418
431
        zfile = zipfile.ZipFile('test.zip')
419
432
        info = zfile.getinfo("test/har")
420
433
        self.assertEquals(time.localtime(timestamp)[:6], info.date_time)
 
434
 
 
435
 
 
436
class TestSmartServerExport(TestCaseWithTransport):
 
437
 
 
438
    def test_simple_export(self):
 
439
        self.setup_smart_server_with_call_log()
 
440
        t = self.make_branch_and_tree('branch')
 
441
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
442
        t.add("foo")
 
443
        t.commit("message")
 
444
        self.reset_smart_call_log()
 
445
        out, err = self.run_bzr(['export', "foo.tar.gz", self.get_url('branch')])
 
446
        # This figure represent the amount of work to perform this use case. It
 
447
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
448
        # being too low. If rpc_count increases, more network roundtrips have
 
449
        # become necessary for this use case. Please do not adjust this number
 
450
        # upwards without agreement from bzr's network support maintainers.
 
451
        self.assertLength(7, self.hpss_calls)
 
452
        self.assertLength(1, self.hpss_connections)
 
453
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)