Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Nov 5, 2024
1 parent 0b59ee8 commit b088b79
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_core/test_core_buildsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,45 @@ def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRn
]
assert another.lastBuild == buildIDOne
assert another.defaultBuild == buildIDTwo


@pytest.mark.core
def testCoreBuildSettings_Duplicate(monkeypatch, mockGUI, fncPath: Path, mockRnd):
"""Test duplicating builds."""
project = NWProject()
buildTestProject(project, fncPath)
buildsFile = project.storage.getMetaFile(nwFiles.BUILDS_FILE)
assert isinstance(buildsFile, Path)

# No initial builds in a fresh project
builds = BuildCollection(project)
assert len(builds) == 0
assert not buildsFile.exists()
assert builds.lastBuild == ""
assert builds.defaultBuild == ""

# Create a default build
buildOne = BuildSettings()
buildOne.setName("Test Build")
buildOne.setValue("headings.fmtScene", nwHeadFmt.TITLE)
buildOne.setValue("headings.fmtAltScene", nwHeadFmt.TITLE)
buildOne.setValue("headings.fmtSection", nwHeadFmt.TITLE)

# Copy it
buildTwo = BuildSettings().duplicate(buildOne)
assert buildTwo.name == "Test Build 2"

# Raw data
dataOne = buildOne.pack()
dataTwo = buildTwo.pack()

# Name and UUID should be different
assert dataOne["name"] != dataTwo["name"]
assert dataOne["uuid"] != dataTwo["uuid"]

# The rest should be equal
assert dataOne["path"] == dataTwo["path"]
assert dataOne["build"] == dataTwo["build"]
assert dataOne["format"] == dataTwo["format"]
assert dataOne["settings"] == dataTwo["settings"]
assert dataOne["content"] == dataTwo["content"]
9 changes: 9 additions & 0 deletions tests/test_tools/test_tools_manuscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ def _testNewSettingsReady(new: BuildSettings):
assert build.name == "Test Build"
assert manus.buildList.count() == 1

# Copy the build
manus._buildMap[build.buildID].setSelected(True)
manus._copySelectedBuild()
assert manus.buildList.count() == 2

new = manus._getSelectedBuild()
assert new is not None
assert new.name == "Test Build 2"

# Close the dialog should also close the child dialogs
manus.btnClose.click()
if isinstance(bSettings, GuiBuildSettings):
Expand Down

0 comments on commit b088b79

Please sign in to comment.