Beispiel #1
0
    def __init__(self, key_word, filename='events.json'):
        """
    When created, this instance will try to open self.filename. It will always
    keep a copy in memory of the whole events dictionary and commit it when necessary.
    """
        self.key_word = key_word
        self.filename = filename
        self.command_list = (
            rsvp_commands.RSVPInitCommand(key_word),
            rsvp_commands.RSVPHelpCommand(key_word),
            rsvp_commands.RSVPCancelCommand(key_word),
            rsvp_commands.RSVPMoveCommand(key_word),
            rsvp_commands.RSVPSetLimitCommand(key_word),
            rsvp_commands.RSVPSetDateCommand(key_word),
            rsvp_commands.RSVPSetTimeCommand(key_word),
            rsvp_commands.RSVPSetTimeAllDayCommand(key_word),
            rsvp_commands.RSVPSetStringAttributeCommand(key_word),
            rsvp_commands.RSVPSummaryCommand(key_word),
            rsvp_commands.RSVPPingCommand(key_word),
            rsvp_commands.RSVPCreditsCommand(key_word),
            rsvp_commands.RSVPCreateCalendarEventCommand(key_word),
            rsvp_commands.RSVPSetDurationCommand(key_word),

            # This needs to be at last for fuzzy yes|no checking
            rsvp_commands.RSVPConfirmCommand(key_word))

        try:
            with open(self.filename, "r") as f:
                try:
                    self.events = json.load(f)
                except ValueError:
                    self.events = {}
        except IOError:
            self.events = {}
Beispiel #2
0
    def __init__(self, key_word):
        self.key_word = key_word
        self.command_list = (
            rsvp_commands.RSVPInitCommand(key_word),
            rsvp_commands.RSVPInitEventCommand(key_word),
            rsvp_commands.RSVPHelpCommand(key_word),
            rsvp_commands.RSVPMoveCommand(key_word),
            rsvp_commands.RSVPSummaryCommand(key_word),
            rsvp_commands.RSVPPingCommand(key_word),
            rsvp_commands.RSVPCreditsCommand(key_word),

            # Command supported on recurse.com
            rsvp_commands.RSVPCancelCommand(key_word),
            rsvp_commands.RSVPSetLimitCommand(key_word),
            rsvp_commands.RSVPSetDateCommand(key_word),
            rsvp_commands.RSVPSetTimeCommand(key_word),
            rsvp_commands.RSVPSetTimeAllDayCommand(key_word),
            rsvp_commands.RSVPSetDurationCommand(key_word),
            rsvp_commands.RSVPSetLocationCommand(key_word),
            rsvp_commands.RSVPSetPlaceCommand(key_word),
            rsvp_commands.RSVPSetDescriptionCommand(key_word),

            # Command no longer supported anywhere
            rsvp_commands.RSVPCreateCalendarEventCommand(key_word),

            # This needs to be at last for fuzzy yes|no checking
            rsvp_commands.RSVPConfirmCommand(key_word))
Beispiel #3
0
 def test_generate_funky_response_no(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     normal_response = command.generate_response('no', self.event)
     possible_expected_responses = [
         normal_response + postfix for postfix in command.funky_no_postfixes
     ]
     response = command.generate_response('no', self.event, funkify=True)
     self.assertIn(response, possible_expected_responses)
Beispiel #4
0
 def test_generate_funky_response_yes(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     normal_response = command.generate_response('yes', self.event)
     possible_expected_responses = [
         prefix + normal_response for prefix in command.funky_yes_prefixes
     ]
     response = command.generate_response('yes', self.event, funkify=True)
     self.assertIn(response, possible_expected_responses)
Beispiel #5
0
 def test_generate_response_no(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     response = command.generate_response('no', self.event)
     self.assertIn("You are **not** attending", response)
Beispiel #6
0
 def test_generate_response_yes(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     response = command.generate_response('yes', self.event)
     self.assertIn("**You** are attending", response)
Beispiel #7
0
 def test_generate_response_maybe(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     response = command.generate_response(decision='maybe', event_id=self.event_id)
     self.assertEqual("You **might** be attending **{}**. It's complicated.".format(self.event_id), response)
Beispiel #8
0
 def test_generate_response_no(self):
     command = rsvp_commands.RSVPConfirmCommand(prefix='rsvp')
     response = command.generate_response(decision='no', event_id=self.event_id)
     self.assertEqual("You are **not** attending **{}**!".format(self.event_id), response)