def test_create_flex_interest(self):

        EventManager.create(category='Category1',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            note='test_note')
        EventManager.create(category='Category2',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            note='test_note')
        EventManager.create(category='Category3',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            note='test_note')
        EventManager.create(category='Category4',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_2',
                            note='test_note')
        EventManager.create(category='Category5',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_2',
                            note='test_note')
        self.assertEqual(3, len(Event.get_interests_by_building('building_1')))
        self.assertEqual(2, len(Event.get_interests_by_building('building_2')))
    def get(self):
        params = {}
        if not self.user:
            return self.render_template('home.html', **params)
        if self.user:
            user_info = models.User.get_by_id(long(self.user_id))
            if user_info.building is None:
                logging.info('no building assigned to user')
                self.redirect_to('complete_profile_social_user')

        action = str(self.request.get('action'))
        if action == 'delete':
            event_manager = EventManager.get(self.request.get('key'))
            event_manager.cancel()
        elif action == 'cancel':
            event_manager = EventManager.get(self.request.get('key'))
            participants = event_manager.get_all_companions()
            category = event_manager.get_event().category
            activity_username = event_manager.get_event().username
            event_manager.cancel()
            activity_user = models.User.get_by_username(activity_username)
            activity_owner_name = activity_user.name + ' ' + activity_user.last_name
            for participant in participants:
                self._push_notification(category,
                                        activity_owner_name, participant,
                                        self.request.get('reason'))

        user_info = models.User.get_by_id(long(self.user_id))
        my_interests = Event.query(Event.username == user_info.username,
                                   Event.status != Event.EXPIRED).fetch()
        my_join_requests = Request.get_open_requests_for_user(user_info.key)
        activities_for_my_join_requests = list()
        for join_request in my_join_requests:
            activities_for_my_join_requests.append(join_request.activity.get())

        event_attributes_list = dict()
        for event in my_interests:
            event_attribute = event_attributes(event.key.urlsafe(),
                                               self.username)
            event_attributes_list[event.key.urlsafe()] = event_attribute
        for event in activities_for_my_join_requests:
            event_attribute = event_attributes(event.key.urlsafe(),
                                               self.username)
            event_attributes_list[event.key.urlsafe()] = event_attribute

        self.view.my_interests = my_interests
        self.view.activities_for_my_join_requests = activities_for_my_join_requests
        self.view.event_attributes_list = event_attributes_list
        token = channel.create_channel(self.user_id)
        params['token'] = token
        return self.render_template('home.html', **params)
    def test_load_interest_mgr(self):
        success, message, interest_created = EventManager.create(
            category='Category1',
            duration='40',
            expiration='180',
            username='******',
            building_name='building_1',
            note='test_note')
        interest_from_interest_mgr = EventManager.get(
            interest_created.key.urlsafe()).get_event()

        self.assertEqual(interest_created.key.urlsafe(),
                         interest_from_interest_mgr.key.urlsafe())
        self.assertEqual(Event.FORMING, interest_from_interest_mgr.status)
 def test_load_activity_mgr(self):
     success, message, activity_created = EventManager.create(
         category='Category1',
         duration='40',
         expiration='180',
         username='******',
         building_name='building_1',
         min_number_of_people_to_join='1',
         max_number_of_people_to_join='2',
         note='note1')
     activity_from_activity_mgr = EventManager.get(
         activity_created.key.urlsafe()).get_event()
     self.assertEqual(activity_created.key.urlsafe(),
                      activity_from_activity_mgr.key.urlsafe())
     self.assertEqual(Event.FORMING, activity_from_activity_mgr.status)
 def get(self):
     user_id = self.user_id
     key = self.request.get('key')
     action = self.request.get('action')
     activity_manager = EventManager.get(key)
     activity_user = models.User.get_by_username(
         activity_manager.get_event().username)
     if action == "Initiate":
         (success, request) = RequestManager.initiate(
             activity_key=activity_manager.get_event().key,
             requester_key=models.User.get_by_username(self.username).key)
         if success:
             message = _(
                 "Processing Request. We'll notify you as soon as the organizer confirms."
             )
             self._push_notification(activity_manager, request)
             self.add_message(message, 'success')
         else:
             message = _("Failed to send join request")
             self.add_message(message, 'failure')
     elif action == "Cancel":
         request = Request.query(Request.activity == activity,
                                 cls.requester == activity_user,
                                 Request.status == Request.INITIATED)
         reqeust_manager = RequestManager.get(request.key)
         reqeust_manager.cancel()
     elif action == "Ignore":
         pass
     return self.redirect_to('pipeline')
    def test_create_specific_interest(self):

        EventManager.create(category='Category1',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            min_number_of_people_to_join='1',
                            max_number_of_people_to_join='2',
                            note='note1')
        EventManager.create(category='Category2',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            min_number_of_people_to_join='1',
                            max_number_of_people_to_join='2',
                            note='note2')
        EventManager.create(category='Category3',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_1',
                            min_number_of_people_to_join='1',
                            max_number_of_people_to_join='2',
                            note='note2')
        EventManager.create(category='Category4',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_2',
                            min_number_of_people_to_join='1',
                            max_number_of_people_to_join='2',
                            note='note3')
        EventManager.create(category='Category5',
                            duration='40',
                            expiration='180',
                            username='******',
                            building_name='building_2',
                            min_number_of_people_to_join='1',
                            max_number_of_people_to_join='2',
                            note='note4')
        self.assertEqual(3,
                         len(Event.get_activities_by_building('building_1')))
        self.assertEqual(2,
                         len(Event.get_activities_by_building('building_2')))
