Skip to content

Commit

Permalink
Add ability to store arbitrary user fields in test user model
Browse files Browse the repository at this point in the history
  • Loading branch information
nickcatal committed Sep 30, 2015
1 parent aa66b83 commit 15d75da
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions social/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class User(BaseModel):
cache = {}
_is_active = True

def __init__(self, username, email=None):
def __init__(self, username, email=None, **extra_user_fields):
self.id = User.next_id()
self.username = username
self.email = email
self.password = None
self.slug = None
self.social = []
self.extra_data = {}
self.extra_user_fields = extra_user_fields
self.save()

def is_active(self):
Expand Down Expand Up @@ -100,8 +101,8 @@ def user_exists(cls, username):
return User.cache.get(username) is not None

@classmethod
def create_user(cls, username, email=None):
return User(username=username, email=email)
def create_user(cls, username, email=None, **extra_user_fields):
return User(username=username, email=email, **extra_user_fields)

@classmethod
def get_user(cls, pk):
Expand Down

0 comments on commit 15d75da

Please sign in to comment.