# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Full test of the cq_deps module."""

from recipe_engine.config import List
from recipe_engine.recipe_api import Property

DEPS = [
    'pigweed/cq_deps',
    'recipe_engine/properties',
    'recipe_engine/step',
]

PROPERTIES = {
    'revision': Property(kind=str, default=None),
    'statuses': Property(kind=List(str), default=('NEW',)),
}


def RunSteps(api, revision, statuses):
    deps, errors = api.cq_deps.resolve(
        'pigweed', revision or 1, statuses=statuses,
    )

    with api.step.nest('final deps'):
        for dep in deps:
            with api.step.nest(dep.name) as pres:
                pres.step_summary_text = dep.remote
                _ = dep.gerrit_url  # For coverage.

    if errors:
        with api.step.nest('errors'):
            for error in errors:
                with api.step.nest(error.name):
                    pass


def GenTests(api):
    yield (
        api.test('hash')
        + api.properties(revision='b' * 40)
        + api.cq_deps.lookup_cl('b' * 40, 1)
        + api.cq_deps.details('pigweed:1', '')
    )

    yield (
        api.test('cl-not-found')
        + api.properties(revision='b' * 40)
        + api.cq_deps.lookup_cl('b' * 40, found=False)
    )

    yield (
        api.test('one')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.has_deps('pigweed:2')
        + api.cq_deps.lacks_deps('pigweed:1')
    )

    yield (
        api.test('disabled')
        + api.properties(**api.cq_deps.properties(disabled=True))
        + api.cq_deps.assert_disabled()
    )

    yield (
        api.test('ignore_errors')
        + api.properties(**api.cq_deps.properties(ignore_errors=True))
        + api.cq_deps.details('pigweed:1', 'Requires: invalid')
    )

    yield (
        api.test('two')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2, pigweed:3')
        + api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('no_space')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2,pigweed:3')
        + api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('no_gerrit_name')
        + api.cq_deps.details('pigweed:1', 'Requires: 2')
        + api.cq_deps.has_deps('pigweed:2')
    )

    yield (
        api.test('loop_two')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.details('pigweed:2', 'Requires: pigweed:1')
        + api.cq_deps.has_deps('pigweed:2')
    )

    yield (
        api.test('loop_three')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.details('pigweed:2', 'Requires: pigweed:3')
        + api.cq_deps.details('pigweed:3', 'Requires: pigweed:1')
        + api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('abandoned')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.details(
            'pigweed:2', 'Requires: pigweed:3', status='ABANDONED'
        )
        + api.cq_deps.lacks_deps('pigweed:2')
    )

    yield (
        api.test('merged_skipped')
        + api.properties()
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.details(
            'pigweed:2', 'Requires: pigweed:3', status='MERGED'
        )
        + api.cq_deps.lacks_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('merged_ok')
        + api.properties(statuses=('NEW', 'MERGED'))
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.details(
            'pigweed:2', 'Requires: pigweed:3', status='MERGED'
        )
        + api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('bad_field_name')
        + api.cq_deps.details('pigweed:1', 'Depends: pigweed:2')
        + api.cq_deps.lacks_deps('pigweed:2')
    )

    yield (
        api.test('commas')
        + api.cq_deps.details('pigweed:1', 'Requires: ,,pigweed:2,')
        + api.cq_deps.has_deps('pigweed:2')
    )

    yield (
        api.test('error')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.transient('pigweed:2')
        + api.cq_deps.transient('pigweed:2', n=2)
        + api.cq_deps.lacks_deps('forbidden:1')
    )

    yield (
        api.test('error_recovery')
        + api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
        + api.cq_deps.transient('pigweed:2')
        + api.cq_deps.details('pigweed:2', '', n=2)
        + api.cq_deps.has_deps('pigweed:2')
    )

    yield (
        api.test('forbidden')
        + api.cq_deps.details('pigweed:1', 'Requires: forbidden:1')
        + api.cq_deps.forbidden('forbidden:1')
        + api.cq_deps.lacks_deps('forbidden:1')
    )

    yield (
        api.test('multiline')
        + api.cq_deps.details(
            'pigweed:1', 'Requires: pigweed:2\nRequires: pigweed:3'
        )
        + api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
    )

    yield (
        api.test('unsubmitted-parent-dependencies')
        + api.cq_deps.details('pigweed:1', '', parent='PIGWEED2')
        + api.cq_deps.lookup_cl('PIGWEED2', 2)
        + api.cq_deps.details(
            'pigweed:2', 'Requires: pigweed:3', commit_hash='PIGWEED2',
        )
        + api.cq_deps.has_deps('pigweed:3')
    )

    yield (
        api.test('dependency-requires-parent')
        + api.cq_deps.details(
            'pigweed:1', 'Requires: pigweed:3', parent='PIGWEED2',
        )
        + api.cq_deps.lookup_cl('PIGWEED2', 2)
        + api.cq_deps.details('pigweed:3', 'Requires: pigweed:2',)
        + api.cq_deps.lacks_deps('pigweed:2')
        + api.cq_deps.has_deps('pigweed:3')
    )

    yield (
        api.test('out-of-date-parent', status='FAILURE')
        + api.cq_deps.details('pigweed:1', '', parent='OUTOFDATE')
        + api.cq_deps.lookup_cl('OUTOFDATE', 2)
        + api.cq_deps.details('pigweed:2', commit_hash='CURRENT')
    )

    yield (
        api.test('no-parent-cl')
        + api.cq_deps.details('pigweed:1', '', parent='NOCL')
        + api.cq_deps.lookup_cl('NOCL')
    )

    yield (
        api.test('gibberish-requirement', status='FAILURE')
        + api.cq_deps.details('pigweed:1', 'Requires: GIBBERISH')
    )
