def test_parse_time_issue(self):
        callback = "/time issue"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/time issue test_issue yesterday"
        command, context = command_parser(callback)
        assert command == "/time"
    def test_parse_liststatus_project(self):
        callback = "/liststatus project"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/liststatus project test_project Done"
        command, context = command_parser(callback)
        assert command == "/liststatus"
    def test_parse_listunresolved_project(self):
        callback = "/listunresolved project"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/listunresolved project test_project"
        command, context = command_parser(callback)
        assert command == "/listunresolved"
    def test_parse_liststatus_user(self):
        callback = "/liststatus user daily"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/liststatus user test_username Done"
        command, context = command_parser(callback)
        assert command == "/liststatus"
    def test_parse_time_project(self):
        callback = "/time project"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/time project test_project 28/Dec/2017"
        command, context = command_parser(callback)
        assert command == "/time"
    def test_parse_listunresolved_user(self):
        callback = "/listunresolved user"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/listunresolved user test_username"
        command, context = command_parser(callback)
        assert command == "/listunresolved"
    def test_parse_time_user(self):
        callback = "/time user"
        with pytest.raises(ContextValidationError):
            command_parser(callback)

        callback = "/time user test_user 24-11-2017 29-11-2017"
        command, context = command_parser(callback)
        assert command == "/time"
Beispiel #8
0
    def handler(self, bot, update, *args, **kwargs):
        self.validate_context(kwargs["args"])
        auth_data = kwargs.get('auth_data')

        cmd_name = " ".join(kwargs["args"])
        if not cmd_name.startswith("/"):
            cmd_name = "/" + cmd_name

        # get user timezone from JIRA
        tz = self.app.jira.get_jira_tz(**kwargs)
        # parse command and options
        m = re.match(command_re, cmd_name)
        if not m:
            raise ScheduleValidationError("Entered value is not correct")

        data = m.groupdict(None)
        command, context = command_parser(data.get("callback"), self.app,
                                          auth_data)
        interval = cron_parser(data.get("type"), data.get("opt") or "")
        # create schedule command
        ScheduleTask.create(update, cmd_name, tz, interval, command, context)
        self.app.send(bot,
                      update,
                      text="Schedule command was created successfully!")
 def test_parse_time_without_context(self):
     callback = "/time"
     with pytest.raises(ContextValidationError):
         command_parser(callback)
 def test_parse_filter_with_context(self):
     callback = "/filter Test Filter"
     command, context = command_parser(callback)
     assert command == "/filter"
 def test_parse_filter_without_context(self):
     command, context = command_parser("/filter")
     assert len(context) == 0
 def test_parse_liststatus_me(self):
     callback = "/liststatus my daily"
     command, context = command_parser(callback)
     assert command == "/liststatus"
 def test_parse_liststatus_without_context(self):
     callback = "/liststatus"
     with pytest.raises(ContextValidationError):
         command_parser(callback)
 def test_parse_listunresolved_me(self):
     callback = "/listunresolved my"
     command, context = command_parser(callback)
     assert command == "/listunresolved"
 def test_parse_failed_command(self):
     with pytest.raises(ScheduleValidationError):
         command_parser("/testfail my")
 def test_parse_not_allowed_command(self, callback):
     with pytest.raises(ScheduleValidationError):
         command_parser(callback)