~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import os
20
20
 
21
21
from bzrlib import tests
 
22
from bzrlib.tests.matchers import ContainsNoVfsCalls
22
23
 
23
24
 
24
25
class TestPack(tests.TestCaseWithTransport):
31
32
        for i in range(total_lines):
32
33
            text += line_prefix + str(i+1) + "\n"
33
34
 
34
 
        open(path, 'w').write(text)
 
35
        with open(path, 'w') as f:
 
36
            f.write(text)
35
37
        if versioned:
36
38
            self.run_bzr(['add', path])
37
39
            self.run_bzr(['ci', '-m', '"' + path + '"'])
68
70
    def test_pack_clean_obsolete_packs(self):
69
71
        """Ensure --clean-obsolete-packs removes obsolete pack files
70
72
        """
71
 
        wd = 'foobar0'
72
 
        wt = self.make_branch_and_tree(wd)
73
 
        transport = wt.branch.repository.bzrdir.transport
74
 
        os.chdir(wd)
 
73
        wt = self.make_branch_and_tree('.')
 
74
        t = wt.branch.repository.bzrdir.transport
75
75
 
76
76
        # do multiple commits to ensure that obsolete packs are created
77
77
        # by 'bzr pack'
81
81
 
82
82
        out, err = self.run_bzr(['pack', '--clean-obsolete-packs'])
83
83
 
84
 
        pack_names = transport.list_dir('repository/obsolete_packs')
 
84
        pack_names = t.list_dir('repository/obsolete_packs')
85
85
        self.assertTrue(len(pack_names) == 0)
 
86
 
 
87
 
 
88
class TestSmartServerPack(tests.TestCaseWithTransport):
 
89
 
 
90
    def test_simple_pack(self):
 
91
        self.setup_smart_server_with_call_log()
 
92
        t = self.make_branch_and_tree('branch')
 
93
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
94
        t.add("foo")
 
95
        t.commit("message")
 
96
        self.reset_smart_call_log()
 
97
        out, err = self.run_bzr(['pack', self.get_url('branch')])
 
98
        # This figure represent the amount of HPSS calls to perform this use
 
99
        # case. It is entirely ok to reduce this number if a test fails due to
 
100
        # rpc_count # being too low. If rpc_count increases, more network
 
101
        # roundtrips have become necessary for this use case. Please do not
 
102
        # adjust this number upwards without agreement from bzr's network
 
103
        # support maintainers.
 
104
        self.assertLength(6, self.hpss_calls)
 
105
        self.assertLength(1, self.hpss_connections)
 
106
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)