コード例 #1
0
    def test_flag_sets_nipsa_true(self, db_session, users):
        svc = NipsaService(db_session)

        svc.flag(users["dominic"])

        assert svc.is_flagged("acct:[email protected]")
        assert users["dominic"].nipsa is True
コード例 #2
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_flag_sets_nipsa_true(self, db_session, users):
        svc = NipsaService(db_session)

        svc.flag(users["dominic"])

        assert svc.is_flagged("acct:[email protected]")
        assert users["dominic"].nipsa is True
コード例 #3
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_unflag_sets_nipsa_false(self, db_session, users):
        svc = NipsaService(db_session)

        svc.unflag(users["renata"])

        assert not svc.is_flagged("acct:[email protected]")
        assert users["renata"].nipsa is False
コード例 #4
0
    def test_unflag_sets_nipsa_false(self, db_session, users):
        svc = NipsaService(db_session)

        svc.unflag(users["renata"])

        assert not svc.is_flagged("acct:[email protected]")
        assert users["renata"].nipsa is False
コード例 #5
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_unflag_updates_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        svc.unflag(users["renata"])
        users["renata"].nipsa = True  # Make sure result below comes from cache.

        assert not svc.is_flagged(users["renata"].userid)
コード例 #6
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_flag_updates_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        svc.flag(users["dominic"])
        users["dominic"].nipsa = False  # Make sure result below comes from cache.

        assert svc.is_flagged(users["dominic"].userid)
コード例 #7
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_clear_resets_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        users["renata"].nipsa = False
        svc.clear()

        assert not svc.is_flagged("acct:[email protected]")
コード例 #8
0
    def test_clear_resets_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        users["renata"].nipsa = False
        svc.clear()

        assert not svc.is_flagged("acct:[email protected]")
コード例 #9
0
    def test_flag_updates_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        svc.flag(users["dominic"])
        users[
            "dominic"].nipsa = False  # Make sure result below comes from cache.

        assert svc.is_flagged(users["dominic"].userid)
コード例 #10
0
    def test_unflag_updates_cache(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        svc.unflag(users["renata"])
        users[
            "renata"].nipsa = True  # Make sure result below comes from cache.

        assert not svc.is_flagged(users["renata"].userid)
コード例 #11
0
    def test_fetch_all_flagged_userids_caches_lookup(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        users['renata'].nipsa = False

        # Returns `True` because status is cached.
        assert svc.is_flagged('acct:[email protected]')
        assert svc.fetch_all_flagged_userids() == set(
            ['acct:[email protected]', 'acct:[email protected]'])
コード例 #12
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_fetch_all_flagged_userids_caches_lookup(self, db_session, users):
        svc = NipsaService(db_session)

        svc.fetch_all_flagged_userids()
        users["renata"].nipsa = False

        # Returns `True` because status is cached.
        assert svc.is_flagged("acct:[email protected]")
        assert svc.fetch_all_flagged_userids() == set(
            ["acct:[email protected]", "acct:[email protected]"]
        )
コード例 #13
0
def handle_annotation_event(message, sockets, session):
    id_ = message['annotation_id']
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warn('received annotation event for missing annotation: %s', id_)
        return

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    for socket in sockets:
        reply = _generate_annotation_event(message, socket, annotation, user_nipsad)
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #14
0
def handle_annotation_event(message, sockets, settings, session):
    id_ = message['annotation_id']
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warn('received annotation event for missing annotation: %s', id_)
        return

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    authority = text_type(settings.get('h.authority', 'localhost'))
    group_service = GroupfinderService(session, authority)

    for socket in sockets:
        reply = _generate_annotation_event(message, socket, annotation, user_nipsad, group_service)
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #15
0
ファイル: messages.py プロジェクト: chinmaygghag/h
def handle_annotation_event(message, sockets, settings, session):
    id_ = message['annotation_id']
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warn('received annotation event for missing annotation: %s', id_)
        return

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    authority = text_type(settings.get('h.authority', 'localhost'))
    group_service = GroupfinderService(session, authority)

    for socket in sockets:
        reply = _generate_annotation_event(message, socket, annotation, user_nipsad, group_service)
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #16
0
ファイル: messages.py プロジェクト: hypothesis/h
def handle_annotation_event(message, sockets, settings, session):
    id_ = message["annotation_id"]
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warning("received annotation event for missing annotation: %s", id_)
        return

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    authority = text_type(settings.get("h.authority", "localhost"))
    group_service = GroupfinderService(session, authority)
    user_service = UserService(authority, session)
    formatters = [AnnotationUserInfoFormatter(session, user_service)]

    for socket in sockets:
        reply = _generate_annotation_event(
            message, socket, annotation, user_nipsad, group_service, formatters
        )
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #17
0
def handle_annotation_event(message, sockets, settings, session):
    id_ = message["annotation_id"]
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warning("received annotation event for missing annotation: %s",
                    id_)
        return

    # Find connected clients which are interested in this annotation.
    matching_sockets = SocketFilter.matching(sockets, annotation)

    try:
        # Check to see if the generator has any items
        first_socket = next(matching_sockets)
    except StopIteration:
        # Nothing matched
        return

    # Create a generator which has the first socket back again
    matching_sockets = chain((first_socket, ), matching_sockets)

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    authority = settings.get("h.authority", "localhost")
    group_service = GroupfinderService(session, authority)
    user_service = UserService(authority, session)
    formatters = [AnnotationUserInfoFormatter(session, user_service)]

    for socket in matching_sockets:
        reply = _generate_annotation_event(message, socket, annotation,
                                           user_nipsad, group_service,
                                           formatters)
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #18
0
ファイル: messages.py プロジェクト: julien-cheng/h
def handle_annotation_event(message, sockets, settings, session):
    id_ = message["annotation_id"]
    annotation = storage.fetch_annotation(session, id_)

    if annotation is None:
        log.warning("received annotation event for missing annotation: %s",
                    id_)
        return

    nipsa_service = NipsaService(session)
    user_nipsad = nipsa_service.is_flagged(annotation.userid)

    authority = text_type(settings.get("h.authority", "localhost"))
    group_service = GroupfinderService(session, authority)
    user_service = UserService(authority, session)
    formatters = [AnnotationUserInfoFormatter(session, user_service)]

    for socket in sockets:
        reply = _generate_annotation_event(message, socket, annotation,
                                           user_nipsad, group_service,
                                           formatters)
        if reply is None:
            continue
        socket.send_json(reply)
コード例 #19
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_is_flagged_returns_false_for_unknown_users(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged("acct:[email protected]")
コード例 #20
0
    def test_is_flagged_returns_false_for_unknown_users(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged("acct:[email protected]")
コード例 #21
0
    def test_is_flagged_returns_false_for_unflagged_users(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged("acct:[email protected]")
コード例 #22
0
    def test_is_flagged_returns_true_for_flagged_users(self, db_session,
                                                       users):
        svc = NipsaService(db_session)

        assert svc.is_flagged("acct:[email protected]")
        assert svc.is_flagged("acct:[email protected]")
コード例 #23
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_is_flagged_returns_false_for_unflagged_users(self, db_session):
        svc = NipsaService(db_session)

        assert not svc.is_flagged("acct:[email protected]")
        assert not svc.is_flagged("acct:[email protected]")
コード例 #24
0
ファイル: nipsa_test.py プロジェクト: hypothesis/h
    def test_is_flagged_returns_true_for_flagged_users(self, db_session, users):
        svc = NipsaService(db_session)

        assert svc.is_flagged("acct:[email protected]")
        assert svc.is_flagged("acct:[email protected]")