Esempio n. 1
0
 def test_reply_disarm_n(self):
     """ Test disarm reply n """
     ret = Disarm.reply_handler(self.action, "n")
     self.assertEqual(1, len(ret))
     self.assertEqual(ret[0][0], self.action.attacker)
     self.assertEqual(ret[0][1], "Your DISARM target claims he was not "
             "disarmed by you.")
     self.assertEqual(self.p1a.disarm, False)
     self.assertEqual(len(self.taskqueue_stub.get_filtered_tasks(\
             queue_names='disarm')), 0)
Esempio n. 2
0
 def test_reply_disarm_N(self):
     """ Test disarm reply N """
     ret = Disarm.reply_handler(self.action, "N")
     self.assertEqual(1, len(ret))
     self.assertEqual(ret[0][0], self.action.attacker)
     self.assertEqual(
         ret[0][1], "Your DISARM target claims he was not "
         "disarmed by you.")
     self.assertEqual(self.p1a.disarm, False)
     self.assertEqual(len(self.taskqueue_stub.get_filtered_tasks(\
             queue_names='disarm')), 0)
Esempio n. 3
0
    def test_reply_disarm_y(self):
        """ Test disarm reply y """
        later = Util.utc_to_chi(self.action.datetime + timedelta(hours=1))

        ret = Disarm.reply_handler(self.action, "y")
        self.assertEqual(1, len(ret))
        self.assertEqual(ret[0][0], "+1")
        self.assertEqual(ret[0][1], "You have been DISARM until {}".format(\
                later.strftime("%m-%d %I:%M%p")))
        self.assertEqual(self.p1a.disarm, True)
        self.assertEqual(len(self.taskqueue_stub.get_filtered_tasks(\
                queue_names='disarm')), 1)
Esempio n. 4
0
    def test_reply_disarm_y(self):
        """ Test disarm reply y """
        later = Util.utc_to_chi(self.action.datetime + timedelta(hours=1))

        ret = Disarm.reply_handler(self.action, "y")
        self.assertEqual(1, len(ret))
        self.assertEqual(ret[0][0], "+1")
        self.assertEqual(ret[0][1], "You have been DISARM until {}".format(\
                later.strftime("%m-%d %I:%M%p")))
        self.assertEqual(self.p1a.disarm, True)
        self.assertEqual(len(self.taskqueue_stub.get_filtered_tasks(\
                queue_names='disarm')), 1)
Esempio n. 5
0
    def handler(cls, ref, params, From):
        logging.debug("REPLY {}".format(ref))
        lookup = Action.get_by_id(int(ref))
        if not lookup:
            raise ReplyError("ref num", ref)

        response = params[0]
        if response != "Y" and response != "y" and response != "N" and response != "n":
            raise ReplyError(response, ref)

        if lookup.action == "DISARM":
            return Disarm.reply_handler(lookup, response)
        else:
            output_msg = []
            if lookup.action == "KILL":
                output_msg += Kill.reply_handler(lookup, response)
            elif lookup.action == "BOMB":
                output_msg += Bomb.reply_handler(lookup, response, From)
            """ Generate push if necessary """
            output_msg += Team.push(Team.get_by_id(From.team))
            return output_msg
        raise ReplyError(response, ref)