示例#7
0
 def post(self):
     if self.user:
         user_info = models.User.get_by_id(long(self.user_id))
         building_name = user_info.building
         interest_info = dict()
         interest_info['building_name'] = building_name
         interest_info['category'] = self.form.category.data.strip()
         interest_info['username'] = user_info.username
         if hasattr(
                 self.form, 'set_time'
         ) and self.form.set_time.data != "None" and self.form.set_time.data != "":
             interest_info['start_time'] = isodate.parse_datetime(
                 self.form.set_time.data.strip()).replace(tzinfo=None)
         elif hasattr(
                 self.form, 'expiration'
         ) and self.form.expiration.data != "" and self.form.expiration.data != "None":
             interest_info['expiration'] = self.form.expiration.data.strip()
         if hasattr(self.form, 'min_number_of_people_to_join'):
             interest_info[
                 'min_number_of_people_to_join'] = self.form.min_number_of_people_to_join.data.strip(
                 )
         if hasattr(self.form, 'max_number_of_people_to_join'):
             interest_info[
                 'max_number_of_people_to_join'] = self.form.max_number_of_people_to_join.data.strip(
                 )
         if hasattr(self.form, 'min_number_of_people_to_join') and hasattr(
                 self.form, 'max_number_of_people_to_join'):
             min_int = interest_info['min_number_of_people_to_join'].split(
             )[0]
             max_int = interest_info['max_number_of_people_to_join'].split(
             )[0]
             if min_int != 'None' and max_int != 'None':
                 min_count = int(min_int)
                 max_count = int(max_int)
                 if min_count > max_count:
                     message = _(
                         "Minimum number of participants cannot be greater than Maximum number of participants."
                     )
                     self.add_message(message, 'error')
                     return self.redirect_to('join')
         if hasattr(self.form, 'meeting_place'):
             interest_info[
                 'meeting_place'] = self.form.meeting_place.data.strip()
         if hasattr(self.form, 'duration'):
             interest_info['duration'] = self.form.duration.data.strip()
         if hasattr(self.form, 'activity_location'):
             interest_info[
                 'activity_location'] = self.form.activity_location.data.strip(
                 )
         success, message, event = EventManager.create(**interest_info)
         if success:
             message = _(
                 "Your post is now live. View matches and manage it on this My Corner page."
             )
             self.add_message(message, 'success')
         else:
             self.add_message(message, 'error')
         return self.redirect_to('home')
