Esempio n. 1
0
def test_is_data_valid_num_seats_err():
    user_data = {
        'dep_city': 'cph',
        'arr_city': 'VAR',
        'dep_date': '15.07.2019',
        'arr_date': '20.07.2019',
        'num_seats': 25
    }

    with pytest.raises(InvalidData):
        is_data_valid(user_data)
Esempio n. 2
0
def test_is_data_valid_few_args():
    user_data = {
        'dep_city': 'CPH',
        'arr_city': 'VAR',
        'dep_date': None,
        'arr_date': None,
        'num_seats': None
    }

    with pytest.raises(InvalidData):
        is_data_valid(user_data)
Esempio n. 3
0
def test_is_data_valid_many_args():
    user_data = {
        'dep_city': 'CPH',
        'arr_city': 'VAR',
        'dep_date': '15.07.1229',
        'arr_date': '16.07.2019',
        'num_seats': None,
        'something': 24,
        'date': '15.12.2020'
    }

    with pytest.raises(InvalidData):
        is_data_valid(user_data)
Esempio n. 4
0
def test_is_data_valid(file, expected):
    """

    Args:
        file: file name
        expected: true if all values could be case to a float;
        false if strings were present

    Returns: Pass or Fail

    """
    headers = ['time', 'voltage']
    data = pd.read_csv(file, names=headers)
    valid_data = is_data_valid(data)
    switch = True
    for x in valid_data['time']:
        y = float(x)
        if x != y:
            switch = False
    for x in valid_data['voltage']:
        y = float(x)
        if x != y:
            switch = False
    assert expected == switch