Permalink
Browse files

Remove features for interacting with test users.

This is indisputably a really helpful feature, but doesn't really fit
with the rest of the library (which have no abstractions). I've moved it
to feature/test-users pending a design decision.
  • Loading branch information...
1 parent 72db24e commit ab1a81e08dbdcbb5e7ed51637240989d9922f7f5 @jgorset committed Oct 4, 2012
Showing with 0 additions and 149 deletions.
  1. +0 −20 docs/source/usage/test-users.rst
  2. +0 −49 facepy/test.py
  3. +0 −80 tests/test_test.py
@@ -1,20 +0,0 @@
-.. _test-users:
-
-Test users
-==========
-
-You may manage test users using the ``User`` class of the ``test`` module::
-
- from facepy.test import User
-
- user = User.create(application_id, application_access_token,
- name = 'John Doe',
- permissions = ['read_stream', 'publish_stream']
- )
-
-.. autoclass:: facepy.test.User
- :members: create, delete
-
-.. admonition:: See also
-
- `Facebook's documentation on test users <http://developers.facebook.com/docs/test_users>`_
View
@@ -1,49 +0,0 @@
-from facepy import GraphAPI
-
-
-class User(object):
- """Instances of the User class represent Facebook test users."""
-
- def __init__(self, id, access_token, login_url, email, password):
- """
- Initialize a Facebook test user.
-
- :param id: A string describing the user's Facebook ID.
- :param access_token: A string describing the user's access token.
- :param login_url: A string describing the user's login URL.
- :param email: A string describing the user's email.
- :param password: A string describing the user's password.
- """
- self.id = id
- self.access_token = access_token
- self.login_url = login_url
- self.email = email
- self.password = password
-
- self.graph = GraphAPI(access_token)
-
- @classmethod
- def create(self, application_id, access_token, **parameters):
- """
- Create a new Facebook test user.
-
- :param application_id: A string describing the Facebook application ID.
- :param access_token: A string describing the application's access token.
- :param name: An optional string describing the user's name (defaults to a generated name).
- :param permissions: An optional list describing permissions.
- :param locale: An optional string describing the user's locale (defaults to ``en_US``).
- :param installed: A boolean describing whether the user has installed your application (defaults to ``True``).
- """
- return User(**GraphAPI(access_token).post('%s/accounts/test-users' % application_id, **parameters))
-
- def delete(self):
- """
- Delete the test user.
- """
- self.graph.delete(self.id)
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args, **kwargs):
- self.delete()
View
@@ -1,80 +0,0 @@
-"""Tests for the ``test`` module."""
-
-from nose.tools import *
-from mock import patch, DEFAULT
-
-from facepy.test import *
-
-
-@patch('facepy.GraphAPI.post')
-def test_create_user(post):
- """Test creating a new test user."""
- response = {
- 'id': '<id>',
- 'access_token': '<access token>',
- 'login_url': '<login url>',
- 'email': '<email>',
- 'password': '<password>'
- }
-
- post.return_value = response
-
- user = User.create(
- '<application id>',
- '<access token>',
- permissions=['read_stream'],
- locale='en_US',
- name='John Doe',
- installed=True
- )
-
- post.assert_called_with(
- '<application id>/accounts/test-users',
- permissions=['read_stream'],
- locale='en_US',
- name='John Doe',
- installed=True
- )
-
- assert_equal(user.id, response['id'])
- assert_equal(user.access_token, response['access_token'])
- assert_equal(user.login_url, response['login_url'])
- assert_equal(user.email, response['email'])
- assert_equal(user.password, response['password'])
-
-
-@patch.multiple('facepy.GraphAPI', post=DEFAULT, delete=DEFAULT)
-def test_context_manager(post, delete):
- """Test creating and deleting users in a context."""
- post.return_value = {
- 'id': '<id>',
- 'access_token': '<access token>',
- 'login_url': '<login url>',
- 'email': '<email>',
- 'password': '<password>'
- }
-
- with User.create('<application id>', '<access token>') as user:
- assert_equal(user.id, post.return_value['id'])
- assert_equal(user.access_token, post.return_value['access_token'])
- assert_equal(user.login_url, post.return_value['login_url'])
- assert_equal(user.email, post.return_value['email'])
- assert_equal(user.password, post.return_value['password'])
-
- delete.assert_called_with(post.return_value['id'])
-
-
-@patch('facepy.GraphAPI.delete')
-def test_delete_user(delete):
- """Test deleting a test user."""
- user = User(
- id='<id>',
- access_token='<access token>',
- login_url='<login url>',
- email='<email>',
- password='<password'
- )
-
- user.delete()
-
- delete.assert_called_with('<id>')

0 comments on commit ab1a81e

Please sign in to comment.