~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-09 14:43:27 UTC
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: john@arbash-meinel.com-20060809144327-d604af2edf646794
Clean up and write tests for permissions. Now we use fstat which should be cheap, and lets us check the permissions and the file size

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 by 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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
507
507
            ('deleted', 'filetoremove'),
508
508
            ],
509
509
            reporter.calls)
 
510
 
 
511
    def test_commit_removals_respects_filespec(self):
 
512
        """Commit respects the specified_files for removals."""
 
513
        tree = self.make_branch_and_tree('.')
 
514
        self.build_tree(['a', 'b'])
 
515
        tree.add(['a', 'b'])
 
516
        tree.commit('added a, b')
 
517
        tree.remove(['a', 'b'])
 
518
        tree.commit('removed a', specific_files='a')
 
519
        basis = tree.basis_tree().inventory
 
520
        self.assertIs(None, basis.path2id('a'))
 
521
        self.assertFalse(basis.path2id('b') is None)
 
522
 
 
523
    def test_commit_saves_1ms_timestamp(self):
 
524
        """Passing in a timestamp is saved with 1ms resolution"""
 
525
        tree = self.make_branch_and_tree('.')
 
526
        self.build_tree(['a'])
 
527
        tree.add('a')
 
528
        tree.commit('added a', timestamp=1153248633.4186721, timezone=0,
 
529
                    rev_id='a1')
 
530
 
 
531
        rev = tree.branch.repository.get_revision('a1')
 
532
        self.assertEqual(1153248633.419, rev.timestamp)
 
533
 
 
534
    def test_commit_has_1ms_resolution(self):
 
535
        """Allowing commit to generate the timestamp also has 1ms resolution"""
 
536
        tree = self.make_branch_and_tree('.')
 
537
        self.build_tree(['a'])
 
538
        tree.add('a')
 
539
        tree.commit('added a', rev_id='a1')
 
540
 
 
541
        rev = tree.branch.repository.get_revision('a1')
 
542
        timestamp = rev.timestamp
 
543
        timestamp_1ms = round(timestamp, 3)
 
544
        self.assertEqual(timestamp_1ms, timestamp)