Exemple #1
0
def test_validate_input(capfd):
    from CybleEvents import validate_input

    args = {
        'start_date': datetime.today().strftime('%Y-%m-%d'),
        'end_date': datetime.today().strftime('%Y-%m-%d'),
        'from': '-1',
        'limit': '1',
    }
    with capfd.disabled():
        with pytest.raises(
                ValueError,
                match=
                f"Parameter having negative value, from: {args.get('from')}"):
            validate_input(args=args)
Exemple #2
0
def test_limit_validate_input(capfd):
    from CybleEvents import validate_input

    args = {
        'start_date': datetime.today().strftime('%Y/%m/%d'),
        'end_date': datetime.today().strftime('%Y/%m/%d'),
        'from': '0',
        'limit': '-1',
    }
    with capfd.disabled():
        with pytest.raises(
                ValueError,
                match=
                f"Limit should a positive number upto 50, limit: {args.get('limit', '50')}"
        ):
            validate_input(args=args)
Exemple #3
0
def test_edate_validate_input(capfd):
    from CybleEvents import validate_input

    args = {
        'start_date': datetime.today().strftime('%Y/%m/%d'),
        'end_date':
        (datetime.today() + timedelta(days=4)).strftime('%Y/%m/%d'),
        'from': '0',
        'limit': '1'
    }
    with capfd.disabled():
        with pytest.raises(
                ValueError,
                match=
                f"End date must be a date before or equal to {datetime.today().strftime('%Y/%m/%d')}"
        ):
            validate_input(args=args)
Exemple #4
0
def test_datecheck_validate_input(capfd):
    from CybleEvents import validate_input

    args = {
        'start_date': datetime.today().strftime('%Y-%m-%d'),
        'end_date':
        (datetime.today() - timedelta(days=4)).strftime('%Y-%m-%d'),
        'from': '0',
        'limit': '1'
    }

    with capfd.disabled():
        with pytest.raises(
                ValueError,
                match=
                f"Start date {args.get('start_date')} cannot be after end date {args.get('end_date')}"
        ):
            validate_input(args=args, is_iocs=True)