-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/pack_and_upload' into 'main'
Fix issues related to component uploads Closes PACMAN-961, PACMAN-958, PACMAN-962, PACMAN-957, and PACMAN-956 See merge request espressif/idf-component-manager!423
- Loading branch information
Showing
14 changed files
with
547 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Test Core commands""" | ||
|
||
import pytest | ||
import vcr | ||
|
||
from idf_component_manager.core import ComponentManager | ||
from idf_component_tools.constants import MANIFEST_FILENAME | ||
from idf_component_tools.errors import FatalError | ||
from idf_component_tools.manager import ManifestManager | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_init_project.yaml') | ||
def test_init_project(mock_registry, tmp_path): | ||
(tmp_path / 'main').mkdir() | ||
(tmp_path / 'components' / 'foo').mkdir(parents=True) | ||
main_manifest_path = tmp_path / 'main' / MANIFEST_FILENAME | ||
foo_manifest_path = tmp_path / 'components' / 'foo' / MANIFEST_FILENAME | ||
|
||
manager = ComponentManager(path=str(tmp_path)) | ||
manager.create_manifest() | ||
manager.create_manifest(component='foo') | ||
|
||
for filepath in [main_manifest_path, foo_manifest_path]: | ||
assert filepath.read_text().startswith('## IDF Component Manager') | ||
|
||
manager.add_dependency('cmp==4.0.3') | ||
manifest_manager = ManifestManager(str(main_manifest_path), 'main') | ||
assert manifest_manager.manifest_tree['dependencies']['espressif/cmp'] == '==4.0.3' | ||
|
||
manager.add_dependency('espressif/cmp==4.0.3', component='foo') | ||
manifest_manager = ManifestManager(str(foo_manifest_path), 'foo') | ||
assert manifest_manager.manifest_tree['dependencies']['espressif/cmp'] == '==4.0.3' | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_init_project_with_path.yaml') | ||
def test_init_project_with_path(mock_registry, tmp_path): | ||
src_path = tmp_path / 'src' | ||
src_path.mkdir(parents=True, exist_ok=True) | ||
src_manifest_path = src_path / MANIFEST_FILENAME | ||
|
||
outside_project_path = tmp_path.parent | ||
outside_project_path_error_match = 'Directory ".*" is not under project directory!' | ||
component_and_path_error_match = 'Cannot determine manifest directory.' | ||
|
||
manager = ComponentManager(path=str(tmp_path)) | ||
manager.create_manifest(path=str(src_path)) | ||
|
||
with pytest.raises(FatalError, match=outside_project_path_error_match): | ||
manager.create_manifest(path=str(outside_project_path)) | ||
|
||
with pytest.raises(FatalError, match=component_and_path_error_match): | ||
manager.create_manifest(component='src', path=str(src_path)) | ||
|
||
manager.add_dependency('espressif/cmp==4.0.3', path=str(src_path)) | ||
manifest_manager = ManifestManager(str(src_manifest_path), 'src') | ||
|
||
assert manifest_manager.manifest_tree['dependencies']['espressif/cmp'] == '==4.0.3' | ||
|
||
with pytest.raises(FatalError, match=outside_project_path_error_match): | ||
manager.create_manifest(path=str(outside_project_path)) | ||
|
||
with pytest.raises(FatalError, match=component_and_path_error_match): | ||
manager.add_dependency('espressif/cmp==4.0.3', component='src', path=str(src_path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import vcr | ||
from pytest import raises | ||
|
||
from idf_component_manager.core import ComponentManager | ||
from idf_component_tools.errors import FatalError | ||
|
||
|
||
def test_create_example_project_path_not_a_directory(tmp_path): | ||
existing_file = tmp_path / 'example' | ||
existing_file.write_text('test') | ||
|
||
manager = ComponentManager(path=str(tmp_path)) | ||
|
||
with raises(FatalError, match='Your target path is not a directory*'): | ||
manager.create_project_from_example('test:example') | ||
|
||
|
||
def test_create_example_project_path_not_empty(tmp_path): | ||
example_dir = tmp_path / 'example' | ||
example_dir.mkdir() | ||
existing_file = example_dir / 'test' | ||
existing_file.write_text('test') | ||
|
||
manager = ComponentManager(path=str(tmp_path)) | ||
|
||
with raises(FatalError, match='To create an example you must*'): | ||
manager.create_project_from_example('test:example') | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_create_example_component_not_exist.yaml') | ||
def test_create_example_component_not_exist(tmp_path): | ||
manager = ComponentManager(path=str(tmp_path)) | ||
with raises(FatalError, match='Component "espressif/test" not found'): | ||
manager.create_project_from_example('test:example') | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_create_example_not_exist.yaml') | ||
def test_create_example_version_not_exist(mock_registry, tmp_path): | ||
manager = ComponentManager(path=str(tmp_path)) | ||
with raises( | ||
FatalError, | ||
match='Version of the component "test/cmp" satisfying the spec "=2.0.0" was not found.', | ||
): | ||
manager.create_project_from_example('test/cmp=2.0.0:example') | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_create_example_not_exist.yaml') | ||
def test_create_example_not_exist(mock_registry, tmp_path): | ||
manager = ComponentManager(path=str(tmp_path)) | ||
with raises( | ||
FatalError, | ||
match='Cannot find example "example" for "test/cmp" version "=1.0.1"', | ||
): | ||
manager.create_project_from_example('test/cmp=1.0.1:example') | ||
|
||
|
||
@vcr.use_cassette('tests/fixtures/vcr_cassettes/test_create_example_success.yaml') | ||
def test_create_example_success(mock_registry, tmp_path): | ||
manager = ComponentManager(path=str(tmp_path)) | ||
manager.create_project_from_example('test/cmp>=1.0.0:sample_project') |
Oops, something went wrong.