Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stvnrlly committed Nov 15, 2016
1 parent 6414271 commit b092f98
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
3 changes: 0 additions & 3 deletions nda/tests.py

This file was deleted.

Empty file added nda/tests/test_markdown.py
Empty file.
47 changes: 47 additions & 0 deletions nda/tests/test_nda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest
from django.contrib.auth.models import Group
from team.factories import UserFactory
from nda.views import sign_nda
from web.views import profile


class TestNDA:
@pytest.mark.django_db
def test_add_to_group(self, rf):
group = Group.objects.create(name='NDA Signed')
user = UserFactory.create()
# POST form data using request factory
request = rf.post('/profile/sign_nda', {'agree': True})
request.user = user
response = sign_nda(request)
# check group
assert group == user.groups.get(id=group.id)

@pytest.mark.django_db
def test_did_not_agree(self, rf):
group = Group.objects.create(name='NDA Signed')
user = UserFactory.create()
# POST form data using request factory
request = rf.post('/profile/sign_nda', {'agree': False})
request.user = user
response = sign_nda(request)
# check group
try:
user.groups.get(id=group.id)
except:
assert True
return
assert False

@pytest.mark.django_db
def test_skip_if_unnecessary(self, rf):
# create user
user = UserFactory.create()
# add to group
group = Group.objects.create(name='NDA Signed')
user.groups.add(group)
# go to view
request = rf.get('/profile/sign_nda')
request.user = user
response = sign_nda(request)
assert "previously signed the NDA" in str(response.content)

0 comments on commit b092f98

Please sign in to comment.