示例#1
0
 def test_not_equal_if_different_number_of_groups(self):
     manager_1 = SoundManager({"volume": 1, "groups": []})
     manager_2 = SoundManager({
         "volume": 1,
         "groups": [{
             "name": "Group",
             "sounds": []
         }]
     })
     assert manager_1 != manager_2
     assert manager_2 != manager_1
示例#2
0
文件: server.py 项目: Hanyman8/dndj
 def __init__(self, config_path, host, port):
     with open(config_path) as config_file:
         config = yaml.load(config_file, Loader=CustomLoader)
     self.music = MusicManager(config["music"], callback_fn=self.on_music_changes)
     self.sound = SoundManager(config["sound"], callback_fn=self.on_sound_changes)
     self.app = None
     self.host = host
     self.port = port
示例#3
0
 def test_groups_are_created(self, minimal_sound_manager_config):
     sound_group_1_config = {"name": "Some Sound Group 1", "sounds": []}
     sound_group_2_config = {"name": "Some Sound Group 2", "sounds": []}
     minimal_sound_manager_config["groups"] = [
         sound_group_1_config, sound_group_2_config
     ]
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert len(sound_manager.groups) == 2
     assert sound_manager.groups[0] == SoundGroup(sound_group_1_config)
     assert sound_manager.groups[1] == SoundGroup(sound_group_2_config)
示例#4
0
 def test_sort_in_config(self, minimal_sound_manager_config):
     name_starts_with_n_config = {
         "name": "Not First In The Alphabet",
         "sounds": []
     }
     name_starts_with_a_config = {"name": "Alphabet", "sounds": []}
     minimal_sound_manager_config["sort"] = False
     minimal_sound_manager_config["groups"] = [
         name_starts_with_n_config, name_starts_with_a_config
     ]
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert sound_manager.groups[0] == SoundGroup(name_starts_with_n_config)
     assert sound_manager.groups[1] == SoundGroup(name_starts_with_a_config)
示例#5
0
文件: game.py 项目: jkamuda/protomonk
    def __init__(self):
        # Center window on screen
        os.environ['SDL_VIDEO_CENTERED'] = '1'

        pygame.init()

        self.caption = 'NES Mario'

        size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT]
        self.screen = pygame.display.set_mode(size)

        self.game_info = GameInfo()
        self.sound_manager = SoundManager()
示例#6
0
 def test_performs_checks_on_initialization(self, monkeypatch):
     sound_checker_instance_mock = MagicMock()
     sound_checker_mock = MagicMock(
         return_value=sound_checker_instance_mock)
     monkeypatch.setattr("src.sound.sound_manager.SoundChecker",
                         sound_checker_mock)
     manager = SoundManager({
         "volume": 1,
         "directory": "default/dir/",
         "groups": []
     })
     sound_checker_mock.assert_called_once_with(manager.groups,
                                                manager.directory)
     sound_checker_instance_mock.do_all_checks.assert_called_once()
示例#7
0
 def test_not_equal_if_different_attributes(self):
     manager_1 = SoundManager({"volume": 1, "groups": []})
     manager_2 = SoundManager({"volume": 0.5, "groups": []})
     assert manager_1 != manager_2
     assert manager_2 != manager_1
示例#8
0
 def test_equal_if_same_config(self):
     manager_1 = SoundManager({"volume": 1, "groups": []})
     manager_2 = SoundManager({"volume": 1, "groups": []})
     assert manager_1 == manager_2
     assert manager_2 == manager_1
示例#9
0
 def test_sound_groups_use_tuple_instead_of_list(
         self, minimal_sound_manager_config):
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert isinstance(sound_manager.groups, tuple)
示例#10
0
 def test_directory_in_config(self, minimal_sound_manager_config):
     minimal_sound_manager_config["directory"] = "/some/dir/"
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert sound_manager.directory == "/some/dir/"
示例#11
0
 def test_directory_is_none_by_default(self, minimal_sound_manager_config):
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert sound_manager.directory is None
示例#12
0
 def test_minimal_dict_as_config(self, minimal_sound_manager_config):
     sound_manager = SoundManager(minimal_sound_manager_config)
     assert sound_manager.volume == 1
     assert len(sound_manager.groups) == 0
示例#13
0
 def example_sound_manager(self, example_config, monkeypatch):
     with monkeypatch.context() as m:
         m.setattr("src.sound.sound_manager.SoundChecker", MagicMock())
         manager = SoundManager(config=example_config["sound"])
     return manager
示例#14
0
 def test_not_equal_if_different_types(self):
     config = {"volume": 1, "groups": [{"name": "Group", "sounds": []}]}
     manager = SoundManager(config)
     assert config != manager
     assert manager != config
示例#15
0
 def test_minimal_server_configures_sound(self, minimal_server):
     minimal_sound_config = {"volume": 1, "groups": []}
     assert minimal_server.sound == SoundManager(minimal_sound_config)