def test_that_nix_build_hasher_is_used(self) -> None:
     hash_sum = self.selector.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=PrefetchOptions(),
     )
     self.assertEqual(hash_sum, "nix build hash")
 def prefetch_repository(
         self,
         revision: Optional[str] = None,
         options: PrefetchOptions = PrefetchOptions(),
 ) -> PrefetchResult:
     return self.prefetcher.prefetch_github(self.repository, revision,
                                            options)
示例#3
0
def get_options_argument_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "--fetch-submodules",
        dest="prefetch_options",
        default=PrefetchOptions(),
        action=set_argument("fetch_submodules", True),
    )
    parser.add_argument(
        "--no-fetch-submodules",
        dest="prefetch_options",
        action=set_argument("fetch_submodules", False),
    )
    parser.add_argument(
        "--leave-dot-git",
        dest="prefetch_options",
        action=set_argument("leave_dot_git", True),
    )
    parser.add_argument(
        "--no-leave-dot-git",
        dest="prefetch_options",
        action=set_argument("leave_dot_git", False),
    )
    parser.add_argument(
        "--deep-clone",
        dest="prefetch_options",
        action=set_argument("deep_clone", True),
    )
    parser.add_argument(
        "--no-deep-clone",
        dest="prefetch_options",
        action=set_argument("deep_clone", False),
    )
    parser.add_argument(
        "--verbose",
        "-v",
        dest="logging_configuration",
        default=LoggingConfiguration(output_file=sys.stderr,
                                     log_level=WARNING),
        action=set_argument("log_level", INFO),
    )
    parser.add_argument(
        "--nix",
        dest="rendering_format",
        default=RenderingFormat.json,
        action="store_const",
        const=RenderingFormat.nix,
    )
    parser.add_argument(
        "--json",
        dest="rendering_format",
        action="store_const",
        const=RenderingFormat.json,
    )
    parser.add_argument("--version",
                        action="version",
                        version="%(prog)s " + VERSION_STRING)
    return parser
 def test_that_nix_build_hasher_is_used_with_deep_clone_and_not_leave_dot_git(
     self, ) -> None:
     hash_sum = self.selector.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=PrefetchOptions(deep_clone=True,
                                          leave_dot_git=False),
     )
     self.assertEqual(hash_sum, "nix build hash")
 def test_with_deep_clone(self) -> None:
     prefetch_options = PrefetchOptions(deep_clone=True)
     hash_sum = self.hasher.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=prefetch_options,
     )
     self.assertEqual(hash_sum,
                      "gBAtCILDbqofa6+9/bXR9drxymCGrgwf0+5mDxwF9p0=")
 def test_with_leaving_dotgit_dir(self) -> None:
     prefetch_options = PrefetchOptions(leave_dot_git=True)
     hash_sum = self.hasher.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=prefetch_options,
     )
     self.assertNotEqual(hash_sum,
                         "B5AlNwg6kbcaqUiQEC6jslCRKVpErXLMsKC+b9aPlrM=")
 def test_with_fetching_submodules(self) -> None:
     prefetch_options = PrefetchOptions(fetch_submodules=True)
     hash_sum = self.hasher.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=prefetch_options,
     )
     self.assertEqual(hash_sum,
                      "wCo1YobyatxSOE85xQNSJw6jvufghFNHlZl4ToQjRHA=")
 def test_without_fetching_submodules(self) -> None:
     prefetch_options = PrefetchOptions(fetch_submodules=False)
     hash_sum = self.hasher.calculate_sha256_sum(
         repository=self.repository,
         revision=self.revision,
         prefetch_options=prefetch_options,
     )
     self.assertEqual(hash_sum,
                      "B5AlNwg6kbcaqUiQEC6jslCRKVpErXLMsKC+b9aPlrM=")
 def _make_repository(self,
                      leave_dot_git: bool = False,
                      deep_clone: bool = False) -> PrefetchedRepository:
     return PrefetchedRepository(
         repository=GithubRepository(owner="test", name="test"),
         rev="test",
         sha256="test",
         options=PrefetchOptions(leave_dot_git=leave_dot_git,
                                 deep_clone=deep_clone),
     )
示例#10
0
 def test_prefetch_sensu_go_5_11(self) -> None:
     self.url_hasher.sha256_sum = "TEST_HASH_SUM"
     self.revision_index_factory.revision_index = RevisionIndexImpl(
         self.sensu_go_ls_remote_output)
     result = self.prefetcher.prefetch_github(
         repository=self.repository,
         rev="5.11.0",
         prefetch_options=PrefetchOptions(),
     )
     assert isinstance(result, PrefetchedRepository)
     assert result.rev == "dd8f160a9033ecb5ad0384baf6a9965fa7bd3c17"
     assert result.sha256 == "TEST_HASH_SUM"
 def setUp(self) -> None:
     self.result_output = StringIO()
     self.error_output = StringIO()
     self.renderer = TestingRepositoryRenderer()
     self.presenter = PresenterImpl(
         result_output=self.result_output,
         error_output=self.error_output,
         repository_renderer=self.renderer,
     )
     self.repo = PrefetchedRepository(
         GithubRepository(owner="test", name="test"),
         rev="test",
         sha256="test",
         options=PrefetchOptions(),
     )
示例#12
0
 def test_extract_no_fetch_submodules_from_arguments(self) -> None:
     self.controller.process_arguments(
         ["owner", "repo", "--no-fetch-submodules"])
     self.assertPrefetchOptions(PrefetchOptions(fetch_submodules=False))
示例#13
0
 def test_extract_no_leave_dot_git_from_arguments(self) -> None:
     self.controller.process_arguments(
         ["owner", "repo", "--no-leave-dot-git"])
     self.assertPrefetchOptions(PrefetchOptions(leave_dot_git=False))
示例#14
0
 def test_deep_clone_is_false_by_default(self) -> None:
     self.controller.process_arguments(["owner", "repo"])
     self.assertPrefetchOptions(PrefetchOptions(deep_clone=False))
示例#15
0
 def test_extract_non_deep_clone_request_from_arguments(self) -> None:
     self.controller.process_arguments(["owner", "repo", "--no-deep-clone"])
     self.assertPrefetchOptions(PrefetchOptions(deep_clone=False))
 def is_default_prefetch_options(self, options: PrefetchOptions) -> bool:
     return options == PrefetchOptions()