forked from rafalp/Misago
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tried to add test for logged in user, but sinche Misago does not use Django auth, it becomes a bit complicated to test authenticated users. Probably I will have to extend django webtest and add cutom logic there to make authenticated users testing work.
- Loading branch information
Showing
8 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import factory | ||
import factory.django | ||
|
||
|
||
class ForumFactory(factory.django.DjangoModelFactory): | ||
slug = 'first-forum' | ||
|
||
class Meta: | ||
model = 'misago.Forum' | ||
django_get_or_create = ('slug',) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.core.management import call_command | ||
|
||
from django_webtest import WebTest | ||
|
||
from misago.factories.forummodel import ForumFactory | ||
|
||
|
||
class ForumListTests(WebTest): | ||
|
||
def test_forum_list_annonymous(self): | ||
call_command('syncfixtures', quiet=1) | ||
|
||
forum = ForumFactory() | ||
|
||
resp = self.app.get('/forum/%s-%d/' % (forum.slug, forum.pk)) | ||
resp.mustcontain('First Forum') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import faker | ||
|
||
|
||
class FakerFactoryBoyWrapper(object): | ||
"""Small wrapper around faker for factory boy. | ||
Usage: | ||
>>> from factory import LazyAttribute | ||
>>> from pylab.core.helpers.factories import fake | ||
>>> LazyAttribute(fake.company()) # doctest: +ELLIPSIS | ||
<factory.declarations.LazyAttribute object at 0x...> | ||
""" | ||
|
||
def __init__(self): | ||
self.faker = faker.Factory.create() | ||
|
||
def __getattr__(self, name): | ||
faker_method = getattr(self.faker, name) | ||
|
||
def wrapper(*args, **kwargs): | ||
def func(obj=None): # pylint: disable=unused-argument | ||
return faker_method(*args, **kwargs) | ||
return func | ||
|
||
return wrapper | ||
|
||
|
||
fake = FakerFactoryBoyWrapper() # pylint: disable=invalid-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ whoosh<2.6 | |
coverage | ||
django-nose | ||
django-webtest | ||
factory_boy | ||
fake-factory |