Skip to content

Commit

Permalink
Add a functional test for BuildFile.write()
Browse files Browse the repository at this point in the history
  • Loading branch information
abadger committed Aug 2, 2021
1 parent 24f55e2 commit d44438a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/functional/test_dependency_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from packaging.version import Version as PypiVer
from semantic_version import Version as SemVer

import pytest

from antsibull.dependency_files import BuildFile


SIMPLE_TEST_FILE = """_ansible_version: 4
_ansible_base_version: 2.11.0rc1
community.general: >=1.0.0,<2.0.0
community.routeros: >=2.0.0-a2,<3.0.0
"""

SIMPLE_TEST_DEPS = {'community.general': SemVer('1.0.0'),
'community.routeros': SemVer('2.0.0-a2'),
}

@pytest.mark.parametrize('dependencies, file_contents', ((SIMPLE_TEST_DEPS, SIMPLE_TEST_FILE),))
def test_build_file_write(tmpdir, dependencies, file_contents):
filename = tmpdir / 'test.build'
bf = BuildFile(filename)
bf.write(PypiVer('4.0.0'), '2.11.0rc1', dependencies)

with open(filename) as f:
assert f.read() == file_contents

0 comments on commit d44438a

Please sign in to comment.