Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 160 hangouts endpoint first pass #193

Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dcbab36
Added osprojects to admin interface.
BethanyG Sep 7, 2020
31edf0f
Added osprojects to admin interface.
BethanyG Sep 7, 2020
d585cdd
Added OSProjects to admin interface.
BethanyG Sep 7, 2020
606c871
added django-res-auth and associated basic settings to test DRF and a…
BethanyG Sep 8, 2020
30936fe
Working state Mon Sept 14 - dj-rest-auth and django-allauth
BethanyG Sep 14, 2020
cdadba1
Removed django-rest-jwt and django-rest-auth added simplejwt and dj-r…
BethanyG Sep 22, 2020
782e05b
Added routes for registration and allauth.
BethanyG Sep 22, 2020
040c6f3
Added password reset email template.
BethanyG Sep 22, 2020
ef3a5ad
Added confirm_email method. Will probably remove it as uneeded later.
BethanyG Sep 22, 2020
7e6ff72
Added CustomUserDetailsSerializer. Stubbed other serializers for con…
BethanyG Sep 22, 2020
e97153b
Added routes for registration, email confirmation, password reset, lo…
BethanyG Sep 22, 2020
b6c4ac2
Added CustomVerifyEmailView to enable email verify emails from the ba…
BethanyG Sep 22, 2020
f06a74c
Added tests for registration flow, token authorization, email verific…
BethanyG Sep 22, 2020
221b7b6
Fixed tests that were failing due to auth change.
BethanyG Sep 24, 2020
e8197e7
Added final simpleJWT tests for auth.
BethanyG Sep 24, 2020
f220224
Added skips for User tests broken due to auth changes.
BethanyG Sep 24, 2020
bb47eb0
Removed django-rest_auth and django-rest-jwt from requirememts.
BethanyG Sep 24, 2020
9fd6eb7
Removed unused import that was causing an error.
BethanyG Sep 24, 2020
2670780
Removed excess space from email_confirmation_subject.txt filename.
BethanyG Sep 24, 2020
9451986
Revert "Removed excess space from email_confirmation_subject.txt file…
BethanyG Sep 24, 2020
aa6218a
Attempted to fix intermittent email verification post test failure by…
BethanyG Sep 24, 2020
f91a22d
Changed order of included URLs.
BethanyG Sep 24, 2020
a2b2b4b
Added specific path for email link verification post and changed path…
BethanyG Sep 24, 2020
569ee99
Fun trick: If your regex fails to capture all the key generations cas…
BethanyG Sep 24, 2020
35c5610
Removed print statement from email post verificaton test case.
BethanyG Sep 24, 2020
75e9461
Corrected circular reference that was breaking tests and renamed file…
BethanyG Sep 24, 2020
b2ba2c2
Removed regex from path url to avoid djang deprecation and migration …
BethanyG Sep 24, 2020
6934291
New stub files after running create app script for django.
BethanyG Sep 26, 2020
738f7c1
Registered Hangouts as an app.
BethanyG Sep 26, 2020
11c40e2
WIP for registering Hangouts in admin. Issues with properly inlining…
BethanyG Sep 26, 2020
92b8944
Inital migration file for hangouts, hangoutsessions, and hangoutrespo…
BethanyG Sep 26, 2020
afa7f25
First pass at hangouts model.
BethanyG Sep 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed tests that were failing due to auth change.
  • Loading branch information
BethanyG committed Sep 24, 2020
commit 221b7b6a142e7412c534e0aa0b46d8eb4980a9de
58 changes: 28 additions & 30 deletions project/resources/tests.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from unittest import skip
from pytest import raises
from random import randint
from rest_framework import status
from rest_framework.test import APITestCase
from rest_framework_jwt.settings import api_settings
from rest_framework import status, serializers
from rest_framework.test import APITestCase, URLPatternsTestCase
from users.factories import UserFactory
from resources.factories import ResourceFactory
from factory import PostGenerationMethodCall, LazyAttribute, create, create_batch


jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER


class PublicResourcesTests(APITestCase):
# Viewing resources, viewing a single resource, and search don't require user authentication

Expand Down Expand Up @@ -73,13 +66,16 @@ def test_create_a_resource(self):
class AuthedResourcesTests(APITestCase):

def setUp(self):
self.user = UserFactory(password=PostGenerationMethodCall('set_password', 'codebuddies'))
token_uri = '/api/v1/auth/token/'
user_to_auth = UserFactory(password=PostGenerationMethodCall('set_password', 'codebuddies'))
user_auth_data = {
"username": user_to_auth.username,
"password": 'codebuddies'
}

url = '/auth/obtain_token/'
data = {"username": self.user.username, "password": "codebuddies"}
token_response = self.client.post(url, data, format='json')
JWT_user_tokens = self.client.post(token_uri, user_auth_data, format='json')

self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + token_response.data['token'])
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + JWT_user_tokens.data['access'])

def test_patch_one_resource(self):
new_resource = create(ResourceFactory)
Expand Down Expand Up @@ -189,20 +185,22 @@ def test_create_one_resource_without_media_type(self):
self.assertEqual(response.data['media_type'], '')

def test_create_one_resource_with_invalid_media_type(self):
with raises(KeyError, match=r"The media type should be one of the following:"):
url = '/api/v1/resources/'
data = {"title": "The Best Medium-Hard Data Analyst SQL Interview Questions",
"author": "Zachary Thomas",
"description": "The first 70% of SQL is pretty straightforward but the remaining 30% can be pretty tricky. These are good practice problems for that tricky 30% part.",
"url": "https://quip.com/2gwZArKuWk7W",
"referring_url": "https://quip.com",
"other_referring_source": "twitter.com/lpnotes",
"date_published": "2020-04-19T03:27:06Z",
"created": "2020-05-02T03:27:06.485Z",
"modified": "2020-05-02T03:27:06.485Z",
"media_type": "DOP",
"tags": ["SQLt", "BackEnd", "Databases"]
}

response = self.client.post(url, data, format='json')
url = '/api/v1/resources/'
data = {"title": "The Best Medium-Hard Data Analyst SQL Interview Questions",
"author": "Zachary Thomas",
"description": "The first 70% of SQL is pretty straightforward but the remaining 30% can be pretty tricky. These are good practice problems for that tricky 30% part.",
"url": "https://quip.com/2gwZArKuWk7W",
"referring_url": "https://quip.com",
"other_referring_source": "twitter.com/lpnotes",
"date_published": "2020-04-19T03:27:06Z",
"created": "2020-05-02T03:27:06.485Z",
"modified": "2020-05-02T03:27:06.485Z",
"media_type": "DOP",
"tags": ["SQLt", "BackEnd", "Databases"]
}

response = self.client.post(url, data, format='json')

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data[0], "Invalid media type. The media type should be one of the following: VID, POD, PODEP, TALK, TUTOR, COURSE, BOOK, BLOG, GAME, EVENT, TOOL, LIB, WEB")