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)
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)
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)
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)
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()
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)