示例#1
0
def test_get_event(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    res1 = model.get_event(events, "12345")
    assert type(res1) == dict
    res2 = model.get_event(events, "6789")
    assert res2 is None
示例#2
0
def _refresh_from_file(file, src, sess):
    logging.debug(file)
    logfile = get_logfile_progress(sess, file)
    logging.info("Refreshing from: {}".format(file))

    with open(logfile.source_url, 'rb') as f:
        logging.debug('offset: {}'.format(logfile.current_key))
        f.seek(logfile.current_key)
        iter = 0
        for line in f:
            try:
                data = modelutils.logline_to_dict(line.decode())
                data["src_abbr"] = src.name
                if not ('type' in data and data['type'] == 'crash'):
                    add_event(sess, data)
            except KeyError as e:
                logging.error('key {} not found'.format(e))
            except Exception as e:  # how scandalous! Don't want one broken line to break everything
                logging.exception(
                    'Something unexpected happened, skipping this event')
            iter += 1
            logfile.current_key += len(line)
            if iter % 1000 == 0:  # don't spam commits
                sess.commit()
        logfile.current_key = f.tell()
        sess.commit()
示例#3
0
def test_rsvp(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    model.rsvp(events, "12345", "1111", "Omer Daniel", 2)
    res = model.get_event(events, "12345")
    print(res['participants'])
    assert len(res['participants']) == 1
示例#4
0
文件: api.py 项目: Debjitdj/sync-soc
def add_event():
    community_name = request.args.get('name')

    year = request.args.get('year')
    month = request.args.get('month')
    day = request.args.get('day')
    try:
        date = datetime.date(year, month, day)
    except:
        print('using default date of (2019, 10, 2)')
        date = datetime.date(2019, 10, 2)

    start_slot = request.args.get('start_slot')
    end_slot = request.args.get('end_slot')
    if community_name is None:  # test
        community_name = 'Sync Society'
        start_slot = 20
        end_slot = 25

    community = model.communities.find_one({"name": community_name})

    weekly = request.args.get('weekly')
    print(weekly)
    if not weekly:
        model.add_event(community["_id"], date, start_slot, end_slot)
    else:
        model.add_recurring_event(community["_id"], date.weekday(), start_slot,
                                  end_slot)
        print('adding recurring event')
    return jsonify(True)
示例#5
0
def test_friend_brings_item(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    model.rsvp(events, "12345", "1111", "Omer Daniel", 2)
    model.add_items_to_event(events, "12345", "bamba")
    model.friend_brings_item(events, "12345", "1111", "bamba")
    res = model.get_event(events, "12345")
    assert res['participants'][0]['brings'][0] == "bamba"
示例#6
0
def test_get_items(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    model.add_items_to_event(events, "12345", "bamba")
    model.add_items_to_event(events, "12345", "bisli")
    model.add_items_to_event(events, "12345", "cola")
    res = model.get_items(events, "12345")
    assert len(res[0]) == 0
    assert len(res[1]) == 3
def loadEvents(analyzer):
    """
    Carga los eventos del archivo.  Por cada evento se toman sus características y por
    cada uno de ellos, se crea en la lista y árboles bianrios para 
    las categorías específicas
    """

    context_file = cf.data_dir + 'context_content_features-small.csv'
    input_file = csv.DictReader(open(context_file, encoding="utf-8"),
                                delimiter=",")

    for event in input_file:
        for key, value in event.items():
            event[key] = conv(value)
        model.add_event(analyzer, event)
示例#8
0
        def post(self):
            unique_id = str(uuid.uuid4())

            event_str = flask.request.stream.read()
            event = json.loads(event_str)
            event["id"] = unique_id

            if not "date" in event:
                event["date"] = time.time()

            if not "family" in event:
                event["family"] = "nofamily"

            socket.emit("event", event, namespace="/default")

            model.add_event(event)

            return unique_id
示例#9
0
def event_created(update: Update, context: CallbackContext):
    chat_id = update.effective_chat.id
    text = update.message.text
    event_id = str(uuid.uuid1())
    context.bot.send_message(
        chat_id=chat_id,
        text=" Event created ! share the following message with your friends:")
    context.bot.send_message(
        chat_id=chat_id,
        text=
        f"You are invited to {text} click here to RSVP:  t.me/event_handler_bot?start={event_id}"
    )
    context.bot.send_message(
        chat_id=chat_id,
        text=
        "if you want to tell your friend to bring items, just write it down")
    name = f"{update.effective_chat['first_name']} {update.effective_chat['last_name']}"
    model.add_event(events_collection, event_id, text, name)
    model.add_event_to_user(user_events_collection, chat_id, event_id)
    return GET_ITEMS
示例#10
0
def load_events1(catalog):
    eventsfile = cf.data_dir + 'subsamples-small/context_content_features-small.csv'
    input_file = csv.DictReader(open(eventsfile, encoding='utf-8'))
    for event in input_file:
        model.add_event(catalog, event)
示例#11
0
def test_get_participants(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    model.rsvp(events, "12345", "1111", "Omer Daniel", 1)
    res = model.get_participants(events, "12345")
    assert res[0]['user_id'] == "1111"
示例#12
0
def test_get_last_event(user_events):
    model.add_event(user_events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    model.add_event_to_user(user_events, "1111", "12345")
    res = model.get_last_event(user_events, "1111")
    assert res == "12345"
示例#13
0
def test_create_event(events):
    model.add_event(events, "12345", "Orel Birthday at ashkelon 7/2/2020",
                    "Omer Daniel")
    event = model.get_event(events, "12345")
    assert event['description'] == "Orel Birthday at ashkelon 7/2/2020"