Exemplo n.º 1
0
 def test_bundle_all(self):
     """Tests bundling multiple real repositories. This uses an array of URLs that 
        represent smallish repositories that are unlikely to go away."""
     print("\ntest_bundle_all")
     repo_urls = [
         "https://github.com/octocat/Hello-World.git",
         "https://github.com/octocat/git-consortium",
         "https://bitbucket.org/atlassian_tutorial/helloworld.git",
         "https://github.com/Microsoft/api-guidelines",
     ]
     throttler = bundle_repos.Throttler(2.0)
     config = bundle_repos.BundleConfig()
     config.throttler = throttler
     with tests.TemporaryDirectory() as tmpdir:
         bundles_dir = os.path.join(tmpdir, 'repositories')
         os.mkdir(bundles_dir)
         print("bundles dir: {}".format(bundles_dir))
         num_ok = bundle_repos.Bundler(bundles_dir, tmpdir,
                                       config=config).bundle_all(repo_urls)
         self.assertEqual(num_ok, len(repo_urls))
         bundle_files = tests.list_files_recursively(bundles_dir)
         print("bundle files: {}".format(bundle_files))
         self.assertEqual(len(bundle_files), len(repo_urls))
         self.assertBundleVerifies(
             (os.path.join(bundles_dir, 'github.com', 'octocat',
                           'Hello-World.git.bundle')))
         self.assertBundleVerifies(
             (os.path.join(bundles_dir, 'github.com', 'octocat',
                           'git-consortium.bundle')))
         self.assertBundleVerifies(
             (os.path.join(bundles_dir, 'github.com', 'Microsoft',
                           'api-guidelines.bundle')))
         self.assertBundleVerifies(
             (os.path.join(bundles_dir, 'bitbucket.org',
                           'atlassian_tutorial', 'helloworld.git.bundle')))
Exemplo n.º 2
0
 def test_bundle_all_throttling(self):
     repo_urls = [
         "https://github.com/octocat/Hello-World.git",
         "https://localhost/foo/bar.git",
         "https://bitbucket.org/atlassian_tutorial/helloworld.git",
         "https://github.com/Microsoft/api-guidelines",
     ]
     counter = CountingThrottler(0)
     config = bundle_repos.BundleConfig()
     config.throttler = counter
     with tests.TemporaryDirectory() as tmpdir:
         self.make_bundler(tmpdir, config).bundle_all(repo_urls)
     print("counts: {}".format(counter.counts))
     self.assertEqual(counter.counts['github.com'], 2)
     self.assertEqual(counter.counts['bitbucket.org'], 1)
     self.assertEqual(counter.counts['localhost'], 1)
Exemplo n.º 3
0
 def test_bundle_not_required_force(self):
     source_bundle_path = tests.get_data_dir('sample-repo.bundle')
     source_bundle_uri = pathlib.PurePath(source_bundle_path).as_uri()
     original_bundle_path = tests.get_data_dir('sample-repo.bundle')
     with tests.TemporaryDirectory() as tmpdir:
         repo = Repository(source_bundle_uri)
         dest_bundle_path = repo.make_bundle_path(tmpdir)
         os.makedirs(os.path.dirname(dest_bundle_path))
         shutil.copyfile(original_bundle_path, dest_bundle_path)
         original_metadata = os.stat(dest_bundle_path)
         config = bundle_repos.BundleConfig(ignore_rev=True)
         new_bundle_path = bundle_repos.Bundler(tmpdir,
                                                tmpdir,
                                                config=config).bundle(repo)
         self.assertEqual(new_bundle_path, dest_bundle_path)
         new_metadata = os.stat(new_bundle_path)
         self.assertNotEqual(new_metadata, original_metadata,
                             "file metadata should have changed")
Exemplo n.º 4
0
 def test_kwargs_bad_arg(self):
     with self.assertRaises(AttributeError):
         bundle_repos.BundleConfig(foo='bar')
Exemplo n.º 5
0
 def test_kwargs(self):
     c = bundle_repos.BundleConfig(ignore_rev=True)
     self.assertTrue(c.ignore_rev)