示例#8
0
 def accept(self):
     event_manager = EventManager.get(self._request.activity.urlsafe())
     status, message = event_manager.connect(self._request.requester.id())
     if status:
         self._request.status = Request.ACCEPTED
         self._request.put()
         return True, "Accepted & Connected"
     else:
         return False, message
    def test_set_time_interest(self):

        interest_start_time = datetime.utcnow() + timedelta(hours=2)
        success, message, activity_created = EventManager.create(
            category='Category1',
            start_time=interest_start_time,
            username=self.user1.username,
            building_name='building_1',
            min_number_of_people_to_join='1',
            max_number_of_people_to_join='2',
            meeting_place='meeting_place',
            activity_location='activity_location')
        activity_manager = EventManager.get(activity_created.key.urlsafe())
        self.assertEqual(activity_created.key.urlsafe(),
                         activity_manager.get_event().key.urlsafe())
        self.assertEqual(True,
                         activity_manager.can_join(self.user2.key.id())[0])
        activity_manager.connect(self.user2.key.id())
        self.assertEqual(Event.FORMED_OPEN, activity_created.status)
        self.assertEqual(False,
                         activity_manager.can_join(self.user2.key.id())[0])
        self.assertEqual(True,
                         activity_manager.can_join(self.user3.key.id())[0])
        activity_manager.connect(self.user3.key.id())
        self.assertEqual(Event.FORMED_OPEN, activity_created.status)
        self.assertEqual(False,
                         activity_manager.can_join(self.user4.key.id())[0])
        self.assertEqual(2, activity_manager.companion_count())
        get_interest_details(activity_created.key.urlsafe())
        #Now have 3 Unjoin activity
        activity_manager.unjoin(self.user3.key.id())
        self.assertEqual(Event.FORMED_OPEN, activity_created.status)
        self.assertEqual(1, activity_manager.companion_count())
        #Now check if User4 can join
        self.assertEqual(True,
                         activity_manager.can_join(self.user4.key.id())[0])
        activity_manager.connect(self.user4.key.id())
        self.assertEqual(2, activity_manager.companion_count())
        self.assertEqual(Event.FORMED_OPEN, activity_created.status)
        activity_manager.unjoin(self.user4.key.id())
        activity_manager.unjoin(self.user2.key.id())
        self.assertEqual(Event.FORMING, activity_created.status)
        self.assertEqual(0, activity_manager.companion_count())
示例#10
0
 def post(self):
     if self.user:
         user_info = models.User.get_by_id(long(self.user_id))
         building_name = user_info.building
         interest_info = dict()
         interest_info['building_name'] = building_name
         interest_info['category'] = self.form.category.data.strip()
         interest_info['username'] = user_info.username
         if hasattr(
                 self.form, 'set_time'
         ) and self.form.set_time.data != "None" and self.form.set_time.data != "":
             interest_info['start_time'] = isodate.parse_datetime(
                 self.form.set_time.data.strip()).replace(tzinfo=None)
         elif hasattr(
                 self.form, 'expiration'
         ) and self.form.expiration.data != "" and self.form.expiration.data != "None":
             interest_info['expiration'] = self.form.expiration.data.strip()
         if hasattr(self.form, 'min_number_of_people_to_join'):
             interest_info[
                 'min_number_of_people_to_join'] = "1"  #self.form.min_number_of_people_to_join.data.strip()
         if hasattr(self.form, 'max_number_of_people_to_join'):
             interest_info[
                 'max_number_of_people_to_join'] = self.form.max_number_of_people_to_join.data.strip(
                 )
         ''' Commenting out the logic checking block since the min # to join is always 1 for now'''
         '''
         if hasattr(self.form,'min_number_of_people_to_join') and hasattr(self.form,'max_number_of_people_to_join'):
             min_int = interest_info['min_number_of_people_to_join'].split()[0]
             max_int = interest_info['max_number_of_people_to_join'].split()[0]
             if min_int != 'None' and max_int != 'None':
                 min_count = int(min_int)
                 max_count = int(max_int)
                 if min_count > max_count:
                     message = _("Minimum number of participants cannot be greater than Maximum number of participants.")
                     self.add_message(message, 'error')
                     return self.redirect_to('join')
         '''
         if hasattr(self.form, 'meeting_place'):
             interest_info[
                 'meeting_place'] = self.form.meeting_place.data.strip()
         if hasattr(self.form, 'duration'):
             interest_info['duration'] = self.form.duration.data.strip()
         if hasattr(self.form, 'activity_location'):
             interest_info[
                 'activity_location'] = self.form.activity_location.data.strip(
                 )
         success, message, event = EventManager.create(**interest_info)
         if success:
             message = _(
                 "Your post is now live. You can approve join requests and manage it here. Watch your email for notifications."
             )
             self.add_message(message, 'success')
         else:
             self.add_message(message, 'error')
         return self.redirect_to('home')
