Skip to content

Instantly share code, notes, and snippets.

View groovecoder's full-sized avatar

luke crouch groovecoder

View GitHub Profile
class AllauthGitHubTestCase(UserTestCase):
"""
Test sign-up/in flow with GitHub.
"""
localizing_client = False
def test_github_auth_success(self):
url_params = {
'access_token': 123456789,
@mock.patch('devmo.decorators.never_cache')
def test_views_never_cached(self, mock_never_cache):
mock_never_cache = mock.Mock()
import ipdb; ipdb.set_trace()
self.client.login(username='admin', password='testpass')
locale = settings.WIKI_DEFAULT_LANGUAGE
new_url = reverse('wiki.new_document', locale=locale)
edit_url = reverse('wiki.edit_document',
def forwards(self, orm):
"""
Switch the 'disallow_add_attachment' permission to belong to
the attachments app instead of the wiki app.
"""
from django.core.exceptions import ObjectDoesNotExist
wiki_ctype = None
disallow_permission = None
====================================================================== [54/1356]
FAIL: test_database_filter (apps.search.tests.test_filters.FilterTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/vagrant/src/apps/search/tests/test_filters.py", line 86, in test_database_filter
eq_(response.data['documents'][0]['slug'], 'le-title')
AssertionError: u'article-title' != 'le-title'
======================================================================
FAIL: test_document_serializer (apps.search.tests.test_serializers.SerializerTests)
def has_voted(self, request):
"""Did the user already vote for this document?"""
if request.user.is_authenticated():
qs = HelpfulVote.objects.filter(document=self,
creator=request.user)
elif request.anonymous.has_id:
anon_id = request.anonymous.anonymous_id
qs = HelpfulVote.objects.filter(document=self,
anonymous_id=anon_id)
else:
bid_router = BidRouter()
bid_router.register(r'bids', views.BidViewSet)
class BidRouter(routers.SimpleRouter):
""" Custom Router to allow /bids/?url= for detail view """
def __init__(self, trailing_slash=True):
self.routes.append(routers.Route(
url=r'^{prefix}/?url={lookup}{trailing_slash}$',
mapping={
'get': 'retrieve',
'put': 'update',
'patch': 'partial_update',
'delete': 'destroy'
router = routers.DefaultRouter()
router.register(r'bids', views.BidViewSet)
class BidViewSet(viewsets.ModelViewSet):
"""
API endpoint for bids. Users can create, update, retrieve, and delete
only their own bids.
url -- url of an OSS bug or issue
"""
model = Bid
serializer_class = BidSerializer
lookup_url_kwarg = 'url'
class Bid(models.Model):
user = models.ForeignKey(User)
url = models.URLField()
ask = models.DecimalField(max_digits=6, decimal_places=2)
offer = models.DecimalField(max_digits=6, decimal_places=2)