~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2006-03-10 06:29:53 UTC
  • mfrom: (1608 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060310062953-bc1c7ade75c89a7a
[merge] bzr.dev; pycurl not updated for readv yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
            "test_adapted_tests")
235
235
        server1 = "a"
236
236
        server2 = "b"
237
 
        formats = [(str, "C1", "C2"), (str, "D1", "D2")]
 
237
        formats = [(str, "C1", "C2"), (int, "D1", "D2")]
238
238
        adapter = InterRepositoryTestProviderAdapter(server1, server2, formats)
239
239
        suite = adapter.adapt(input_test)
240
240
        tests = list(iter(suite))
244
244
        self.assertEqual(tests[0].repository_format_to, formats[0][2])
245
245
        self.assertEqual(tests[0].transport_server, server1)
246
246
        self.assertEqual(tests[0].transport_readonly_server, server2)
247
 
        self.assertEqual(tests[0].interrepo_class, formats[1][0])
 
247
        self.assertEqual(tests[1].interrepo_class, formats[1][0])
248
248
        self.assertEqual(tests[1].repository_format, formats[1][1])
249
249
        self.assertEqual(tests[1].repository_format_to, formats[1][2])
250
250
        self.assertEqual(tests[1].transport_server, server1)
251
251
        self.assertEqual(tests[1].transport_readonly_server, server2)
252
252
 
253
253
 
 
254
class TestInterVersionedFileProviderAdapter(TestCase):
 
255
    """A group of tests that test the InterVersionedFile test adapter."""
 
256
 
 
257
    def test_adapted_tests(self):
 
258
        # check that constructor parameters are passed through to the adapted
 
259
        # test.
 
260
        from bzrlib.versionedfile import InterVersionedFileTestProviderAdapter
 
261
        input_test = TestInterRepositoryProviderAdapter(
 
262
            "test_adapted_tests")
 
263
        server1 = "a"
 
264
        server2 = "b"
 
265
        formats = [(str, "C1", "C2"), (int, "D1", "D2")]
 
266
        adapter = InterVersionedFileTestProviderAdapter(server1, server2, formats)
 
267
        suite = adapter.adapt(input_test)
 
268
        tests = list(iter(suite))
 
269
        self.assertEqual(2, len(tests))
 
270
        self.assertEqual(tests[0].interversionedfile_class, formats[0][0])
 
271
        self.assertEqual(tests[0].versionedfile_factory, formats[0][1])
 
272
        self.assertEqual(tests[0].versionedfile_factory_to, formats[0][2])
 
273
        self.assertEqual(tests[0].transport_server, server1)
 
274
        self.assertEqual(tests[0].transport_readonly_server, server2)
 
275
        self.assertEqual(tests[1].interversionedfile_class, formats[1][0])
 
276
        self.assertEqual(tests[1].versionedfile_factory, formats[1][1])
 
277
        self.assertEqual(tests[1].versionedfile_factory_to, formats[1][2])
 
278
        self.assertEqual(tests[1].transport_server, server1)
 
279
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
280
 
 
281
 
 
282
class TestRevisionStoreProviderAdapter(TestCase):
 
283
    """A group of tests that test the RevisionStore test adapter."""
 
284
 
 
285
    def test_adapted_tests(self):
 
286
        # check that constructor parameters are passed through to the adapted
 
287
        # test.
 
288
        from bzrlib.store.revision import RevisionStoreTestProviderAdapter
 
289
        input_test = TestRevisionStoreProviderAdapter(
 
290
            "test_adapted_tests")
 
291
        # revision stores need a store factory - i.e. RevisionKnit
 
292
        #, a readonly and rw transport 
 
293
        # transport servers:
 
294
        server1 = "a"
 
295
        server2 = "b"
 
296
        store_factories = ["c", "d"]
 
297
        adapter = RevisionStoreTestProviderAdapter(server1, server2, store_factories)
 
298
        suite = adapter.adapt(input_test)
 
299
        tests = list(iter(suite))
 
300
        self.assertEqual(2, len(tests))
 
301
        self.assertEqual(tests[0].store_factory, store_factories[0][0])
 
302
        self.assertEqual(tests[0].transport_server, server1)
 
303
        self.assertEqual(tests[0].transport_readonly_server, server2)
 
304
        self.assertEqual(tests[1].store_factory, store_factories[1][0])
 
305
        self.assertEqual(tests[1].transport_server, server1)
 
306
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
307
 
 
308
 
254
309
class TestWorkingTreeProviderAdapter(TestCase):
255
310
    """A group of tests that test the workingtree implementation test adapter."""
256
311
 
312
367
        self.failUnless(isinstance(t2, HttpTransportBase))
313
368
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
314
369
 
 
370
    def test_is_directory(self):
 
371
        """Test assertIsDirectory assertion"""
 
372
        t = self.get_transport()
 
373
        self.build_tree(['a_dir/', 'a_file'], transport=t)
 
374
        self.assertIsDirectory('a_dir', t)
 
375
        self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)
 
376
        self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)
315
377
 
316
378
class TestChrootedTest(ChrootedTestCase):
317
379