示例#11
0
 def test_join(self):
     success, message, activity_created = EventManager.create(
         category='Category1',
         duration='40',
         expiration='180',
         username=self.user1.username,
         building_name='building_1',
         min_number_of_people_to_join='1',
         max_number_of_people_to_join='2',
         note='note1')
     activity_manager = EventManager.get(activity_created.key.urlsafe())
     self.assertEqual(activity_created.key.urlsafe(),
                      activity_manager.get_event().key.urlsafe())
     self.assertEqual(True,
                      activity_manager.can_join(self.user2.key.id())[0])
     activity_manager.connect(self.user2.key.id())
     self.assertEqual(Event.FORMED_OPEN, activity_created.status)
     self.assertEqual(False,
                      activity_manager.can_join(self.user2.key.id())[0])
     self.assertEqual(True,
                      activity_manager.can_join(self.user3.key.id())[0])
     activity_manager.connect(self.user3.key.id())
     self.assertEqual(Event.FORMED_OPEN, activity_created.status)
     self.assertEqual(False,
                      activity_manager.can_join(self.user4.key.id())[0])
     self.assertEqual(2, activity_manager.companion_count())
     get_interest_details(activity_created.key.urlsafe())
     #Now have 3 Unjoin activity
     activity_manager.unjoin(self.user3.key.id())
     self.assertEqual(Event.FORMED_OPEN, activity_created.status)
     self.assertEqual(1, activity_manager.companion_count())
     #Now check if User4 can join
     self.assertEqual(True,
                      activity_manager.can_join(self.user4.key.id())[0])
     activity_manager.connect(self.user4.key.id())
     self.assertEqual(2, activity_manager.companion_count())
     self.assertEqual(Event.FORMED_OPEN, activity_created.status)
     activity_manager.unjoin(self.user4.key.id())
     activity_manager.unjoin(self.user2.key.id())
     self.assertEqual(Event.FORMING, activity_created.status)
     self.assertEqual(0, activity_manager.companion_count())
 def test_initiate(self):
     #Activity Created by user1
     success, message, activity_created = EventManager.create(
         category='Category1',
         duration='40',
         expiration='180',
         username=self.user1.username,
         building_name='building_1',
         min_number_of_people_to_join='1',
         max_number_of_people_to_join='2',
         note='note1')
     activity_manager = EventManager.get(activity_created.key.urlsafe())
     self.assertEqual(activity_created.key.urlsafe(),
                      activity_manager.get_event().key.urlsafe())
     (success,
      request) = RequestManager.initiate(activity_key=activity_created.key,
                                         requester_key=self.user2.key)
     self.assertIsNotNone(request, "Failed to initiate request")
     request_manager = RequestManager.get(request.key.urlsafe())
     self.assertIsNotNone(request_manager, "Failed to load request manager")
     self.assertEqual(True, request_manager.can_accept(self.user1.username))
