Esempio n. 1
0
    def __init__(self,
                 config: Config,
                 db_facade: DBFacade,
                 bot: Bot,
                 gh_interface: GithubInterface,
                 token_config: TokenCommandConfig,
                 metrics: CWMetrics,
                 gcp: Optional[GCPInterface] = None):
        """Initialize the dictionary of command handlers."""
        self.commands: Dict[str, Command] = {}
        self.__facade = db_facade
        self.__bot = bot
        self.__github = gh_interface
        self.__gcp = gcp
        self.__metrics = metrics
        self.commands["user"] = UserCommand(self.__facade,
                                            self.__github,
                                            self.__gcp)
        self.commands["team"] = TeamCommand(config, self.__facade,
                                            self.__github,
                                            self.__bot,
                                            gcp=self.__gcp)
        self.commands["token"] = TokenCommand(self.__facade, token_config)
        self.commands["project"] = ProjectCommand(self.__facade)
        self.commands["karma"] = KarmaCommand(self.__facade)
        self.commands["mention"] = MentionCommand(self.__facade)
        self.commands["i-quit"] = IQuitCommand(self.__facade)

        # Disable project commands (delete when we enable it again)
        del self.commands['project']
Esempio n. 2
0
 def setUp(self):
     """Set up the test case environment."""
     self.app = Flask(__name__)
     self.gh = mock.MagicMock()
     self.db = mock.MagicMock()
     self.sc = mock.MagicMock()
     self.testcommand = TeamCommand(self.db, self.gh, self.sc)
     self.help_text = self.testcommand.help
     self.maxDiff = None
Esempio n. 3
0
 def __init__(self, db_facade: DBFacade, bot: Bot,
              gh_interface: GithubInterface,
              token_config: TokenCommandConfig) -> None:
     """Initialize the dictionary of command handlers."""
     self.__commands: Dict[str, Command] = {}
     self.__facade = db_facade
     self.__bot = bot
     self.__github = gh_interface
     self.__commands["user"] = UserCommand(self.__facade, self.__github)
     self.__commands["team"] = TeamCommand(self.__facade, self.__github,
                                           self.__bot)
     self.__commands["token"] = TokenCommand(self.__facade, token_config)
     self.__commands["project"] = ProjectCommand(self.__facade)
     self.__commands["karma"] = KarmaCommand(self.__facade)
     self.__commands["mention"] = MentionCommand(self.__facade)
Esempio n. 4
0
    def setUp(self):
        self.app = Flask(__name__)
        self.config = mock.MagicMock()
        self.gh = mock.MagicMock()

        self.u0 = User('U123456789')
        self.u1 = User('U234567891')
        self.admin = create_test_admin('Uadmin')
        self.t0 = Team("BRS", "brs", "web")
        self.t1 = Team("OTEAM", "other team", "android")
        self.t2 = Team("LEADS", "leads", "")
        self.t3 = Team("ADMIN", "admin", "")
        self.db = MemoryDB(users=[self.u0, self.u1, self.admin],
                           teams=[self.t0, self.t1, self.t2, self.t3])

        self.sc = mock.MagicMock()
        self.testcommand = TeamCommand(self.config, self.db, self.gh, self.sc)
        self.help_text = self.testcommand.help
        self.maxDiff = None

        self.config.github_team_all = 'all'
        self.config.github_team_leads = 'leads'
        self.config.github_team_admin = 'admin'