예제 #1
0
파일: services_test.py 프로젝트: djcun95/h
    def test_flag_adds_record_to_database(self, db_session):
        svc = NipsaService(db_session)

        svc.flag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(userid='acct:[email protected]')
        assert user_query.one_or_none() is not None
예제 #2
0
파일: services_test.py 프로젝트: djcun95/h
    def test_unflag_removes_record_from_database(self, db_session):
        svc = NipsaService(db_session)

        svc.unflag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(userid='acct:[email protected]')
        assert user_query.one_or_none() is None
예제 #3
0
파일: services_test.py 프로젝트: djcun95/h
    def test_unflag_is_idempotent(self, db_session):
        svc = NipsaService(db_session)

        svc.unflag('acct:[email protected]')
        svc.unflag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(userid='acct:[email protected]')
        assert user_query.one_or_none() is None
예제 #4
0
    def test_unflag_removes_record_from_database(self, db_session):
        svc = NipsaService(db_session)

        svc.unflag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(
            userid='acct:[email protected]')
        assert user_query.one_or_none() is None
예제 #5
0
    def test_flag_adds_record_to_database(self, db_session):
        svc = NipsaService(db_session)

        svc.flag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(
            userid='acct:[email protected]')
        assert user_query.one_or_none() is not None
예제 #6
0
    def test_unflag_is_idempotent(self, db_session):
        svc = NipsaService(db_session)

        svc.unflag('acct:[email protected]')
        svc.unflag('acct:[email protected]')

        user_query = db_session.query(NipsaUser).filter_by(
            userid='acct:[email protected]')
        assert user_query.one_or_none() is None
예제 #7
0
    def test_flagged_userids_returns_list_of_userids(self, db_session):
        svc = NipsaService(db_session)

        assert set(svc.flagged_userids) == set([
            'acct:[email protected]', 'acct:[email protected]',
            'acct:[email protected]'
        ])
예제 #8
0
파일: messages.py 프로젝트: zermelozf/h
def handle_annotation_event(message, sockets, session):
    id_ = message['annotation_id']
    annotation = storage.fetch_annotation(session, id_)

    # FIXME: It isn't really nice to try and get the userid from the fetched
    # annotation or otherwise get it from the maybe-already serialized
    # annotation dict, to then only access the database for the nipsa flag once.
    # We do this because the event action is `delete` at which point we can't
    # load the annotation from the database. Handling annotation deletions is
    # a known problem and will be fixed in the future.
    userid = None
    if annotation:
        userid = annotation.userid
    else:
        userid = message.get('annotation_dict', {}).get('userid')
    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(userid)

    for socket in sockets:
        reply = _generate_annotation_event(message, socket, annotation, user_nipsad)
        if reply is None:
            continue
        socket.send_json(reply)
예제 #9
0
파일: services_test.py 프로젝트: djcun95/h
    def test_is_flagged_returns_false_for_unflagged_userids(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged('acct:[email protected]')
        assert not svc.is_flagged('acct:[email protected]')
예제 #10
0
파일: services_test.py 프로젝트: djcun95/h
    def test_is_flagged_returns_true_for_flagged_userids(self, db_session):
        svc = NipsaService(db_session)

        assert svc.is_flagged('acct:[email protected]')
        assert svc.is_flagged('acct:[email protected]')
예제 #11
0
    def test_is_flagged_returns_false_for_unflagged_userids(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged('acct:[email protected]')
        assert not svc.is_flagged('acct:[email protected]')
예제 #12
0
    def test_is_flagged_returns_true_for_flagged_userids(self, db_session):
        svc = NipsaService(db_session)

        assert svc.is_flagged('acct:[email protected]')
        assert svc.is_flagged('acct:[email protected]')
예제 #13
0
파일: services_test.py 프로젝트: nlisgo/h
    def test_unflag_triggers_remove_nipsa_job(self, db_session, users, worker):
        svc = NipsaService(db_session)

        svc.unflag(users['renata'])

        worker.remove_nipsa.delay.assert_called_once_with('acct:[email protected]')
예제 #14
0
파일: services_test.py 프로젝트: nlisgo/h
    def test_unflag_sets_nipsa_false(self, db_session, users):
        svc = NipsaService(db_session)

        svc.unflag(users['renata'])

        assert users['renata'].nipsa is False
예제 #15
0
파일: services_test.py 프로젝트: nlisgo/h
    def test_flag_triggers_add_nipsa_job(self, db_session, users, worker):
        svc = NipsaService(db_session)

        svc.flag(users['dominic'])

        worker.add_nipsa.delay.assert_called_once_with('acct:[email protected]')
예제 #16
0
파일: services_test.py 프로젝트: nlisgo/h
    def test_flag_sets_nipsa_true(self, db_session, users):
        svc = NipsaService(db_session)

        svc.flag(users['dominic'])

        assert users['dominic'].nipsa is True