Skip to content

Commit

Permalink
add tests for the new conditions, use the coverage-based tests in cI
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Jul 1, 2024
1 parent 52d87e1 commit 5d4aada
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
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

0 comments on commit 5d4aada

Please sign in to comment.