Skip to content
Open
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
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
test:
name: "Python ${{ matrix.python-version }}"
runs-on: sfdc-ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
strategy: # when github action adds 3.12, you can add it here.
matrix: # https://github.com/actions/python-versions/releases
python-version: ["3.8", "3.9", "3.11"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
runs-on: sfdc-ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10"]
python-version: ["3.8", "3.11"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
Expand All @@ -122,7 +122,7 @@ jobs:
runs-on: sfdc-windows-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.8", "3.11"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
Expand All @@ -133,7 +133,11 @@ jobs:
run: |
python -VV
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
make dev-install
# Snowfakery should work both with and without graphviz.
# On Linux we test without it and on Windows we test with it.
# The Unit tests adapt to both situations
choco install graphviz

- name: Run Tests
run: python -m pytest
Expand Down
26 changes: 25 additions & 1 deletion tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ def graphviz_available():


class TestImageOuputStreams:
@mock.patch("subprocess.Popen")
def test_image_outputs_mocked(self, popen):
png = "out.png"
svg = "out.svg"
txt = "out.txt"
dot = "out.dot"
popen.return_value.communicate = lambda: (mock.Mock(), mock.Mock())
generate_cli.main(
[
str(sample_yaml),
"--output-file",
png,
"--output-file",
svg,
"--output-file",
txt,
"--output-file",
dot,
],
standalone_mode=False,
)
for call in popen.mock_calls:
assert call[1][0][0] == "dot"

def test_image_outputs(self):
if not graphviz_available():
pytest.skip("Graphviz is not installed")
Expand All @@ -153,7 +177,7 @@ def test_image_outputs(self):
],
standalone_mode=False,
)
assert png.read_bytes().startswith(b"\x89PNG\r\n")
assert png.read_bytes().startswith(b"\x89PNG"), png.read_bytes()[0:10]
assert svg.read_bytes().startswith(b"<?xml"), svg.read_bytes()[0:5]
assert svg.read_bytes().startswith(b"<?xml"), svg.read_bytes()[0:5]
assert dot.read_bytes().startswith(b"/* Ge"), dot.read_bytes()[0:5]
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ install_command =
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[testenv:lint]
description = Run all pre-commit hooks.
Expand Down