Skip to content

Instantly share code, notes, and snippets.

@katiayn
Created January 22, 2017 17:32
Show Gist options
  • Save katiayn/600d89f871620b1f2ff7691ece011064 to your computer and use it in GitHub Desktop.
Save katiayn/600d89f871620b1f2ff7691ece011064 to your computer and use it in GitHub Desktop.
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