Exemple #1
0
  def test_determine_most_common_prefix(self):
    options = self.options
    builder = BomBuilder(options, self.scm)
    self.assertIsNone(builder.determine_most_common_prefix())

    prefix = ['http://github.com/one', '/local/source/path/two']

    # Test two vs one in from different repo prefix
    # run the test twice changing the ordering the desired prefix is visible.
    for which in [0, 1]:
      repository = GitRepositorySpec(
          'RepoOne', origin=prefix[0] + '/RepoOne',
          commit_id='RepoOneCommit')
      summary = RepositorySummary('RepoOneCommit', 'RepoOneTag',
                                  '1.2.3', '1.2.2', [])
      source_info = SourceInfo('BuildOne', summary)
      builder.add_repository(repository, source_info)
      self.assertEquals(prefix[0], builder.determine_most_common_prefix())

      repository = GitRepositorySpec(
          'RepoTwo', origin=prefix[which] + '/RepoTwo',
          commit_id='RepoTwoCommit')
      summary = RepositorySummary('RepoTwoCommit', 'RepoTwoTag',
                                  '2.2.3', '2.2.3', [])
      source_info = SourceInfo('BuildTwo', summary)
      builder.add_repository(repository, source_info)

      repository = GitRepositorySpec(
          'RepoThree', origin=prefix[1] + '/RepoThree',
          commit_id='RepoThreeCommit')
      summary = RepositorySummary('RepoThreeCommit', 'RepoThreeTag',
                                  '3.2.0', '2.2.1', [])
      source_info = SourceInfo('BuildThree', summary)
      builder.add_repository(repository, source_info)
      self.assertEquals(prefix[which], builder.determine_most_common_prefix())
  def test_determine_most_common_prefix(self):
    options = self.options
    builder = BomBuilder(options, self.scm, MetricsManager.singleton())
    self.assertIsNone(builder.determine_most_common_prefix())

    prefix = ['http://github.com/one', '/local/source/path/two']

    # Test two vs one in from different repo prefix
    # run the test twice changing the ordering the desired prefix is visible.
    for which in [0, 1]:
      repository = GitRepositorySpec(
          'RepoOne', origin=prefix[0] + '/RepoOne',
          commit_id='RepoOneCommit')
      summary = RepositorySummary('RepoOneCommit', 'RepoOneTag',
                                  '1.2.3', '1.2.2', [])
      source_info = SourceInfo('BuildOne', summary)
      builder.add_repository(repository, source_info)
      self.assertEqual(prefix[0], builder.determine_most_common_prefix())

      repository = GitRepositorySpec(
          'RepoTwo', origin=prefix[which] + '/RepoTwo',
          commit_id='RepoTwoCommit')
      summary = RepositorySummary('RepoTwoCommit', 'RepoTwoTag',
                                  '2.2.3', '2.2.3', [])
      source_info = SourceInfo('BuildTwo', summary)
      builder.add_repository(repository, source_info)

      repository = GitRepositorySpec(
          'RepoThree', origin=prefix[1] + '/RepoThree',
          commit_id='RepoThreeCommit')
      summary = RepositorySummary('RepoThreeCommit', 'RepoThreeTag',
                                  '3.2.0', '2.2.1', [])
      source_info = SourceInfo('BuildThree', summary)
      builder.add_repository(repository, source_info)
      self.assertEqual(prefix[which], builder.determine_most_common_prefix())
Exemple #3
0
    def test_determine_most_common_prefix(self):
        options = self.options
        builder = BomBuilder(options, self.scm, MetricsManager.singleton())
        self.assertIsNone(builder.determine_most_common_prefix())

        prefix = ["http://github.com/one", "/local/source/path/two"]

        # Test two vs one in from different repo prefix
        # run the test twice changing the ordering the desired prefix is visible.
        for which in [0, 1]:
            repository = GitRepositorySpec("RepoOne",
                                           origin=prefix[0] + "/RepoOne",
                                           commit_id="RepoOneCommit")
            summary = RepositorySummary("RepoOneCommit", "RepoOneTag", "1.2.3",
                                        [])
            source_info = SourceInfo("BuildOne", summary)
            builder.add_repository(repository, source_info)
            self.assertEqual(prefix[0], builder.determine_most_common_prefix())

            repository = GitRepositorySpec("RepoTwo",
                                           origin=prefix[which] + "/RepoTwo",
                                           commit_id="RepoTwoCommit")
            summary = RepositorySummary("RepoTwoCommit", "RepoTwoTag", "2.2.3",
                                        [])
            source_info = SourceInfo("BuildTwo", summary)
            builder.add_repository(repository, source_info)

            repository = GitRepositorySpec(
                "RepoThree",
                origin=prefix[1] + "/RepoThree",
                commit_id="RepoThreeCommit",
            )
            summary = RepositorySummary("RepoThreeCommit", "RepoThreeTag",
                                        "3.2.0", [])
            source_info = SourceInfo("BuildThree", summary)
            builder.add_repository(repository, source_info)
            self.assertEqual(prefix[which],
                             builder.determine_most_common_prefix())