예제 #1
0
def test_delete_meeting_request(app, monkeypatch, database, fake_user):

    monkeypatch.setattr(meeting_requests, 'get_user', lambda: fake_user)

    meeting_spec_key = database.specs[0].key.urlsafe()
    meeting_request = MeetingRequest(
        meeting_spec=database.specs[0].key,
        user=fake_user.key
    )
    meeting_request_key = meeting_request.put()
    meeting_request_key = meeting_request_key.urlsafe()
    requests = MeetingRequest.query().fetch()
    assert len(requests) == 1

    with app.test_request_context(
            '/v1/meeting_request/',
            method='POST',
            data=json.dumps({
                'meeting_spec_key': meeting_spec_key,
                'meeting_request_key': meeting_request_key
            }),
            content_type='application/json'
    ):
        response = create_delete_meeting_request()
        assert json.loads(response) == {'key': ''}

    requests = MeetingRequest.query().fetch()
    assert len(requests) == 0
예제 #2
0
def test_get_meeting_request_no_exist(app, monkeypatch, database, fake_user):
    monkeypatch.setattr(meeting_requests, 'get_user', lambda: fake_user)

    meeting_spec_key = database.specs[0].key.urlsafe()
    requests = MeetingRequest.query().fetch()
    assert len(requests) == 0

    with app.test_request_context('/v1/meeting_request/' + meeting_spec_key):
        response = get_meeting_request(meeting_spec_key)
        assert json.loads(response) == {'key': ''}
예제 #3
0
def get_meeting_requests():
    requests = []
    for spec in get_specs_for_current_week():
        users = [
            request.user.get().email for request in MeetingRequest.query(
                MeetingRequest.meeting_spec == spec.key).fetch()
        ]
        for user in users:
            requests.append({
                'title': spec.meeting_subscription.get().title,
                'user': user,
            })
    return requests
예제 #4
0
def test_get_meeting_request(app, monkeypatch, database, fake_user):
    monkeypatch.setattr(meeting_requests, 'get_user', lambda (x): fake_user)

    meeting_spec_key = database.specs[0].key.urlsafe()
    meeting_request = MeetingRequest(meeting_spec=database.specs[0].key,
                                     user=fake_user.key)
    meeting_request_key = meeting_request.put()
    requests = MeetingRequest.query().fetch()
    assert len(requests) == 1

    with app.test_request_context('/v1/meeting_request/' + meeting_spec_key):
        response = get_meeting_request(meeting_spec_key).json
        assert response == {'key': meeting_request_key.urlsafe()}
예제 #5
0
파일: tasks.py 프로젝트: tomaszandel/beans
def match_employees():
    specs = get_specs_for_current_week()

    for spec in specs:
        logging.info('Spec Datetime: ')
        logging.info(get_meeting_datetime(spec).strftime("%Y-%m-%d %H:%M"))

        users = [
            request.user.get() for request in MeetingRequest.query(
                MeetingRequest.meeting_spec == spec.key).fetch()
        ]
        logging.info('Users: ')
        logging.info([user.get_username() for user in users])

        matches, unmatched = generate_meetings(users, spec)
        save_meetings(matches, spec)

        send_batch_unmatched_email(unmatched)
        send_batch_meeting_confirmation_email(matches, spec)
    return "OK"
예제 #6
0
def test_create_meeting_request(app, monkeypatch, database, fake_user):

    monkeypatch.setattr(meeting_requests, 'get_user', lambda (x): fake_user)

    meeting_spec_key = database.specs[0].key.urlsafe()
    with app.test_request_context('/v1/meeting_request/',
                                  method='POST',
                                  data=json.dumps({
                                      'meeting_spec_key': meeting_spec_key,
                                      'meeting_request_key': '',
                                      'email': fake_user.email
                                  }),
                                  content_type='application/json'):
        response = create_delete_meeting_request().json
        assert response['key'] != ''

    requests = MeetingRequest.query().fetch()
    assert len(requests) == 1
    assert requests[0].user == fake_user.key
    assert requests[0].meeting_spec == database.specs[0].key