Exemple #1
0
 def test_by_request_group_with_new_member_criteria(self):
     form_data = {'name': 'test group',
                  'accepting_new_members': 'by_request',
                  'new_member_criteria': 'some criteria'}
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     ok_('new_member_criteria' in form.cleaned_data)
Exemple #2
0
 def test_no_saved_criteria(self):
     form_data = {'name': 'test group',
                  'accepting_new_members': 'no',
                  'new_member_criteria': 'some criteria'}
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     eq_(u'', form.cleaned_data['new_member_criteria'])
Exemple #3
0
 def test_by_request_group_without_new_member_criteria(self):
     form_data = {
         'name': 'test group',
         'accepting_new_members': 'by_request'
     }
     form = GroupForm(data=form_data)
     eq_(False, form.is_valid())
     ok_('new_member_criteria' in form.errors)
Exemple #4
0
 def test_name_unique(self):
     group = GroupFactory.create()
     GroupAliasFactory.create(alias=group, name='bar')
     form = GroupForm({'name': 'bar'})
     ok_(not form.is_valid())
     ok_('name' in form.errors)
     msg = u'This name already exists.'
     ok_(msg in form.errors['name'])
Exemple #5
0
 def test_name_unique(self):
     group = GroupFactory.create()
     GroupAliasFactory.create(alias=group, name='bar')
     form = GroupForm({'name': 'bar'})
     ok_(not form.is_valid())
     ok_('name' in form.errors)
     msg = u'This name already exists.'
     ok_(msg in form.errors['name'])
Exemple #6
0
 def test_by_request_group_with_new_member_criteria(self):
     user = UserFactory.create()
     form_data = {'name': 'test group',
                  'accepting_new_members': 'by_request',
                  'new_member_criteria': 'some criteria',
                  'curators': [user.userprofile.id]}
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     ok_('new_member_criteria' in form.cleaned_data)
Exemple #7
0
 def test_no_saved_criteria(self):
     user = UserFactory.create()
     form_data = {'name': 'test group',
                  'accepting_new_members': 'no',
                  'new_member_criteria': 'some criteria',
                  'curators': [user.userprofile.id]}
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     eq_(u'', form.cleaned_data['new_member_criteria'])
 def test_no_saved_criteria(self):
     form_data = {
         'name': 'test group',
         'accepting_new_members': 'no',
         'new_member_criteria': 'some criteria'
     }
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     eq_(u'', form.cleaned_data['new_member_criteria'])
 def test_by_request_group_with_new_member_criteria(self):
     form_data = {
         'name': 'test group',
         'accepting_new_members': 'by_request',
         'new_member_criteria': 'some criteria'
     }
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     ok_('new_member_criteria' in form.cleaned_data)
Exemple #10
0
 def test_by_request_group_with_new_member_criteria(self):
     form_data = {
         "name": "test group",
         "accepting_new_members": "by_request",
         "new_member_criteria": "some criteria",
     }
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     ok_("new_member_criteria" in form.cleaned_data)
Exemple #11
0
 def test_by_request_group_with_new_member_criteria(self):
     user = UserFactory.create()
     form_data = {
         'name': 'test group',
         'accepting_new_members': 'by_request',
         'new_member_criteria': 'some criteria',
         'curators': [user.userprofile.id]
     }
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     ok_('new_member_criteria' in form.cleaned_data)
Exemple #12
0
 def test_no_saved_criteria(self):
     user = UserFactory.create()
     form_data = {
         'name': 'test group',
         'accepting_new_members': 'no',
         'new_member_criteria': 'some criteria',
         'curators': [user.userprofile.id]
     }
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     eq_(u'', form.cleaned_data['new_member_criteria'])
Exemple #13
0
    def test_new_group_without_curators(self):
        # Create a new group without curators
        form_data = {
            'name': 'test_group',
            'accepting_new_members': 'by_request',
            'new_member_criteria': 'some criteria',
            'curators': []
        }
        form = GroupForm(data=form_data)

        ok_(not form.is_valid())
        eq_(form.errors,
            {'curators': [u'The group must have at least one curator.']})
