-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.test.py
More file actions
58 lines (38 loc) · 2.07 KB
/
Copy pathmodels.test.py
File metadata and controls
58 lines (38 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from mapper import errors, layout, models
class CatalogueTest(unittest.TestCase):
def test_the_package_names_every_layout_it_covers(self) -> None:
for name in (layout.LOROM, layout.HIROM, layout.EXHIROM):
self.assertIn(name, models.MODELS)
def test_a_layout_says_what_it_is_and_where_its_header_sits(self) -> None:
found = models.layout_named(layout.LOROM)
self.assertTrue(found.summary)
self.assertEqual(found.header_at, 0x7FC0)
def test_a_layout_name_is_matched_however_it_is_written(self) -> None:
for written in ("LOROM", "lo", "mode20", "LO_ROM"):
self.assertEqual(models.layout_named(written).name, layout.LOROM)
def test_a_layout_the_package_does_not_have_is_refused_by_name(self) -> None:
with self.assertRaises(errors.UnknownModelError):
models.layout_named("sa1")
def test_the_refusal_lists_what_is_available(self) -> None:
with self.assertRaises(errors.UnknownModelError) as raised:
models.layout_named("nonsense")
self.assertIn("lorom", str(raised.exception))
def test_a_layout_prints_as_its_name_and_header(self) -> None:
printed = repr(models.layout_named(layout.HIROM))
self.assertIn("hirom", printed)
self.assertIn("ffc0", printed)
class ResolveTest(unittest.TestCase):
def test_a_layout_resolves_an_address_the_way_the_space_does(self) -> None:
found = models.layout_named(layout.LOROM).resolve(0x008000)
self.assertEqual(found.region, layout.ROM)
def test_a_layout_carries_the_speed_it_was_asked_about(self) -> None:
found = models.layout_named(layout.LOROM).resolve(0x808000, fast=True)
self.assertEqual(found.cycles, layout.FAST)
def test_the_high_layout_reaches_cartridge_where_the_low_one_does_not(self) -> None:
self.assertEqual(models.layout_named(layout.HIROM).resolve(0xC00000).region, layout.ROM)
if __name__ == "__main__":
unittest.main()