Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for new conditions; enforce 100% coverage #258

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: ${{ matrix.project }} - Test
working-directory: ./python/${{ matrix.project }}
run: |
poetry run poe test
poetry run poe test_coverage
2 changes: 1 addition & 1 deletion python/reactivedataflow/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "reactivedataflow"
version = "0.1.8"
version = "0.1.9"
description = "Reactive Dataflow Graphs"
license = "MIT"
authors = ["Chris Trevino <chtrevin@microsoft.com>"]
Expand Down
4 changes: 2 additions & 2 deletions python/reactivedataflow/reactivedataflow/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def array_input_values_are_defined() -> FireCondition:
T = TypeVar("T")


def array_result_non_empty(name: str = default_output) -> EmitCondition:
def array_result_not_empty(name: str = default_output) -> EmitCondition:
"""Create an emit condition to emit when the given array output is non-empty."""

def check_array_results_non_empty(_inputs: VerbInput, outputs: VerbOutput) -> bool:
return (
return bool(
name in outputs.outputs
and outputs.outputs[name]
and isinstance(outputs.outputs[name], list)
Expand Down
29 changes: 29 additions & 0 deletions python/reactivedataflow/tests/unit/test_conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2024 Microsoft Corporation.
"""reactivedataflow Conditions Tests."""

from reactivedataflow import VerbInput, VerbOutput
from reactivedataflow.conditions import (
array_result_not_empty,
output_is_not_none,
)
from reactivedataflow.constants import default_output


def test_array_results_not_empty():
check = array_result_not_empty()
inputs = VerbInput()
outputs = VerbOutput({default_output: []})
assert check(inputs, outputs) is False

outputs = VerbOutput({default_output: [1]})
assert check(inputs, outputs) is True


def test_output_is_not_none():
check = output_is_not_none(default_output)
inputs = VerbInput()
outputs = VerbOutput({default_output: None})
assert check(inputs, outputs) is False

outputs = VerbOutput({default_output: 1})
assert check(inputs, outputs) is True
Loading