Skip to content
Merged
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
41 changes: 41 additions & 0 deletions tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,47 @@ def test_a_damaged_save_is_kept_aside_and_a_fresh_winter_starts(scripted, tmp_pa
assert game2.state.day == 1


def test_a_damaged_save_that_cannot_be_copied_aside_says_so(scripted, monkeypatch):
from overwinter import game as gameModule

game, ui = scripted(["Create New Save", "Quit"])
game.play()
path = game.saveFileManager.get_save_path("save.json")
with open(path, "w") as f:
f.write('{"version": 1, "day": "seven"}')

def refuse(source, destination):
raise OSError("read-only")

monkeypatch.setattr(gameModule.shutil, "copy2", refuse)
game2, ui2 = scripted(["Load Slot 1", "Quit"])
game2.play()
assert ui2.saw("This save could not be read")
assert ui2.saw("It could not be copied aside.")
assert not ui2.saw("A copy was kept at")
assert not [n for n in os.listdir(os.path.dirname(path)) if "damaged" in n]
assert game2.state.day == 1


def test_a_save_in_a_place_the_game_no_longer_has_resumes_in_the_galley(scripted):
game, ui = scripted(["Create New Save", "Count the store", "Quit"])
game.play()
path = game.saveFileManager.get_save_path("save.json")
with open(path) as f:
data = json.load(f)
data["location"] = "the_old_radio_mast"
with open(path, "w") as f:
json.dump(data, f)

game2, ui2 = scripted(["Load Slot 1", "Quit"])
game2.play()
assert not game2.failedLoad
assert game2.state.location == "galley"
assert game2.state.knows(facts.THE_STORE)
# The first menu after the slot menu is the galley's.
assert "Count the store" in ui2.menus[1][1]


def test_letting_aksel_go_is_an_ending_of_its_own(scripted):
script = list(FULL_RUN)
script[script.index("He's coming with us")] = "Let him go"
Expand Down
10 changes: 10 additions & 0 deletions tests/test_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Galley,
)
from overwinter.scenes.hut import Hut
from overwinter.scenes.office import Office
from overwinter.scenes.shed import Shed
from overwinter.state import (
AKSEL_HUT,
Expand Down Expand Up @@ -203,6 +204,15 @@ def test_the_hut_after_aksel_has_come_in_is_cold_and_has_nobody_to_talk_to():
assert game.ui.saw("Nothing left in it that was not here in 1961.")


def test_opening_the_station_log_and_closing_it_unread_costs_nothing():
game, office = scene(Office, ["Read the station log", "Close the log"], "office")
assert office.run() == "office"
assert "Close the log" in game.ui.menus[-1][1]
assert game.state.facts == []
assert game.state.watch == MORNING
assert game.state.day == 1


def test_the_epilogue_rereads_the_last_page_and_opens_the_journal_for_free():
game, epilogue = scene(
Epilogue,
Expand Down
Loading