示例#13
0
 def post(self):
     if self.user:
         user_info = models.User.get_by_id(long(self.user_id))
         interest_id = self.request.get('interest_id')
         event_manager = EventManager.get(interest_id)
         success, message, interest_owner, activity_key = event_manager.join_flex_interest(
             user_id=self.user_id,
             min_number_of_people_to_join=self.form.
             min_number_of_people_to_join.data.strip(),
             max_number_of_people_to_join=self.form.
             max_number_of_people_to_join.data.strip(),
             note=self.form.note.data.strip(),
             meeting_place=self.form.meeting_place.data.strip(),
             activity_location=self.form.activity_location.data.strip())
         if success:
             message = _("The interest was converted successfully.")
             self._push_notification(user_info, interest_owner,
                                     EventManager.get(activity_key))
             self.add_message(message, 'success')
             return self.redirect_to('activity')
         else:
             self.add_message(message, 'failure')
             return self.redirect_to('activity')
示例#14
0
    def test_join_flex_interest(self):

        success, message, interest_created = EventManager.create(
            category='Category1',
            duration='40',
            expiration='180',
            username=self.user1.username,
            building_name='building_1',
            note='test_note')
        interest_manager = EventManager.get(interest_created.key.urlsafe())
        interest_from_interest_mgr = interest_manager.get_event()
        self.assertEqual(interest_created.key.urlsafe(),
                         interest_from_interest_mgr.key.urlsafe())
        self.assertEqual(Event.FORMING, interest_from_interest_mgr.status)
        interest_manager.join_flex_interest(self.user2.key.id(),
                                            min_number_of_people_to_join='2',
                                            max_number_of_people_to_join='3')
        self.assertEqual(Event.EVENT_TYPE_SPECIFIC_INTEREST,
                         interest_created.type)
        self.assertEqual(Event.FORMING, interest_created.status)
        self.assertEqual(1, interest_manager.companion_count())
        interest_manager.connect(self.user3.key.id())
        self.assertEqual(Event.FORMED_OPEN, interest_created.status)
        self.assertEqual(2, interest_manager.companion_count())
示例#15
0
 def _send_readyness_notification(self, activity):
     notification_manager = NotificationManager.get(self)
     activity_manager = EventManager.get(activity.key.urlsafe())
     interest_details = get_interest_details(
         activity_manager.get_event().key.urlsafe())
     for participant in activity_manager.get_all_companions():
         template_val = notification_manager.get_base_template()
         template_val['interest'] = interest_details
         template_val['participant_username'] = participant.user.get(
         ).username
         notification_manager.push_notification(
             participant.user.get().email,
             'ActiMom.com Notification: Your activity is starting soon!',
             'emails/activity_formed_and_initiated_for_activity_participant.txt',
             **template_val)
示例#16
0
 def post(self):
     activity_key = self.request.get('activity_key')
     #invoke unjoin for given user and activity
     activity_manager = EventManager.get(activity_key)
     success, message = activity_manager.unjoin(self.user_id)
     if success:
         user_info = models.User.get_by_id(long(self.user_id))
         channel.send_message(
             activity_manager.get_event().username,
             "A user has left your activity: " + user_info.username)
         self.add_message(message, 'success')
         self._push_notification(user_info, activity_manager)
     #fire a notification to the activity owner
     else:
         self.add_message(message, 'error')
     return self.redirect_to('activity')
 def get(self):
     action = self.request.get('action')
     request_key = self.request.get('request_key')
     request_manager = RequestManager.get(request_key)
     activity_manager = EventManager.get(
         request_manager.get_request().activity.urlsafe())
     if action == "Accept":
         (success, message) = request_manager.accept()
         if success:
             self.add_message(message, 'success')
             self._push_notification(activity_manager)
         else:
             self.add_message(message, 'failure')
     elif action == "Reject":
         request_manager.reject()
     elif action == "Cancel":
         request_manager.cancel()
     return self.redirect_to('pipeline')
 def post(self):
     event_manager = EventManager.get(self.request.get('activity_key'))
     #invoke unjoin for given user and activity
     participants = event_manager.get_all_companions()
     category = event_manager.get_event().category
     activity_username = event_manager.get_event().username
     success, message = event_manager.cancel()
     if success:
         activity_user = models.User.get_by_username(activity_username)
         activity_owner_name = activity_user.name + ' ' + activity_user.last_name
         for participant in participants:
             participant_user = participant.user.get()
             channel.send_message(participant_user.name, "Your activity has been canceled by: " + activity_owner_name)
             self._push_notification(category,activity_owner_name,participant_user,'No reason')
         self.add_message(message, 'success')
     else:
         self.add_message(message, 'error')
     #fire a notification to the activity owner
     return self.redirect_to('pipeline')
