您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

73 行
2.5KB

  1. from dds_ci.dds import DDSWrapper
  2. from dds_ci.testing import Project, RepoServer, PackageJSON
  3. from dds_ci.testing.error import expect_error_marker
  4. from dds_ci.testing.http import HTTPRepoServerFactory, RepoServer
  5. import pytest
  6. NEO_SQLITE_PKG_JSON = {
  7. 'packages': {
  8. 'neo-sqlite3': {
  9. '0.3.0': {
  10. 'remote': {
  11. 'git': {
  12. 'url': 'https://github.com/vector-of-bool/neo-sqlite3.git',
  13. 'ref': '0.3.0',
  14. }
  15. }
  16. }
  17. }
  18. }
  19. }
  20. @pytest.fixture(scope='session')
  21. def _test_repo(http_repo_factory: HTTPRepoServerFactory) -> RepoServer:
  22. srv = http_repo_factory('test-pkg-db-repo')
  23. srv.import_json_data(NEO_SQLITE_PKG_JSON)
  24. return srv
  25. def test_pkg_get(_test_repo: RepoServer, tmp_project: Project) -> None:
  26. _test_repo.import_json_data(NEO_SQLITE_PKG_JSON)
  27. tmp_project.dds.repo_add(_test_repo.url)
  28. tmp_project.dds.pkg_get('neo-sqlite3@0.3.0')
  29. assert tmp_project.root.joinpath('neo-sqlite3@0.3.0').is_dir()
  30. assert tmp_project.root.joinpath('neo-sqlite3@0.3.0/package.jsonc').is_file()
  31. def test_pkg_repo(_test_repo: RepoServer, tmp_project: Project) -> None:
  32. dds = tmp_project.dds
  33. dds.repo_add(_test_repo.url)
  34. dds.run(['pkg', 'repo', dds.catalog_path_arg, 'ls'])
  35. def test_pkg_repo_rm(_test_repo: RepoServer, tmp_project: Project) -> None:
  36. _test_repo.import_json_data(NEO_SQLITE_PKG_JSON)
  37. dds = tmp_project.dds
  38. dds.repo_add(_test_repo.url)
  39. # Okay:
  40. tmp_project.dds.pkg_get('neo-sqlite3@0.3.0')
  41. # Remove the repo:
  42. dds.run(['pkg', dds.catalog_path_arg, 'repo', 'ls'])
  43. dds.repo_remove(_test_repo.repo_name)
  44. # Cannot double-remove a repo:
  45. with expect_error_marker('repo-rm-no-such-repo'):
  46. dds.repo_remove(_test_repo.repo_name)
  47. # Now, fails:
  48. with expect_error_marker('pkg-get-no-pkg-id-listing'):
  49. tmp_project.dds.pkg_get('neo-sqlite3@0.3.0')
  50. def test_pkg_search(_test_repo: RepoServer, tmp_project: Project) -> None:
  51. _test_repo.import_json_data(NEO_SQLITE_PKG_JSON)
  52. dds = tmp_project.dds
  53. with expect_error_marker('pkg-search-no-result'):
  54. dds.run(['pkg', dds.catalog_path_arg, 'search'])
  55. dds.repo_add(_test_repo.url)
  56. dds.run(['pkg', dds.catalog_path_arg, 'search'])
  57. dds.run(['pkg', dds.catalog_path_arg, 'search', 'neo-sqlite3'])
  58. dds.run(['pkg', dds.catalog_path_arg, 'search', 'neo-*'])
  59. with expect_error_marker('pkg-search-no-result'):
  60. dds.run(['pkg', dds.catalog_path_arg, 'search', 'nonexistent'])