Ejemplo n.º 1
0
    def test_add_event(self):
        invalid_date = '2018.12.31'
        invalid_event_1 = EventModel(1, 'event_title_1', 'tags_1',
                                     'description_1', 'image_1', [], [],
                                     invalid_date, 'location_1', 'address1',
                                     '5')
        event_id_1 = EventController.add_event(self.event_1)

        self.assertIsNotNone(event_id_1)
        self.assertIsNotNone(EventController.add_event(invalid_event_1))
Ejemplo n.º 2
0
def post_event():
    global current_event
    global current_user
    current_event = read_event()
    if not current_user:
        add_output("You have to login first to post events. \n")
    else:
        result = EventController.add_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            current_event.eid = None
            add_output("The same event already exists. \n")
        elif result == Errors.FAILURE.name:
            current_event.eid = None
            return_failure()
        add_output('Event #' + str(result) + ' has been posted. \n')
        current_event.eid = result

        result = EventController.host_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            current_event.eid = None
            add_output("You have already hosted this event. \n")
        elif result == Errors.FAILURE.name:
            current_event.eid = None
            return_failure()
        add_output("You are the host of event " + str(current_event.eid) +
                   " now. \n")
        current_event.hosts = current_user.uid
        current_user.host_events.append(current_event.eid)
        print('User #' + current_event.hosts + ' posted event #' +
              str(current_event.eid) + '. \n')
        EventController.print_event(current_event)
    return
Ejemplo n.º 3
0
    def test_host_event(self):
        UserController.add_user(self.user_1)
        user_2 = UserController.retrieve_user('email', 'email_1')

        event_id = EventController.add_event(self.event_1)
        self.event_1.eventid = event_id

        self.assertIsNotNone(EventController.host_event(user_2, self.event_1))

        UserController.delete_user('nickname_1', 'email_1')
Ejemplo n.º 4
0
def post_event(data):
    event = EventModel(0, data['title'], data['tags'], data['description'],
                       data['image'], data['hosts'], [], data['event_date'],
                       data['state'], data['address'], data['register_period'])

    EventController.print_event(event)
    result = EventController.add_event(event)
    if result == Errors.DUPLICATE.name:
        event.eid = None
        return Errors.DUPLICATE.name, None
    elif result == Errors.FAILURE.name:
        event.eid = None
        return Errors.FAILURE.name, None
    print('Event #' + str(result) + ' has been posted. \n')
    event.eid = result

    result = EventController.host_event(event.hosts, event)
    if result == Errors.DUPLICATE.name:
        current_event.eid = None
        print("You have already hosted this event. \n")
        return Errors.DUPLICATE.name
    elif result == Errors.FAILURE.name:
        current_event.eid = None
        return Errors.FAILURE.name

    EventController.print_event(event)
    data = {
        'eid': event.eid,
        'title': event.title,
        'tags': event.tags,
        'description': event.description,
        'hosts': event.hosts,
        'event_date': event.event_date,
        'state': event.location,
        'address': event.address,
        'image': event.image,
        'register_period': event.register_period,
        'expire_date': event.expire_date
    }
    return 'OK', data
Ejemplo n.º 5
0
 def test_post_event(self):
     event_id_1 = EventController.add_event(self.user_1, self.event_1)
     self.assertIsNotNone(event_id_1)