Esempio n. 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)
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')