示例#1
0
 def test_account_with_url_but_no_identifier(self):
     # Related bug 984298
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {'AMO': {'name': 'Example',
                         'url': 'https://example.com/{identifier}'}}):
         form = ExternalAccountForm({'type': 'AMO',
                                     'privacy': 3})
         form.is_valid()
     ok_('identifier' in form.errors)
示例#2
0
 def test_identifier_cleanup(self):
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {'AMO': {'name': 'Example',
                         'url': 'https://example.com/{identifier}'}}):
         form = ExternalAccountForm({'type': 'AMO',
                                     'identifier': 'https://example.com/foobar/',
                                     'privacy': 3})
         form.is_valid()
     eq_(form.cleaned_data['identifier'], 'foobar')
示例#3
0
 def test_identifier_validator_get_called(self):
     validator = MagicMock()
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {'AMO': {'name': 'Example',
                         'validator': validator}}):
         form = ExternalAccountForm({'type': 'AMO',
                                     'identifier': 'https://example.com/foobar/',
                                     'privacy': 3})
         form.is_valid()
     ok_(validator.called)
示例#4
0
 def test_account_with_url_but_no_identifier(self):
     # Related bug 984298
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {
                    'AMO': {
                        'name': 'Example',
                        'url': 'https://example.com/{identifier}'
                    }
                }):
         form = ExternalAccountForm({'type': 'AMO', 'privacy': 3})
         form.is_valid()
     ok_('identifier' in form.errors)
示例#5
0
 def test_identifier_validator_get_called(self):
     validator = MagicMock()
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {'AMO': {
                    'name': 'Example',
                    'validator': validator
                }}):
         form = ExternalAccountForm({
             'type': 'AMO',
             'identifier': 'https://example.com/foobar/',
             'privacy': 3
         })
         form.is_valid()
     ok_(validator.called)
示例#6
0
 def test_identifier_cleanup(self):
     with patch('mozillians.phonebook.forms.ExternalAccount.ACCOUNT_TYPES',
                {
                    'AMO': {
                        'name': 'Example',
                        'url': 'https://example.com/{identifier}'
                    }
                }):
         form = ExternalAccountForm({
             'type': 'AMO',
             'identifier': 'https://example.com/foobar/',
             'privacy': 3
         })
         form.is_valid()
     eq_(form.cleaned_data['identifier'], 'foobar')