Exemple #14
0
    def test_group_curators_validation(self):
        group = GroupFactory.create()
        curator = UserFactory.create()
        group.curators.add(curator.userprofile)

        # Update form without adding curators
        form_data = {'name': 'test_group',
                     'accepting_new_members': 'by_request',
                     'new_member_criteria': 'some criteria',
                     'curators': []}
        form = GroupForm(instance=group, data=form_data)

        ok_(not form.is_valid())
        eq_(form.errors, {'curators': [u'The group must have at least one curator.']})
Exemple #15
0
    def test_legacy_group_curators_validation(self):
        group = GroupFactory.create()

        # Update form without adding curators
        form_data = {'name': 'test_group',
                     'accepting_new_members': 'by_request',
                     'new_member_criteria': 'some criteria'}
        form = GroupForm(instance=group, data=form_data)

        ok_(form.is_valid())

        # Ensure that groups has no curators
        group = Group.objects.get(id=group.id)
        ok_(not group.curators.exists())
Exemple #16
0
    def test_create_new_group(self):
        # Create a new group without curators
        curator = UserFactory.create(vouched=True)
        form_data = {
            'name': 'test_group',
            'accepting_new_members': 'by_request',
            'new_member_criteria': 'some criteria',
            'curators': [curator.id]
        }
        form = GroupForm(data=form_data)

        ok_(form.is_valid())
        form.save()
        eq_(Group.objects.all().count(), 1)
Exemple #17
0
    def test_legacy_group_curators_validation(self):
        group = GroupFactory.create()

        # Update form without adding curators
        form_data = {
            'name': 'test_group',
            'accepting_new_members': 'by_request',
            'new_member_criteria': 'some criteria'
        }
        form = GroupForm(instance=group, data=form_data)

        ok_(form.is_valid())

        # Ensure that groups has no curators
        group = Group.objects.get(id=group.id)
        ok_(not group.curators.exists())
Exemple #18
0
    def test_group_curators_validation(self):
        group = GroupFactory.create()
        curator = UserFactory.create()
        group.curators.add(curator.userprofile)

        # Update form without adding curators
        form_data = {
            'name': 'test_group',
            'accepting_new_members': 'by_request',
            'new_member_criteria': 'some criteria',
            'curators': []
        }
        form = GroupForm(instance=group, data=form_data)

        ok_(not form.is_valid())
        eq_(form.errors,
            {'curators': [u'The group must have at least one curator.']})
Exemple #19
0
 def test_name_unique(self):
     group = GroupFactory.create()
     GroupAliasFactory.create(alias=group, name='bar')
     form = GroupForm({'name': 'bar'})
     ok_(not form.is_valid())
     ok_('name' in form.errors)
Exemple #20
0
 def test_no_saved_criteria(self):
     form_data = {"name": "test group", "accepting_new_members": "no", "new_member_criteria": "some criteria"}
     form = GroupForm(data=form_data)
     ok_(form.is_valid())
     eq_(u"", form.cleaned_data["new_member_criteria"])
Exemple #21
0
 def test_name_unique(self):
     group = GroupFactory.create()
     GroupAliasFactory.create(alias=group, name="bar")
     form = GroupForm({"name": "bar"})
     ok_(not form.is_valid())
     ok_("name" in form.errors)
Exemple #22
0
 def test_by_request_group_without_new_member_criteria(self):
     form_data = {'name': 'test group', 'accepting_new_members': 'by_request'}
     form = GroupForm(data=form_data)
     eq_(False, form.is_valid())
     ok_('new_member_criteria' in form.errors)
 def test_name_unique(self):
     group = GroupFactory.create()
     GroupAliasFactory.create(alias=group, name='bar')
     form = GroupForm({'name': 'bar'})
     ok_(not form.is_valid())
     ok_('name' in form.errors)
Exemple #24
0
 def test_by_request_group_without_new_member_criteria(self):
     form_data = {"name": "test group", "accepting_new_members": "by_request"}
     form = GroupForm(data=form_data)
     eq_(False, form.is_valid())
     ok_("new_member_criteria" in form.errors)