def test_check_engine_settings__multiple_duplicate_nicknames(self):
     with self.assertRaises(ValueError) as error:
         settings_loader.check_engine_settings(
             [
                 create_engine_settings('test1', 'test1'),
                 create_engine_settings('test1', 'test1'),
                 create_engine_settings('test2', 'test2'),
                 create_engine_settings('test3', 'test3'),
                 create_engine_settings('test3', 'test3')
             ])
     self.assertTrue('\'nickname\' not unique [\'test1\', \'test3\']' in str(error.exception))
示例#2
0
def main():
    """Chess opening explorer."""
    settings = load_settings()

    # TODO create a type for settings
    engine_settings = typing.cast(List[Json], settings['engines'])

    settings_loader.check_engine_settings(engine_settings)

    engine_options = load_all_engine_options(settings)
    first_engine_settings = engine_settings[0]

    engine_path = typing.cast(str, first_engine_settings['path'])
    nickname = typing.cast(str, first_engine_settings['nickname'])
    with open_engine_with_options(engine_path, engine_options[nickname]) as uci_engine:
        with db_wrapper.Database() as database:
            opex = OpeningExplorer(database, uci_engine)
            board = chess.Board()
            while True:
                opex.search(board)
 def test_check_engine_settings__second_engine_path_not_set(self):
     with self.assertRaises(ValueError) as error:
         settings_loader.check_engine_settings(
             [create_engine_settings('test', 'test'),
              create_engine_settings('test', '')])
     self.assertTrue('Engine[1] missing value for \'path\'' in str(error.exception))
 def test_check_engine_settings__one_engine_nickname_not_set(self):
     with self.assertRaises(ValueError) as error:
         settings_loader.check_engine_settings([{'nickname': '', 'path': 'test'}])
     self.assertTrue('Engine[0] missing value for \'nickname\'' in str(error.exception))
 def test_check_engine_settings__no_engines(self):
     with self.assertRaises(ValueError) as error:
         settings_loader.check_engine_settings([])
     self.assertTrue('Engine list was empty' in str(error.exception))