Esempio n. 1
0
def test_plugin_matrix_invalid():
    assert_that(Matrix.valid({}), equal_to(False))
    assert_that(Matrix.valid(None), equal_to(False))
    assert_that(Matrix.valid(OrderedDict({'a': 'abc'})), equal_to(False))

    initialize()

    stream = StringIO('''
    - name: test1
      matrix:
        tags:
          - m1
    ''')
    document = loader.ordered_load(stream)
    assert_that(TopLevel.valid(document), equal_to(False))

    stream = StringIO('''
    - name: test1
      matrix:
        tags:
          - m1
        tasks:
          - name: test2
            matrix:
              tags:
                - m11
    ''')
    document = loader.ordered_load(stream)
    assert_that(TopLevel.valid(document), equal_to(False))
Esempio n. 2
0
def test_plugin_top_level_invalid():
    assert_that(TopLevel.valid({}), equal_to(False))
    assert_that(TopLevel.valid(None), equal_to(False))
    stream = StringIO('''
    - name: test1
    ''')
    document = loader.ordered_load(stream)
    assert_that(TopLevel.valid(document), equal_to(False))
Esempio n. 3
0
def test_plugin_matrix_runs_with_two_matrices_with_multiple_attempts(caplog):
    stream = StringIO('''
    - name: test1
      matrix:
        tags:
          - m1
          - m2
        tasks:
          - name: test2
            matrix:
              tags:
                - m3
              tasks:
                - name: Testing task
                  echo: Hello world.
                  attempts: 3
    ''')
    document = loader.ordered_load(stream)

    assert_that(TopLevel.valid(document), equal_to(True))

    nodes = TopLevel.build(document)

    context = Context()

    for node in nodes:
        node.execute(context)

    assert_that(caplog.text, contains_string('Hello world.'))
    assert_that(caplog.text, is_not(contains_string('failure')))
Esempio n. 4
0
def test_plugin_matrix_runs_with_two_elements_and_contains_tags(caplog):
    stream = StringIO('''
    - name: test1
      matrix:
        tags:
          - m1
          - m2
        tasks:
          - name: Testing task
            echo: Hello world.
    ''')
    document = loader.ordered_load(stream)

    assert_that(TopLevel.valid(document), equal_to(True))

    nodes = TopLevel.build(document)

    context = Context()

    for node in nodes:
        node.execute(context)

        assert_that(context.variables.last(),
                    not has_entry('matrix_tag', 'm2'))
        assert_that(context.variables.last(),
                    not has_entry('matrix_list', ['m2']))

    assert_that(caplog.text, contains_string('entry: m1'))
    assert_that(caplog.text, contains_string('entry: m2'))
    assert_that(caplog.text, contains_string('Hello world.'))

    assert_that(context.variables.last(), not has_entry('matrix_tag', 'm2'))
    assert_that(context.variables.last(), not has_entry('matrix_list', ['m2']))
Esempio n. 5
0
def test_plugin_shell_invalid():
    assert_that(Shell.valid({}), equal_to(False))
    assert_that(Shell.valid(None), equal_to(False))
    assert_that(Shell.valid(OrderedDict({'a': 'abc'})), equal_to(False))

    initialize()

    stream = StringIO('''
    - name: test1
      shell: False
    ''')
    document = loader.ordered_load(stream)
    assert_that(TopLevel.valid(document), equal_to(False))
Esempio n. 6
0
def test_plugin_continue_invalid():
    assert_that(Continue.valid({}), equal_to(False))
    assert_that(Continue.valid(None), equal_to(False))
    assert_that(Continue.valid(OrderedDict({'a': 'abc'})), equal_to(False))

    initialize()

    stream = StringIO('''
    - name: test1
      continue:
        - i1
        - i2
    ''')
    document = loader.ordered_load(stream)
    assert_that(TopLevel.valid(document), equal_to(False))
Esempio n. 7
0
def test_plugin_matrix_runs_with_two_elements(caplog):
    stream = StringIO('''
    - name: test1
      matrix:
        tags:
          - m1
          - m2
        tasks:
          - name: Testing task
            echo: Hello world.
    ''')
    document = loader.ordered_load(stream)

    assert_that(TopLevel.valid(document), equal_to(True))

    nodes = TopLevel.build(document)

    for node in nodes:
        node.execute(None)

    assert_that(caplog.text, contains_string('entry: m1'))
    assert_that(caplog.text, contains_string('entry: m2'))
    assert_that(caplog.text, contains_string('Hello world.'))
Esempio n. 8
0
def test_plugin_top_level_valid_empty_list():
    assert_that(TopLevel.valid([]), equal_to(True))