Example #1
0
 def test_extract_statuses_one(self):
     raw_html = """dewqwdqw eldqkwkwjd
     delwqdew q
     <input type="radio" stuff name="action" value="my_action" />
     dewklqjd lewkdjqwe dlkjhew
     """
     self.assertEquals(text.extract_statuses(raw_html), ["my_action"])
Example #2
0
 def test_extract_statuses_one(self):
     raw_html = """dewqwdqw eldqkwkwjd
     delwqdew q
     <input type="radio" stuff name="action" value="my_action" />
     dewklqjd lewkdjqwe dlkjhew
     """
     self.assertEquals(text.extract_statuses(raw_html), ["my_action"])
Example #3
0
 def test_extract_statuses_multiple(self):
     raw_html = """dewqwdqw eldqkwkwjd
     delwqdew q
     <input type="radio" stuff name="action" value="my_action" />
     <input type="radio" stuff name="action" value="something" />
     <input type="radio" stuff name="action" value="else" />
     dewklqjd lewkdjqwe dlkjhew
     """
     self.assertEquals(text.extract_statuses(raw_html), [
         "my_action",
         "something",
         "else",
     ])
Example #4
0
 def test_extract_statuses_multiple(self):
     raw_html = """dewqwdqw eldqkwkwjd
     delwqdew q
     <input type="radio" stuff name="action" value="my_action" />
     <input type="radio" stuff name="action" value="something" />
     <input type="radio" stuff name="action" value="else" />
     dewklqjd lewkdjqwe dlkjhew
     """
     self.assertEquals(text.extract_statuses(raw_html), [
         "my_action",
         "something",
         "else",
     ])
Example #5
0
    def run_status(self, ticket_id, status=None):
        """Updates the status of a ticket.

        usage: cm status ticket_id [new_status]

        """
        ticket_id = text.validate_id(ticket_id)

        self.login()

        # Get all the available actions for this ticket
        r = self.get("/ticket/{}".format(ticket_id))
        timestamps = self._extract_timestamps(r.text)
        statuses = text.extract_statuses(r.text)

        # A ``status`` was provided, try to find the exact match, else just
        # display the current status for this ticket, and the available ones.
        if status:
            status = text.fuzzy_find(status, statuses)

            if not status:
                raise exceptions.FatalError("bad status (for this ticket: {})"
                                            .format(", ".join(statuses)))
        else:
            status = text.extract_status_from_ticket_page(r.text)
            print("Current status: {}".format(status))
            print("Available statuses: {}".format(", ".join(statuses)))
            return

        if self.message:
            comment = self.message
        elif self.add_comment:
            comment = self._read_comment()
        else:
            comment = ""

        data = {
            "action": status,
            "comment": comment,
        }
        data.update(timestamps)

        r = self.post("/ticket/{}".format(ticket_id), data)

        if "system-message" in r.text or r.status_code != 200:
            raise exceptions.FatalError("unable to set status")
Example #6
0
    def run_status(self, ticket_id, status=None):
        """Updates the status of a ticket.

        usage: cm status ticket_id [new_status]

        """
        output = []
        ticket_id = text.validate_id(ticket_id)

        self.login()

        # Get all the available actions for this ticket
        r = self.get("/ticket/{}".format(ticket_id))
        statuses = text.extract_statuses(r.text)

        # Just display current status.
        if not status:
            status = self.extract_status_from_ticket_page(r.text)
            output.append("Current status: {}".format(status))
            if statuses:
                output.append("Available statuses: {}"
                              .format(", ".join(statuses)))
            return output

        if not status:
            raise exceptions.FatalError("bad status (acceptable: {})"
                                        .format(", ".join(statuses)))

        if self.message:
            comment = self.message
        elif self.add_comment:
            comment = self._read_comment()
        else:
            comment = ""

        # Not having a value for submit causes Trac to ignore the request.
        data = {
            "action": status,
            "comment": comment,
            "submit": "anything",
        }
        data.update(self._extract_timestamps(r.text))

        r = self.post("/ticket/{}".format(ticket_id), data)
Example #7
0
    def run_status(self, ticket_id, status=None):
        """Updates the status of a ticket.

        usage: cm status ticket_id [new_status]

        """
        output = []
        ticket_id = text.validate_id(ticket_id)

        self.login()

        # Get all the available actions for this ticket
        r = self.get("/ticket/{}".format(ticket_id))
        statuses = text.extract_statuses(r.text)

        # Just display current status.
        if not status:
            status = self.extract_status_from_ticket_page(r.text)
            output.append("Current status: {}".format(status))
            if statuses:
                output.append("Available statuses: {}".format(
                    ", ".join(statuses)))
            return output

        if not status:
            raise exceptions.FatalError("bad status (acceptable: {})".format(
                ", ".join(statuses)))

        if self.message:
            comment = self.message
        elif self.add_comment:
            comment = self._read_comment()
        else:
            comment = ""

        # Not having a value for submit causes Trac to ignore the request.
        data = {
            "action": status,
            "comment": comment,
            "submit": "anything",
        }
        data.update(self._extract_timestamps(r.text))

        r = self.post("/ticket/{}".format(ticket_id), data)
Example #8
0
 def test_extract_statuses_nothing(self):
     raw_html = ""
     self.assertEquals(text.extract_statuses(raw_html), [])
Example #9
0
 def test_extract_statuses_nothing(self):
     raw_html = ""
     self.assertEquals(text.extract_statuses(raw_html), [])