예제 #1
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_looks_up_users_by_username(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"}, es=es)

    views.users_index(request)

    User.get_by_username.assert_called_with("bob")
예제 #2
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_queries_annotation_count_by_userid(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"}, es=es)

    User.get_by_username.return_value.username = '******'

    views.users_index(request)

    expected_query = {
        'query': {
            'filtered': {
                'filter': {
                    'term': {
                        'user': u'acct:[email protected]'
                    }
                },
                'query': {
                    'match_all': {}
                }
            }
        }
    }
    es.conn.count.assert_called_with(index=es.index,
                                     doc_type=es.t.annotation,
                                     body=expected_query)
예제 #3
0
파일: users_test.py 프로젝트: ficolo/h
def test_users_index_looks_up_users_by_username(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"},
                           es=es)

    views.users_index(request)

    User.get_by_username.assert_called_with("bob")
예제 #4
0
def test_users_index_looks_up_users_by_email(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    views.users_index(pyramid_request)

    models.User.get_by_email.assert_called_with(pyramid_request.db, "*****@*****.**", "foo.org")
예제 #5
0
def test_users_index_strips_spaces(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "   foo.org    "}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    views.users_index(pyramid_request)

    models.User.get_by_username.assert_called_with(pyramid_request.db, "bob", "foo.org")
예제 #6
0
def test_users_index_strips_spaces(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "   foo.org    "}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    views.users_index(pyramid_request)

    models.User.get_by_username.assert_called_with(pyramid_request.db, "bob", "foo.org")
예제 #7
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index_looks_up_users_by_email(User, pyramid_request):
    pyramid_request.params = {"username": "******"}

    User.get_by_username.return_value = None

    views.users_index(pyramid_request)

    User.get_by_email.assert_called_with(pyramid_request.db, "*****@*****.**")
예제 #8
0
def test_users_index_looks_up_users_by_email(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    views.users_index(pyramid_request)

    models.User.get_by_email.assert_called_with(pyramid_request.db, "*****@*****.**", "foo.org")
예제 #9
0
def test_users_index_looks_up_users_by_email(User, pyramid_request):
    pyramid_request.params = {"username": "******"}
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    views.users_index(pyramid_request)

    User.get_by_email.assert_called_with(pyramid_request.db, "*****@*****.**")
예제 #10
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_looks_up_users_by_email(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"}, es=es)

    User.get_by_username.return_value = None

    views.users_index(request)

    User.get_by_email.assert_called_with("*****@*****.**")
예제 #11
0
def test_users_index_looks_up_users_by_email(User):
    request = DummyRequest(db=mock.sentinel.db_session,
                           es=MagicMock(),
                           params={"username": "******"})

    User.get_by_username.return_value = None

    views.users_index(request)

    User.get_by_email.assert_called_with(mock.sentinel.db_session, "*****@*****.**")
예제 #12
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_looks_up_users_by_email(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"},
                           es=es)

    User.get_by_username.return_value = None

    views.users_index(request)

    User.get_by_email.assert_called_with("*****@*****.**")
예제 #13
0
def test_users_index_queries_annotation_count_by_userid(models, factories, pyramid_request, annotation_stats_service):
    user = factories.User.build(username='******')
    models.User.get_by_username.return_value = user
    annotation_stats_service.user_annotation_counts.return_value = {'total': 8}

    pyramid_request.params = {"username": "******", "authority": user.authority}
    result = views.users_index(pyramid_request)
    assert result['user_meta']['annotations_count'] == 8
예제 #14
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index_no_user_found(User, pyramid_request):
    pyramid_request.params = {"username": "******"}
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    result = views.users_index(pyramid_request)

    assert result == {'username': "******", 'user': None, 'user_meta': {}}
예제 #15
0
def test_users_index_no_user_found(User, pyramid_request):
    pyramid_request.params = {"username": "******"}
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    result = views.users_index(pyramid_request)

    assert result == {'username': "******", 'user': None, 'user_meta': {}}
예제 #16
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_no_user_found(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"}, es=es)
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    result = views.users_index(request)

    assert result == {'username': "******", 'user': None, 'user_meta': {}}
예제 #17
0
파일: users_test.py 프로젝트: ackermann/h
def test_users_index_no_user_found(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"},
                           es=es)
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    result = views.users_index(request)

    assert result == {'username': "******", 'user': None, 'user_meta': {}}
예제 #18
0
파일: users_test.py 프로젝트: pombredanne/h
def test_users_index_queries_annotation_count_by_userid(User, db_session, factories, pyramid_request):
    User.get_by_username.return_value = factories.User(username='******')
    userid = "acct:bob@{}".format(pyramid_request.auth_domain)
    for _ in xrange(8):
        db_session.add(factories.Annotation(userid=userid))
    db_session.flush()

    pyramid_request.params = {"username": "******"}
    result = views.users_index(pyramid_request)
    assert result['user_meta']['annotations_count'] == 8
예제 #19
0
def test_users_index(pyramid_request):
    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': pyramid_request.auth_domain,
        'username': None,
        'authority': None,
        'user': None,
        'user_meta': {},
    }
예제 #20
0
def test_users_index(pyramid_request):
    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': pyramid_request.auth_domain,
        'username': None,
        'authority': None,
        'user': None,
        'user_meta': {},
    }
예제 #21
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index_queries_annotation_count_by_userid(User, pyramid_request):
    pyramid_request.params = {"username": "******"}
    es = pyramid_request.es

    User.get_by_username.return_value.username = '******'

    views.users_index(pyramid_request)

    expected_query = {
        'query': {
            'filtered': {
                'filter': {'term': {'user': u'acct:[email protected]'}},
                'query': {'match_all': {}}
            }
        }
    }
    es.conn.count.assert_called_with(index=es.index,
                                     doc_type=es.t.annotation,
                                     body=expected_query)
예제 #22
0
def test_users_index_no_user_found(User):
    request = DummyRequest(db=mock.sentinel.db_session,
                           es=MagicMock(),
                           params={"username": "******"})
    User.get_by_username.return_value = None
    User.get_by_email.return_value = None

    result = views.users_index(request)

    assert result == {'username': "******", 'user': None, 'user_meta': {}}
예제 #23
0
파일: users_test.py 프로젝트: pombredanne/h
def test_users_index_user_found(User, pyramid_request, db_session, factories):
    pyramid_request.params = {"username": "******"}
    user = User.get_by_username.return_value = factories.User(username='******')

    result = views.users_index(pyramid_request)

    assert result == {
        'username': "******",
        'user': user,
        'user_meta': {'annotations_count': 0},
    }
예제 #24
0
파일: users_test.py 프로젝트: ficolo/h
def test_users_index_queries_annotation_count_by_userid(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"},
                           es=es)

    User.get_by_username.return_value.username = '******'

    views.users_index(request)

    expected_query = {
        'query': {
            'filtered': {
                'filter': {'term': {'user': u'acct:[email protected]'}},
                'query': {'match_all': {}}
            }
        }
    }
    es.conn.count.assert_called_with(index=es.index,
                                     doc_type=es.t.annotation,
                                     body=expected_query)
예제 #25
0
def test_users_index_queries_annotation_count_by_userid(
        User, db_session, factories, pyramid_request):
    User.get_by_username.return_value = factories.User(username='******')
    userid = "acct:bob@{}".format(pyramid_request.auth_domain)
    for _ in xrange(8):
        db_session.add(factories.Annotation(userid=userid))
    db_session.flush()

    pyramid_request.params = {"username": "******"}
    result = views.users_index(pyramid_request)
    assert result['user_meta']['annotations_count'] == 8
예제 #26
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index_user_found(User, pyramid_request):
    pyramid_request.params = {"username": "******"}
    pyramid_request.es.conn.count.return_value = {'count': 43}

    result = views.users_index(pyramid_request)

    assert result == {
        'username': "******",
        'user': User.get_by_username.return_value,
        'user_meta': {'annotations_count': 43},
    }
예제 #27
0
def test_users_index_user_found(User, pyramid_request, db_session, factories):
    pyramid_request.params = {"username": "******"}
    user = User.get_by_username.return_value = factories.User(username='******')

    result = views.users_index(pyramid_request)

    assert result == {
        'username': "******",
        'user': user,
        'user_meta': {
            'annotations_count': 0
        },
    }
예제 #28
0
def test_users_index_user_found(User):
    es = MagicMock()
    request = DummyRequest(params={"username": "******"},
                           es=es)
    es.conn.count.return_value = {'count': 43}

    result = views.users_index(request)

    assert result == {
        'username': "******",
        'user': User.get_by_username.return_value,
        'user_meta': {'annotations_count': 43},
    }
예제 #29
0
def test_users_index_no_user_found(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': "example.com",
        'username': "******",
        'authority': "foo.org",
        'user': None,
        'user_meta': {}
    }
예제 #30
0
def test_users_index_user_found(models, pyramid_request, db_session, factories):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    user = factories.User.build(username='******', authority='foo.org')
    models.User.get_by_username.return_value = user

    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': "example.com",
        'username': "******",
        'authority': "foo.org",
        'user': user,
        'user_meta': {'annotations_count': 0},
    }
예제 #31
0
def test_users_index_no_user_found(models, pyramid_request):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    models.User.get_by_username.return_value = None
    models.User.get_by_email.return_value = None

    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': "example.com",
        'username': "******",
        'authority': "foo.org",
        'user': None,
        'user_meta': {}
    }
예제 #32
0
def test_users_index_user_found(models, pyramid_request, db_session, factories):
    pyramid_request.params = {"username": "******", "authority": "foo.org"}
    user = models.User.get_by_username.return_value = factories.User(username='******',
                                                                     authority='foo.org')

    result = views.users_index(pyramid_request)

    assert result == {
        'default_authority': "example.com",
        'username': "******",
        'authority': "foo.org",
        'user': user,
        'user_meta': {'annotations_count': 0},
    }
예제 #33
0
def test_users_index():
    request = DummyRequest()

    result = views.users_index(request)

    assert result == {'username': None, 'user': None, 'user_meta': {}}
예제 #34
0
def test_users_index(pyramid_request):
    result = views.users_index(pyramid_request)

    assert result == {'username': None, 'user': None, 'user_meta': {}}
예제 #35
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index_looks_up_users_by_username(User, pyramid_request):
    pyramid_request.params = {"username": "******"}

    views.users_index(pyramid_request)

    User.get_by_username.assert_called_with(pyramid_request.db, "bob")
예제 #36
0
파일: users_test.py 프로젝트: djcun95/h
def test_users_index(pyramid_request):
    result = views.users_index(pyramid_request)

    assert result == {'username': None, 'user': None, 'user_meta': {}}