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)
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')
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)
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)
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)
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')