示例#1
0
def test_is_valid_image_positive(monkeypatch):
    """
    Given
        - An integration is with a valid non default image

    When
        - Validating this integration

    Then
        - Ensure integration is considered valid
    """
    integration_path = os.path.normpath(
        os.path.join(f'{git_path()}/demisto_sdk/tests', 'test_files',
                     'not_default_image_integration-Zoom.yml'))
    structure = mock_structure(file_path=integration_path)
    monkeypatch.setattr(
        'demisto_sdk.commands.common.hook_validations.image.INTEGRATION_REGXES',
        [integration_path])
    # Adding monkey patching this will make image validator behave like this is an integration outside of
    # pack context and ignore the image that's in the same folder as the file
    monkeypatch.setattr(
        'demisto_sdk.commands.common.hook_validations.image.INTEGRATION_REGEX',
        integration_path)
    validator = IntegrationValidator(structure)
    assert validator.is_valid_image() is True
示例#2
0
def test_image_when_invalid_type(monkeypatch):
    """
    Given
        - An integration that has an invalid image

    When
        - Validating this integration

    Then
        - Ensure integration is considered non-valid.
    """
    integration_path = os.path.normpath(
        os.path.join(f'{git_path()}/demisto_sdk/tests', 'test_files',
                     'not_default_image_integration-Zoom.yml'))
    structure = mock_structure(file_path=integration_path)
    validator = IntegrationValidator(structure)
    assert validator.is_valid_image() is False
示例#3
0
def test_image_in_both_yml_and_directory(monkeypatch):
    """
    Given
        - An integration that has image in both yml file and in the yml directory

    When
        - Validating this integration

    Then
        - Ensure integration is considered non-valid
    """
    integration_path = os.path.normpath(
        os.path.join(f'{git_path()}/demisto_sdk/tests', 'test_files',
                     'not_default_image_integration-Zoom.yml'))
    structure = mock_structure(file_path=integration_path)
    validator = IntegrationValidator(structure)
    assert validator.is_valid_image() is False
示例#4
0
def test_no_image_integration(monkeypatch):
    """
    Given
        - A new integration yml that does not have an image in its pack

    When
        - Validating this integration

    Then
        - Ensure integration is considered non-valid.
    """
    integration_path = os.path.normpath(
        os.path.join(f'{git_path()}/demisto_sdk/tests', 'test_files',
                     'DummyPack', 'Integrations',
                     'integration-DummyIntegration.yml'))
    structure = mock_structure(file_path=integration_path)
    validator = IntegrationValidator(structure)
    assert validator.is_valid_image() is False