Blender ships tests: build refuses a hull type that is not a HullType name; the grid limit is hull_grid's (red)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8bfb06ed64
commit
efeadec265
2 changed files with 28 additions and 0 deletions
|
|
@ -208,6 +208,23 @@ class HullTypeTests(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
hs.build(fixture.runner(), fixture.read_library)
|
||||
|
||||
def test_build_refuses_a_hull_type_that_is_not_a_hulltype_name_before_reading_the_source(self):
|
||||
for hull_type in ("ship", "SHIP", "Ship ", "", None, "Stations", 0, SECRET):
|
||||
with self.subTest(hull_type=hull_type):
|
||||
fixture, read = Fixture(), []
|
||||
runner = fixture.runner()
|
||||
with self.assertRaises(hs.HullSourceError) as caught:
|
||||
hs.build(lambda part: read.append(part) or runner(part), fixture.read_library, hull_type)
|
||||
self.assertEqual(read, [])
|
||||
self.assertNotIn(SECRET, str(caught.exception))
|
||||
|
||||
def test_build_accepts_each_hulltype_name_and_only_a_ship_lists_the_proportion_check(self):
|
||||
for hull_type in ("Ship", "Station", "Turret"):
|
||||
with self.subTest(hull_type):
|
||||
built = self.fixture(hull_type).build()
|
||||
self.assertEqual([c.name for c in built.failed()], [])
|
||||
self.assertEqual(PROPORTION in names(built), hull_type == "Ship")
|
||||
|
||||
|
||||
class MirrorOverlapTests(unittest.TestCase):
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import shutil
|
|||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
|
@ -543,6 +544,16 @@ class LayoutTests(ShipFileCase):
|
|||
revision = self.layout()[2]
|
||||
self.assertNotEqual(before, self.bytes())
|
||||
|
||||
def test_the_grid_limit_is_hull_grids_max_cells(self):
|
||||
_, _, revision = self.layout()
|
||||
before = self.bytes()
|
||||
with self.assertRaisesRegex(ValueError, f"1..{ship_cc.hull_grid.MAX_CELLS} cells"):
|
||||
self.edit(revision, width=33, height=1, cells=[True] * 33)
|
||||
self.assertEqual(before, self.bytes())
|
||||
with mock.patch.object(ship_cc.hull_grid, "MAX_CELLS", 33):
|
||||
self.edit(revision, width=33, height=1, cells=[True] * 33, hardpoints=[])
|
||||
self.assertEqual([33, 1, [True] * 33], self.layout()[0])
|
||||
|
||||
def test_a_layout_save_refreshes_the_stored_at_of_the_hull_and_leaves_the_ships(self):
|
||||
stale = "2000-01-01T00:00:00+00:00"
|
||||
envelopes = self.envelopes()
|
||||
|
|
|
|||
Loading…
Reference in a new issue