~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

transport implementations now tested consistently.

Show diffs side-by-side

added added

removed removed

Lines of Context:
730
730
    def get_bogus_transport(self):
731
731
        from bzrlib.transport.http import HttpTransport
732
732
        return HttpTransport('http://jasldkjsalkdjalksjdkljasd')
733
 
 
734
 
 
735
 
class TestMemoryTransport(TestCase):
736
 
 
737
 
    def test_get_transport(self):
738
 
        memory.MemoryTransport()
739
 
 
740
 
    def test_clone(self):
741
 
        transport = memory.MemoryTransport()
742
 
        self.failUnless(transport.clone() is transport)
743
 
 
744
 
    def test_abspath(self):
745
 
        transport = memory.MemoryTransport()
746
 
        self.assertEqual("in-memory:relpath", transport.abspath('relpath'))
747
 
 
748
 
    def test_relpath(self):
749
 
        transport = memory.MemoryTransport()
750
 
 
751
 
    def test_append_and_get(self):
752
 
        transport = memory.MemoryTransport()
753
 
        transport.append('path', StringIO('content'))
754
 
        self.assertEqual(transport.get('path').read(), 'content')
755
 
        transport.append('path', StringIO('content'))
756
 
        self.assertEqual(transport.get('path').read(), 'contentcontent')
757
 
 
758
 
    def test_put_and_get(self):
759
 
        transport = memory.MemoryTransport()
760
 
        transport.put('path', StringIO('content'))
761
 
        self.assertEqual(transport.get('path').read(), 'content')
762
 
        transport.put('path', StringIO('content'))
763
 
        self.assertEqual(transport.get('path').read(), 'content')
764
 
 
765
 
    def test_append_without_dir_fails(self):
766
 
        transport = memory.MemoryTransport()
767
 
        self.assertRaises(NoSuchFile,
768
 
                          transport.append, 'dir/path', StringIO('content'))
769
 
 
770
 
    def test_put_without_dir_fails(self):
771
 
        transport = memory.MemoryTransport()
772
 
        self.assertRaises(NoSuchFile,
773
 
                          transport.put, 'dir/path', StringIO('content'))
774
 
 
775
 
    def test_get_missing(self):
776
 
        transport = memory.MemoryTransport()
777
 
        self.assertRaises(NoSuchFile, transport.get, 'foo')
778
 
 
779
 
    def test_has_missing(self):
780
 
        transport = memory.MemoryTransport()
781
 
        self.assertEquals(False, transport.has('foo'))
782
 
 
783
 
    def test_has_present(self):
784
 
        transport = memory.MemoryTransport()
785
 
        transport.append('foo', StringIO('content'))
786
 
        self.assertEquals(True, transport.has('foo'))
787
 
 
788
 
    def test_mkdir(self):
789
 
        transport = memory.MemoryTransport()
790
 
        transport.mkdir('dir')
791
 
        transport.append('dir/path', StringIO('content'))
792
 
        self.assertEqual(transport.get('dir/path').read(), 'content')
793
 
 
794
 
    def test_mkdir_missing_parent(self):
795
 
        transport = memory.MemoryTransport()
796
 
        self.assertRaises(NoSuchFile,
797
 
                          transport.mkdir, 'dir/dir')
798
 
 
799
 
    def test_mkdir_twice(self):
800
 
        transport = memory.MemoryTransport()
801
 
        transport.mkdir('dir')
802
 
        self.assertRaises(FileExists, transport.mkdir, 'dir')
803
 
 
804
 
    def test_parameters(self):
805
 
        transport = memory.MemoryTransport()
806
 
        self.assertEqual(True, transport.listable())
807
 
        self.assertEqual(False, transport.should_cache())
808
 
 
809
 
    def test_iter_files_recursive(self):
810
 
        transport = memory.MemoryTransport()
811
 
        transport.mkdir('dir')
812
 
        transport.put('dir/foo', StringIO('content'))
813
 
        transport.put('dir/bar', StringIO('content'))
814
 
        transport.put('bar', StringIO('content'))
815
 
        paths = set(transport.iter_files_recursive())
816
 
        self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
817
 
 
818
 
    def test_stat(self):
819
 
        transport = memory.MemoryTransport()
820
 
        transport.put('foo', StringIO('content'))
821
 
        transport.put('bar', StringIO('phowar'))
822
 
        self.assertEqual(7, transport.stat('foo').st_size)
823
 
        self.assertEqual(6, transport.stat('bar').st_size)
824