def create_user(self, number, *, enabled=True): screen_name = 'User-{:d}'.format(number) email_address = 'user{:03d}@example.com'.format(number) user = User.create(screen_name, email_address, 'le_password') user.enabled = enabled self.db.session.add(user) return user
class AvatarImagePathTestCase(AbstractAppTestCase): def setUp(self): super().setUp() user_id = UUID("2e17cb15-d763-4f93-882a-371296a3c63f") self.user = User(id=user_id) def test_path(self): expected = Path("/var/data/avatars/2e17cb15-d763-4f93-882a-371296a3c63f_1406637810.jpeg") with freeze_time("2014-07-29 14:43:30"): created_at = TIMEZONE.localize(datetime.now()) self.user.set_avatar_image(created_at, ImageType.jpeg) with self.app.app_context(): self.app.config["PATH_USER_AVATAR_IMAGES"] = Path("/var/data/avatars") self.assertEqual(self.user.avatar_image_path, expected)
def create_user(number, *, screen_name=None, email_address=None, enabled=True): if not screen_name: screen_name = 'User-{:d}'.format(number) if not email_address: email_address = 'user{:03d}@example.com'.format(number) user = User.create(screen_name, email_address, 'le_password') user.id = generate_uuid() user.enabled = enabled return user
def setUp(self): super(EmailAddressConfirmationTestCase, self).setUp() self.user = User.create("John", "*****@*****.**", "SuperSecret") self.db.session.add(self.user) self.db.session.commit()
def create_user(screen_name, email_address, password, *, enabled=False): user = User.create(screen_name, email_address, password) user.enabled = enabled return user
def setUp(self): super().setUp() user_id = UUID("2e17cb15-d763-4f93-882a-371296a3c63f") self.user = User(id=user_id)