示例#19
0
def get_interest_details(interest_key):
    event_manager = EventManager.get(interest_key)
    event = event_manager.get_event()
    interest_user = models.User.get_by_username(event.username)
    interest_details = dict()
    interest_details['category'] = event.category
    interest_details['meeting_place'] = event.meeting_place
    interest_details['location'] = event.activity_location
    if event.start_time is not None:
        start_time = event.start_time - datetime.utcnow()
        if start_time.total_seconds() > 0:
            interest_details['start_time'] = minute_format(start_time)
    interest_details['username'] = event.username
    participants = event_manager.get_all_companions()
    interest_details['participants'] = participants
    all_participants = [interest_user.name + ' ' + interest_user.last_name]
    for participant in participants:
        all_participants.append(
            str(participant.user.get().name) + ' ' +
            str(participant.user.get().last_name))
    interest_details['all_participants'] = ' , '.join(all_participants)
    return interest_details
示例#20
0
def event_attributes(event_key, username):
    event_attributes = {}
    event_manager = EventManager.get(event_key)
    event = event_manager.get_event()
    user = models.User.get_by_username(username)
    type = event.type
    expiration = event_manager.expires_in()
    event_attributes['expiration'] = expiration
    can_join = event_manager.can_join(user.key.id())[0]
    can_leave = event_manager.can_leave(user.key.id())[0]
    can_cancel = event_manager.can_cancel(user.key.id())[0]
    can_initiate_join_request = Request.can_initiate(
        event_manager.get_event().key, user.key)
    can_cancel_join_request = Request.can_cancel(event_manager.get_event().key,
                                                 user.key)
    if can_join and can_initiate_join_request:
        event_attributes['can_join'] = True
    if can_cancel_join_request:
        event_attributes['can_cancel_join_request'] = True
    if can_leave:
        event_attributes['can_leave'] = True
    if can_cancel:
        event_attributes['can_cancel'] = True
    if event.start_time is not None:
        start_time = str(event.start_time)
        if start_time.find('.') > 0:
            event_attributes['start_time'] = start_time[0:start_time.find('.')]
        else:
            event_attributes['start_time'] = start_time
    if type == Event.EVENT_TYPE_SPECIFIC_INTEREST:
        feedback = UserFeedback.query(
            UserFeedback.user == user.key,
            UserFeedback.status == UserFeedback.OPEN,
            UserFeedback.activity == event.key).fetch()
        if len(feedback) > 0:
            event_attributes['has_feedback'] = True
            event_attributes['feedback'] = feedback[0]
        event_attributes['spots_remaining'] = event_manager.spots_remaining()
    return event_attributes
示例#21
0
 def post(self):
     if self.user:
         interest_id = self.request.get('interest_id')
         event_manager = EventManager.get(interest_id)
         success, message, current_owner, new_owner = event_manager.join_flex_interest(
             user_id=self.user_id,
             min_number_of_people_to_join=self.form.
             min_number_of_people_to_join.data.strip(),
             max_number_of_people_to_join=self.form.
             max_number_of_people_to_join.data.strip(),
             meeting_place=self.form.meeting_place.data.strip(),
             activity_location=self.form.activity_location.data.strip())
         if success:
             message = _(
                 "Activity details necessary to start are now set. We'll keep you posted on activity status."
             )
             self._push_notification(new_owner, current_owner,
                                     event_manager)
             self.add_message(message, 'success')
             return self.redirect_to('activity')
         else:
             self.add_message(message, 'failure')
             return self.redirect_to('activity')
示例#22
0
def can_join(key, user_id):
    EventManager.get(key).can_join(user_id)[0]
示例#23
0
def get_all_companions(key):
    companions = []
    for companion in EventManager.get(key).get_all_companions():
        username = companion.user.get().username
        companions.append('<a href="/user_profile/?username='******'">'+username+'</a>')
    return companions
示例#24
0
def spots_remaining(key):
    return EventManager.get(key).spots_remaining()
示例#25
0
def get_expiration_duration(key):
    return EventManager.get(key).expires_in()
示例#26
0
    def test_match_making(self):
        interest_list = []
        activity_list = []
        #Create some interests
        interest_list.append(
            EventManager.create(category='Play date',
                                duration='40',
                                expiration='180',
                                username='******',
                                building_name='building1',
                                note='test_node')[2])
        interest_list.append(
            EventManager.create(category='Play date',
                                duration='40',
                                expiration='180',
                                username='******',
                                building_name='building1',
                                note='test_node')[2])
        interest_list.append(
            EventManager.create(category='Play date',
                                duration='20',
                                expiration='180',
                                username='******',
                                building_name='building1',
                                note='test_node')[2])

        #Create some activities
        activity_list.append(
            EventManager.create(category='Play date',
                                duration='40',
                                expiration='180',
                                username='******',
                                building_name='building1',
                                ip='127.0.0.1',
                                min_number_of_people_to_join='1',
                                max_number_of_people_to_join='1',
                                note='meet me at shadyside')[2])
        activity_list.append(
            EventManager.create(category='Stroller walk',
                                duration='40',
                                expiration='180',
                                username='******',
                                building_name='building1',
                                ip='127.0.0.1',
                                min_number_of_people_to_join='1',
                                max_number_of_people_to_join='1',
                                note='meet me at shadyside')[2])

        #Assert if interests and activities are created fine
        self.assertEqual(
            3, len(Event.get_active_interests_by_category('Play date')))
        self.assertEqual(
            1, len(Event.get_active_activities_by_category('Stroller walk')))
        self.assertEqual(
            1, len(Event.get_active_activities_by_category('Stroller walk')))

        match_list = MatchMaker.match_all()
        self.assertEqual(2, len(match_list))
        self.assertEqual(2, len(match_list['user1']))
        self.assertEqual(1, len(match_list['user2']))
        interest = EventManager.create(category='Stroller walk',
                                       duration='40',
                                       expiration='180',
                                       username='******',
                                       building_name='building1',
                                       note='test_node')[2]
        interest_list.append(interest)
        match_list = MatchMaker.match_interest_with_activities(
            interest.key.urlsafe())
        self.assertEqual(1, len(match_list))
        self.assertEqual(1, len(match_list['user1']))

        activity = EventManager.create(category='Stroller walk',
                                       duration='40',
                                       expiration='180',
                                       username='******',
                                       building_name='building1',
                                       ip='127.0.0.1',
                                       min_number_of_people_to_join='1',
                                       max_number_of_people_to_join='1',
                                       note='meet me at shadyside')[2]

        match_list = MatchMaker.match_activity_with_interests(
            activity.key.urlsafe())
        self.assertEqual(1, len(match_list))

        activity = EventManager.create(category='Play date',
                                       duration='20',
                                       expiration='180',
                                       username='******',
                                       building_name='building1',
                                       ip='127.0.0.1',
                                       min_number_of_people_to_join='1',
                                       max_number_of_people_to_join='1',
                                       note='meet me at shadyside')[2]

        match_list = MatchMaker.match_activity_with_interests(
            activity.key.urlsafe())
        self.assertEqual(2, len(match_list))
        self.assertEqual(2, len(match_list['user1']))