Пример #1
0
def test_manager_connection_assignment():
    cn_without_jon = connect(email='foo', token='bar', name='without_jon')
    cn_with_jon = connect(email='foo', token='bar', name='with_jon')

    cn_without_jon.session = MockSession(urls={})
    cn_with_jon.session = MockSession(urls={
        cn_with_jon.build_absolute_url('people/1/'): load_fixture_json('person.json')  # noqa
    })

    jon = Person.objects.use('with_jon').get(id=1)
    assert_is_jon(jon)
    with assert_raises(exceptions.ApiError):
        jon = Person.objects.use('without_jon').get(id=1)
Пример #2
0
def test_manager_connection_assignment():
    cn_without_jon = connect(email='foo', token='bar', name='without_jon')
    cn_with_jon = connect(email='foo', token='bar', name='with_jon')

    cn_without_jon.session = MockSession(urls={})
    cn_with_jon.session = MockSession(
        urls={
            cn_with_jon.build_absolute_url('people/1/'):
            load_fixture_json('person.json')  # noqa
        })

    jon = Person.objects.use('with_jon').get(id=1)
    assert_is_jon(jon)
    with assert_raises(exceptions.ApiError):
        jon = Person.objects.use('without_jon').get(id=1)
Пример #3
0
def test_manager_get():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(urls={
        cn.build_absolute_url('people/1/'): load_fixture_json('person.json')
    })
    jon = Person.objects.get(id=1)
    assert_is_jon(jon)
Пример #4
0
def test_get_person_by_email():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(urls={
        cn.build_absolute_url('people/fetch_by_email/'): load_fixture_json('person.json')  # noqa
    })
    person = Person.objects.get(email='*****@*****.**')
    assert_is_jon(person)
Пример #5
0
def test_id_or_email_required_for_person():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(urls={
        cn.build_absolute_url('people/1/'): load_fixture_json('person.json')
    })
    with assert_raises(exceptions.ProspyrException):
        Person.objects.get()
Пример #6
0
def test_manager_get():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(urls={
        cn.build_absolute_url('people/1/'):
        load_fixture_json('person.json')
    })
    jon = Person.objects.get(id=1)
    assert_is_jon(jon)
Пример #7
0
def test_id_or_email_required_for_person():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(urls={
        cn.build_absolute_url('people/1/'):
        load_fixture_json('person.json')
    })
    with assert_raises(exceptions.ProspyrException):
        Person.objects.get()
Пример #8
0
def test_get_person_by_email():
    cn = connect(email='foo', token='bar')
    cn.session = MockSession(
        urls={
            cn.build_absolute_url('people/fetch_by_email/'):
            load_fixture_json('person.json')  # noqa
        })
    person = Person.objects.get(email='*****@*****.**')
    assert_is_jon(person)