예제 #1
0
def test_calculate_day_number_iterable():
    """Functional test to ensure the calculate_day_number() method
    runs properly on proper datetime iterables."""
    iterable = [
        pd.to_datetime("January 1, 2020"),
        pd.to_datetime("January 13, 2020"),
    ]
    assert isinstance(calculate_day_number(date=iterable), list)
    assert isinstance(calculate_day_number(date=iterable)[0], int)
예제 #2
0
def test_calculate_day_number_pdseries():
    """Functional test to ensure the calculate_day_number() method
    runs properly on a Pandas series."""
    x = pd.Series(
        pd.date_range("2020-01-01 00:00 -07:00", periods=72, freq="H")
    )
    assert isinstance(calculate_day_number(date=x), pd.Series)
예제 #3
0
def test_invalid_string():
    """Test to ensure calculate_day_number() will throw a
    ValueError with an invalid string input."""
    with pytest.raises(ValueError):
        assert calculate_day_number(date="January 1, blah blah blah")
예제 #4
0
def test_valid_string():
    """Test to ensure calculate_day_number() can handle a typical
    datetime string."""
    assert isinstance(
        calculate_day_number(date="January 1, 2019 12:00 PM"), int
    )
예제 #5
0
def test_known_values():
    """Run a few tests with known answers to ensure
    calculate_day_number() is giving the expected output."""
    assert calculate_day_number(date="January 1, 2020") == 1
    assert calculate_day_number(date="December 31, 2019") == 365
    assert calculate_day_number(date="December 31, 2020") == 366
예제 #6
0
def test_calculate_day_number(value):
    """Functional test to ensure the calculate_day_number() method
    runs properly on proper datetime objects."""
    assert isinstance(calculate_day_number(date=value), int)