-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Comfy-Org/rh-add-tests
Add tests for validating RETURN_TYPES.
- Loading branch information
Showing
10 changed files
with
183 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements-dev.txt | ||
- name: Run tests with pytest | ||
run: | | ||
pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
.coverage | ||
coverage.xml | ||
.pytest_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
name = "node-diff" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
readme = "README.md" | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
"pytest>=8.3.4", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
pythonpath = . | ||
testpaths = tests | ||
python_files = test_*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import pytest | ||
from src.validate_nodes import compare_return_types, BreakingChangeType | ||
|
||
class BaseNode: | ||
RETURN_TYPES = ("STRING", "INT", "FLOAT") | ||
|
||
class PRNode: | ||
RETURN_TYPES = ("STRING", "INT", "FLOAT") | ||
|
||
class ReorderedNode: | ||
RETURN_TYPES = ("INT", "STRING", "FLOAT") | ||
|
||
class IncompatibleNode: | ||
RETURN_TYPES = ("STRING", "BOOL", "FLOAT") | ||
|
||
class AddTypeNode: | ||
RETURN_TYPES = ("STRING", "INT", "FLOAT", "BOOL") | ||
|
||
class RemoveTypeNode: | ||
RETURN_TYPES = ("STRING", "INT") | ||
|
||
class NoReturnTypesNode: | ||
pass | ||
|
||
def test_compare_return_types_no_changes(): | ||
changes = compare_return_types("TestNode", BaseNode, PRNode) | ||
assert len(changes) == 0 | ||
|
||
|
||
def test_compare_return_types_add_type(): | ||
changes = compare_return_types("TestNode", BaseNode, AddTypeNode) | ||
assert len(changes) == 0 | ||
|
||
def test_compare_return_types_remove_type(): | ||
changes = compare_return_types("TestNode", BaseNode, RemoveTypeNode) | ||
assert len(changes) == 1 | ||
assert changes[0].change_type == BreakingChangeType.RETURN_TYPES_CHANGED | ||
assert changes[0].base_value == ("STRING", "INT", "FLOAT") | ||
assert changes[0].pr_value == ("STRING", "INT") | ||
|
||
def test_compare_return_types_reordered(): | ||
changes = compare_return_types("TestNode", BaseNode, ReorderedNode) | ||
assert len(changes) == 1 | ||
assert changes[0].change_type == BreakingChangeType.RETURN_TYPES_CHANGED | ||
assert changes[0].base_value == ("STRING", "INT", "FLOAT") | ||
assert changes[0].pr_value == ("INT", "STRING", "FLOAT") | ||
|
||
def test_compare_return_types_incompatible(): | ||
changes = compare_return_types("TestNode", BaseNode, IncompatibleNode) | ||
assert len(changes) == 1 | ||
assert changes[0].change_type == BreakingChangeType.RETURN_TYPES_CHANGED | ||
assert changes[0].base_value == ("STRING", "INT", "FLOAT") | ||
assert changes[0].pr_value == ("STRING", "BOOL", "FLOAT") | ||
|
||
def test_compare_return_types_missing(): | ||
changes = compare_return_types("TestNode", BaseNode, NoReturnTypesNode) | ||
assert len(changes) == 1 | ||
assert changes[0].change_type == BreakingChangeType.RETURN_TYPES_CHANGED | ||
assert changes[0].base_value == ("STRING", "INT", "FLOAT") | ||
assert changes[0].pr_value == tuple() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.