def test_two_users_with_same_email(user, mixer): mixer.blend('users.User', email=user.email) created = UserCreator(name='Камаз Отходов', email=user.email)() created.refresh_from_db() assert created == user
def test(): created = UserCreator(name='Рулон Обоев', email='*****@*****.**')() created.refresh_from_db() assert created.first_name == 'Рулон' assert created.last_name == 'Обоев' assert created.email == '*****@*****.**'
def test_storing_wants_to_subscribe_flag(wants_to_subscribe): created = UserCreator(name='Рулон Обоев', email='*****@*****.**', subscribe=wants_to_subscribe)() created.refresh_from_db() assert created.subscribed is wants_to_subscribe
def test_empty_email(): created = UserCreator(name='Рулон Обоев', email='')() created.refresh_from_db() assert created.first_name == 'Рулон' assert created.last_name == 'Обоев' assert created.email == '' assert len(created.username) > 0
def test_empty_name(name): created = UserCreator(name=name, email='*****@*****.**')() created.refresh_from_db() assert created.first_name == '' assert created.last_name == '' assert created.email == '*****@*****.**' assert created.username == '*****@*****.**'
def test_existing_user_name_does_not_change(user): created = UserCreator(name='Камаз Отходов', email=user.email)() created.refresh_from_db() assert created.first_name == user.first_name assert created.last_name == user.last_name assert created.first_name != 'Камаз' assert created.last_name != 'Отходов'
def _create_user(self) -> User: return UserCreator( name=self.data['name'], email=self.data['email'], subscribe=True, tags=self.tags, )()
def test_user_is_subscribed_to_maichimp_by_default(subscribe): created = UserCreator(name='Рулон Обоев', email='*****@*****.**')() subscribe.assert_called_once_with( user_id=created.id, tags=None, )
def _create_user(self, name: str, email: str, subscribe: bool = False, tags: Optional[Iterable[str]] = None) -> User: return UserCreator( name=name, email=email.strip(), subscribe=subscribe, tags=tags, )()
def _create_user(self, name: str, email: str, subscribe: bool = False) -> User: return UserCreator( name=name, email=email, subscribe=subscribe, )()
def test_tags_are_passed(subscribe): created = UserCreator(name='Рулон Обоев', email='*****@*****.**', tags=['aatag', 'bbtag'])() subscribe.assert_called_once_with( user_id=created.id, tags=['aatag', 'bbtag'], )
def _create_order(self, data): return OrderCreator( user=UserCreator( name=data['name'], email=data['email'], subscribe=data.get('subscribe', False), )(), item=self.get_object(), promocode=data.get('promocode', None), )()
def test_default_username(): created = UserCreator(name='Ведро Помоев', email='*****@*****.**')() assert created.username == '*****@*****.**'
def test_existing_user(user): created = UserCreator(name='Камаз Отходов', email=user.email)() created.refresh_from_db() assert created == user
def test_not_subscribed(subscribe): UserCreator(name='Рулон Обоев', email='*****@*****.**', subscribe=False)() subscribe.assert_not_called()
def save(self, commit=True): return UserCreator(name='', email=self.cleaned_data['email'])()