def test_emulator_rom_launch_options(self, fmt, location, rompath, expected): emu = model.Emulator("Mednafen", location, fmt) r = model.ROM( name = "ROM", path = rompath, console = mock(), ) self.assertEqual(emulators.emulator_rom_launch_options(emu, r), expected)
def DataFixture(data): """Creates a pseudo class out of the parameter dictionary `data`, and populates the object such that calling `object.foo` will return `bar` if the input dictionary has a key/value pair `"foo": "bar"`.""" # Transform keys to remove invalid characters, like ` `. assert all([ all([c.isalnum() or c == '_' for c in key]) for key in data.keys() ]), "All dictionary keys must be valid python variable names" DataPseudoClass = collections.namedtuple('DataPseudoClass', data.keys()) return DataPseudoClass(**data) emulators = DataFixture({ "mednafen": model.Emulator(name='Mednafen', location='/emulators/Mednafen/mednafen', format="%l %r"), }) consoles = DataFixture({ "nes": model.Console(fullname='Nintendo Entertainment System', shortname='NES', extensions='nes', custom_roms_directory='', prefix='[NES]', icon='/consoles/icons/nes.png', images_directory='/consoles/grid/nes/', emulator=emulators.mednafen), "snes": model.Console(fullname='Super Nintendo',
def test_emulator_startdir(self, location, expected): emu = model.Emulator("Mednafen", location, "%l %r") self.assertEqual(emulators.emulator_startdir(emu), expected)
def test_emulator_is_enabled_returns_false_when_location_is_directory(self): d = tempfile.mkdtemp() emu = model.Emulator("Mednafen", d, "%l %r") self.assertFalse(emulators.emulator_is_enabled(emu)) os.rmdir(d)
def test_emulator_is_enabled_returns_true_when_location_is_file(self): (f, path) = tempfile.mkstemp() emu = model.Emulator("Mednafen", path, "%l %r") self.assertTrue(emulators.emulator_is_enabled(emu)) os.remove(path)
def test_emulator_is_enabled_returns_false_when_location_doesnt_exist(self): emu = model.Emulator("Mednafen", "", "%l %r") self.assertFalse(emulators.emulator_is_enabled(emu))
def test_verify_returns_true_when_location_is_file(self): (f, path) = tempfile.mkstemp() emu = model.Emulator("Mednafen", path, "%l %r") self.assertTrue(self.adapter.verify(emu)) os.remove(path)
def test_verify_returns_true_when_location_is_directory(self): d = tempfile.mkdtemp() emu = model.Emulator("Mednafen", d, "%l %r") self.assertTrue(self.adapter.verify(emu)) os.rmdir(d)
def test_verify_returns_true_when_location_doesnt_exist(self): emu = model.Emulator("Mednafen", "/some/random/path/that/doesnt/exist", "%l %r") self.assertTrue(self.adapter.verify(emu))
def test_verify_returns_false_when_location_is_empty_string(self): emu = model.Emulator("Mednafen", "", "%l %r") self.assertFalse(self.adapter.verify(emu))