You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5KB

  1. import json
  2. from contextlib import contextmanager
  3. from tests import dds, DDS
  4. from tests.fileutil import ensure_dir
  5. import pytest
  6. def load_catalog(dds: DDS, data):
  7. dds.scope.enter_context(ensure_dir(dds.build_dir))
  8. dds.catalog_create()
  9. json_path = dds.build_dir / 'catalog.json'
  10. dds.scope.enter_context(
  11. dds.set_contents(json_path,
  12. json.dumps(data).encode()))
  13. dds.catalog_import(json_path)
  14. def test_get(dds: DDS):
  15. load_catalog(
  16. dds, {
  17. 'version': 2,
  18. 'packages': {
  19. 'neo-sqlite3': {
  20. '0.3.0': {
  21. 'url':
  22. 'git+https://github.com/vector-of-bool/neo-sqlite3.git#0.3.0',
  23. },
  24. },
  25. },
  26. })
  27. dds.catalog_get('neo-sqlite3@0.3.0')
  28. assert (dds.scratch_dir / 'neo-sqlite3@0.3.0').is_dir()
  29. assert (dds.scratch_dir / 'neo-sqlite3@0.3.0/package.jsonc').is_file()
  30. def test_get_http(dds: DDS):
  31. load_catalog(
  32. dds, {
  33. 'version': 2,
  34. 'packages': {
  35. 'cmcstl2': {
  36. '2020.2.24': {
  37. 'url':
  38. 'https://github.com/CaseyCarter/cmcstl2/archive/684a96d527e4dc733897255c0177b784dc280980.tar.gz?dds_lm=cmc/stl2;',
  39. },
  40. },
  41. },
  42. })
  43. dds.catalog_get('cmcstl2@2020.2.24')
  44. assert dds.scratch_dir.joinpath('cmcstl2@2020.2.24/include').is_dir()