Skip to content

Commit

Permalink
Refactor action instantiation in executor.py
Browse files Browse the repository at this point in the history
The code changes refactor the instantiation of actions in the `perform_random_action` method of `executor.py`. Instead of using lambda functions, the actions are now instantiated directly. This improves code readability and maintainability.
  • Loading branch information
drew2a committed Dec 1, 2023
1 parent ebf929d commit 6d55521
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions scripts/application_tester/tribler_apptester/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,18 @@ def get_random_action(self):
action_name = self.weighted_choice(self.probabilities)
self._logger.info("Random action: %s", action_name)
actions = {
'test_exception': TestExceptionAction,
'random_page': RandomPageAction,
'search': RandomSearchAction,
'start_download': lambda: StartRandomDownloadAction(Path(__file__).parent / "data/torrent_links.txt"),
'remove_download': RemoveRandomDownloadAction,
'explore_download': ExploreDownloadAction,
'screenshot': ScreenshotAction,
'start_vod': StartVODAction,
'change_anonymity': lambda: ChangeAnonymityAction(allow_plain=self.allow_plain_downloads),
'change_download_files': ChangeDownloadFilesAction
'test_exception': TestExceptionAction(),
'random_page': RandomPageAction(),
'search': RandomSearchAction(),
'start_download': StartRandomDownloadAction(Path(__file__).parent / "data/torrent_links.txt"),
'remove_download': RemoveRandomDownloadAction(),
'explore_download': ExploreDownloadAction(),
'screenshot': ScreenshotAction(),
'start_vod': StartVODAction(),
'change_anonymity': ChangeAnonymityAction(allow_plain=self.allow_plain_downloads),
'change_download_files': ChangeDownloadFilesAction()
}
return actions.get(action_name, lambda: None)()
return actions.get(action_name)

async def perform_random_action(self):
action = self.get_random_action()
Expand Down

0 comments on commit 6d55521

Please sign in to comment.