def test__get_truth__empty_inp__fail():
    inp = None
    relate = operator.contains
    val = 'cd'

    with pytest.raises(ValidationError):
        get_truth(inp, relate, val)
    def process_results(self, target):
        if not self.command:
            raise ValidationError('DockerTool: No command given.')
        if not self.test_results:
            raise ValidationError('DockerTool: No {} "{}" found.'.format(
                self.command, target.entity))

        method_name = '_process_{}'.format(self.command)
        m = getattr(self, method_name, None)
        if not m:
            raise ValidationError(
                'There is no method {} in DockerTool.'.format(method_name))
        res = m(entity=target.entity)

        actual = res[0] if isinstance(res, list) else res

        set_breakpoint()

        if not get_truth(actual, all_matchers[target.matcher], target.value):
            raise ValidationError(
                'Expected: {} {} {} "{}", \nActual: {}'.format(
                    '"{}":'.format(target.entity) if target.entity else '',
                    target.property if target.property else target.entity,
                    target.matcher, target.value if target.value else '',
                    actual))
def test__get_truth__contains_not():
    inp = ['a', 'ab', 'abc']
    relate = 'contains_not'
    val = 'def'

    res = get_truth(inp, relate, val)

    assert res
def test__get_truth__contains__special_chars(data):
    relate = operator.contains
    # val = """<h1>I'm 4021fdc268d2</h1>"""
    val = '<h1>I\'m 4021fdc268d2</h1>'

    res = get_truth(unicode(val), relate, unicode(data))

    assert res
def test__get_truth__contains_list():
    val = ['a', 'ab', 'abc']
    relate = operator.contains
    inp = 'abc'

    res = get_truth(val, relate, inp)

    assert res
def test__get_truth__contains_string():
    val = 'abcd efg'
    relate = operator.contains
    inp = 'cd'

    res = get_truth(val, relate, inp)

    assert res
def test__get_truth__is_not_empty__fail(data):
    relate = 'is not empty'

    assert not get_truth(data, relate, None)
def test__get_truth__is_empty__pass(data):
    relate = 'is empty'

    assert get_truth(data, relate, None)