Пример #1
0
def test_parse_extracts_description_without_quotes(faker: Faker) -> None:
    """Test description extraction."""
    description = faker.sentence()
    task_arguments = description.split(" ")

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {"description": description}
Пример #2
0
def test_parse_extracts_tags_to_remove(faker: Faker) -> None:
    """Test the parsing of tags to remove."""
    description = faker.sentence()
    tags = [faker.word(), faker.word()]
    task_arguments = [
        description,
        f"-{tags[0]}",
        f"-{tags[1]}",
    ]

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {"description": description}
    assert result.tags_to_remove == tags
Пример #3
0
def test_parse_extracts_integer_properties(faker: Faker, string: str,
                                           attribute: str) -> None:
    """Test parsing of properties that are integers."""
    description = faker.sentence()
    value = faker.random_number()
    task_arguments = [
        description,
        f"{string}:{value}",
    ]

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {
        "description": description,
        attribute: value
    }
Пример #4
0
def test_parse_extracts_due(faker: Faker,
                            freezer: FrozenDateTimeFactory) -> None:
    """Test parsing of due dates."""
    description = faker.sentence()
    freezer.move_to("2017-05-20")
    due = "1d"
    task_arguments = [
        description,
        f"due:{due}",
    ]

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {
        "description": description,
        "due": datetime(2017, 5, 21),
    }
Пример #5
0
def test_parse_extracts_recurring_in_long_representation(
        faker: Faker, string: str, attribute: str,
        recurrence_type: str) -> None:
    """Test parsing of recurrent tasks."""
    description = faker.sentence()
    recurring = faker.word()
    task_arguments = [
        description,
        f"{string}:{recurring}",
    ]

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {
        "description": description,
        "recurrence_type": recurrence_type,
        "recurrence": recurring,
    }
Пример #6
0
def test_parse_return_none_if_argument_is_empty() -> None:
    """Test that the attributes can be set to None.

    One of each type (str, date, float, int) and the description
    empty tags are tested separately.
    """
    task_arguments = [
        "",
        "area:",
        "due:",
        "estimate:",
        "fun:",
    ]

    result = _parse_changes(task_arguments)

    assert result.task_attributes == {
        "description": "",
        "area": None,
        "due": None,
        "estimate": None,
        "fun": None,
    }
Пример #7
0
def test_parse_allows_empty_description() -> None:
    """Test empty description extraction."""
    result = _parse_changes([""])

    assert result.task_attributes == {"description": ""}