This file contains hidden or 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
class AllauthGitHubTestCase(UserTestCase): | |
""" | |
Test sign-up/in flow with GitHub. | |
""" | |
localizing_client = False | |
def test_github_auth_success(self): | |
url_params = { | |
'access_token': 123456789, |
This file contains hidden or 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
@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', |
This file contains hidden or 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
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 |
This file contains hidden or 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
====================================================================== [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) |
This file contains hidden or 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
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: |
This file contains hidden or 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
bid_router = BidRouter() | |
bid_router.register(r'bids', views.BidViewSet) |
This file contains hidden or 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
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' |
This file contains hidden or 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
router = routers.DefaultRouter() | |
router.register(r'bids', views.BidViewSet) |
This file contains hidden or 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
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' |
This file contains hidden or 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
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) |