Created
January 22, 2017 17:32
-
-
Save katiayn/600d89f871620b1f2ff7691ece011064 to your computer and use it in GitHub Desktop.
Hypothesis example by http://drmaciver.github.io/hypothesis-talks/hypothesis-for-django.html#/10
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
from hypothesis.extra.django import TestCase | |
from hypothesis import given | |
from hypothesis.extra.django.models import models | |
from hypothesis.strategies import lists, integers | |
class TestProjectManagement(TestCase): | |
@given( | |
models(Project, collaborator_limit=integers(min_value=0, max_value=20)), | |
lists(models(User), max_size=20)) | |
def test_can_add_users_up_to_collaborator_limit(self, project, collaborators): | |
for c in collaborators: | |
if project.at_collaboration_limit(): | |
with self.assertRaises(LimitReached): | |
project.add_user(c) | |
self.assertFalse(project.team_contains(c)) | |
else: | |
project.add_user(c) | |
self.assertTrue(project.team_contains(c)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment