Exemplo n.º 1
0
    def setUp(self):
        self.user = UserFactory.create(
            username='******',
            email='*****@*****.**',
        )
        self.user.set_password('secret')

        self.user_2 = UserFactory.create(
            username='******',
            email='*****@*****.**',
        )
        self.user_2.set_password('moresecret')

        self.album = AlbumFactory.create(
            name='an_album',
            user=self.user,
            date_created=datetime.datetime.now(),
            date_modified=datetime.datetime.now(),
            date_published=datetime.datetime.now(),
        )

        self.photo = PhotoFactory.create(
            title='image01',
            user=self.user,
            date_created=datetime.datetime.now(),
            date_modified=datetime.datetime.now(),
            date_published=datetime.datetime.now(),
        )
        self.photo.albums.add(self.album)
Exemplo n.º 2
0
    def setUp(self):
        self.user = UserFactory.create(
            username='******',
            email='*****@*****.**',
        )
        self.user.set_password('secret')

        self.user_2 = UserFactory.create(
            username='******',
            email='*****@*****.**',
        )
        self.user_2.set_password('moresecret')

        self.album = AlbumFactory.create(
            name='an_album',
            user=self.user,
            date_created=datetime.datetime.now(),
            date_modified=datetime.datetime.now(),
            date_published=datetime.datetime.now(),
        )

        self.photo = PhotoFactory.create(
            title='image01',
            user=self.user,
            date_created=datetime.datetime.now(),
            date_modified=datetime.datetime.now(),
            date_published=datetime.datetime.now(),
        )
        self.photo.albums.add(self.album)
Exemplo n.º 3
0
 def setUp(self):
     self.r_factory = RequestFactory()
     self.user_1 = UserFactory.create(
         username='******',
         email='*****@*****.**'
     )
     self.user_1.set_password('stuff12345')
     self.user_1.save()
     self.user_2 = UserFactory.build(
         username='******',
         email='*****@*****.**'
     )
     self.user_2.set_password('krampusrocks')
     self.cl = Client()
     self.cl_2 = Client()
     self.cl_3 = Client()
     self.user_3 = UserFactory.create(
         username='******',
         email='*****@*****.**',
     )
     self.user_3.set_password('iwilltrytohackyou')
     self.user_3.save()
     self.image_1 = PhotoFactory.create(
         title="image 1",
         user=self.user_1,
         description="This is a nature shot.",
     )
     self.image_2 = PhotoFactory.create(
         title="image 2",
         user=self.user_3,
         description="This is a sports photo.",
         published='public',
     )
     self.image_3 = PhotoFactory.build(
         title="image 3",
         user=self.user_3,
         description="test",
         published='public'
     )
     self.album_1 = AlbumFactory.create(
         title='2016',
         description='Random photos 2016.',
         user=self.user_1,
         cover_photo=self.image_1
     )
     self.album_2 = AlbumFactory.create(
         title='sports',
         description='This is sporty.',
         user=self.user_3,
         cover_photo=self.image_2
     )
     self.album_1.pictures.add(self.image_1)
     self.album_2.pictures.add(self.image_2)
Exemplo n.º 4
0
 def setUp(self):
     """The appropriate setup for the appropriate test."""
     self.client = Client()
     self.request = RequestFactory()
     self.users = [UserFactory.create() for i in range(20)]
     self.photos = [PhotoFactory.create() for i in range(20)]
     self.albums = [AlbumFactory.create() for i in range(20)]
Exemplo n.º 5
0
 def setUp(self):
     """Photo for album."""
     self.user = UserFactory.create()
     self.photo0 = PhotoFactory.create(owner=self.user)
     self.photo1 = PhotoFactory.create()
     self.album0 = AlbumFactory.create()
     self.album1 = AlbumFactory.create()
     self.album1.photos.add(self.photo0)
Exemplo n.º 6
0
 def setUp(self):
     """Photo for album."""
     self.user = UserFactory.create()
     self.photo0 = PhotoFactory.create(owner=self.user)
     self.photo1 = PhotoFactory.create()
     self.album0 = AlbumFactory.create()
     self.album1 = AlbumFactory.create()
     self.album1.photos.add(self.photo0)
Exemplo n.º 7
0
    def setUp(self):
        """Setup of users, photos, and albums for tests."""
        self.user = UserFactory.create(
            username='******',
            email='*****@*****.**'
        )
        self.user.set_password('stuff123')

        self.sad_user = UserFactory.create(
            username='******',
            email='*****@*****.**'
        )
        self.sad_user.set_password('meh123123')

        self.image_1 = PhotoFactory.create(
            title="image 1",
            user=self.user,
            description="This is a nature shot.",
        )
        self.image_2 = PhotoFactory.create(
            title="image 2",
            user=self.user,
            description="This is a sports photo.",
        )
        self.image_3 = PhotoFactory.create(
            title="image 3",
            user=self.user,
            description="This is a portrait of a cat.",
        )
        self.album_1 = AlbumFactory.create(
            title='2016',
            description='Random photos 2016.',
            user=self.user,
            cover_photo=self.image_1
        )

        self.album_2 = AlbumFactory.create(
            title='Outdoor Adventures',
            description='PNW travel photos.',
            user=self.user,
            cover_photo=self.image_1
        )
        self.album_1.pictures.add(self.image_1)
        self.album_1.pictures.add(self.image_2)
        self.album_2.pictures.add(self.image_1)
Exemplo n.º 8
0
 def setUp(self):
     """Set up test client."""
     self.client = Client()
     self.user = UserFactory.create()
     self.photo = PhotoFactory.create(
         owner=self.user,
     )
     self.album = AlbumFactory.create(
         owner=self.user,
     )
Exemplo n.º 9
0
 def add_test_user(self):
     """Make test user and return his profile."""
     user = UserFactory.create()
     user.username = '******'
     user.set_password('billyspassword')
     photo = PhotoFactory.create()
     photo.owner = user.profile
     user.save()
     photo.save()
     return user
Exemplo n.º 10
0
 def setUp(self):
     """Set up test client."""
     self.client = Client()
     self.user = UserFactory.create()
     self.photo = PhotoFactory.create(
         owner=self.user,
     )
     self.album = AlbumFactory.create(
         owner=self.user,
     )
Exemplo n.º 11
0
    def setUp(self):
        """Setup of users, photos, and albums for tests."""
        self.user = UserFactory.create(username='******',
                                       email='*****@*****.**')
        self.user.set_password('stuff123')

        self.sad_user = UserFactory.create(username='******',
                                           email='*****@*****.**')
        self.sad_user.set_password('meh123123')

        self.image_1 = PhotoFactory.create(
            title="image 1",
            user=self.user,
            description="This is a nature shot.",
        )
        self.image_2 = PhotoFactory.create(
            title="image 2",
            user=self.user,
            description="This is a sports photo.",
        )
        self.image_3 = PhotoFactory.create(
            title="image 3",
            user=self.user,
            description="This is a portrait of a cat.",
        )
        self.album_1 = AlbumFactory.create(title='2016',
                                           description='Random photos 2016.',
                                           user=self.user,
                                           cover_photo=self.image_1)

        self.album_2 = AlbumFactory.create(title='Outdoor Adventures',
                                           description='PNW travel photos.',
                                           user=self.user,
                                           cover_photo=self.image_1)
        self.album_1.pictures.add(self.image_1)
        self.album_1.pictures.add(self.image_2)
        self.album_2.pictures.add(self.image_1)
Exemplo n.º 12
0
 def test_home_view_returns_context_with_photo_from_db(self):
     """Test that the homeview  returns photo from db."""
     from imagersite.views import HomeView
     user = UserFactory()
     user.set_password('password')
     user.save()
     photo = PhotoFactory(user=user, title='test', published='PUBLIC')
     photo.save()
     view = HomeView()
     data = view.get_context_data()
     self.assertIn('hero_img_url', data)
     self.assertEqual('test', data['hero_img_title'])
    def setUp(self):
        """Set up for unauthenticated case with no users."""
        self.users_sessions = []

        for user in UserFactory.create_batch(NUM_USERS):
            params = {'username': user.username, 'password': '******'}

            for perm in PERMS:
                perm = Permission.objects.get(codename=perm)
                user.user_permissions.add(perm)

            session = {'user': user}
            session['client'] = client = Client()
            session['login_response'] = client.post(LOGIN, params, follow=True)
            session['profile_response'] = client.get(
                PROFILE, params, follow=True)
            session['lib_response'] = client.get(LIBRARY, params, follow=True)
            self.users_sessions.append(session)

            album_batch = AlbumFactory.create_batch(NUM_ALBUMS, owner=user)
            for album in album_batch:
                photo_batch = PhotoFactory.create_batch(NUM_PHOTOS, owner=user)
                album.add_photos(photo_batch)
Exemplo n.º 14
0
 def setUp(self):
     """Initialize a photo."""
     self.user = UserFactory.create()
     self.photo = PhotoFactory.create(owner=self.user, )
Exemplo n.º 15
0
 def setUp(self):
     """Initialize an album."""
     self.user = UserFactory.create()
     self.album = AlbumFactory.create(owner=self.user, )
Exemplo n.º 16
0
    def setUpClass(cls):
        """Add one minimal user to the database."""
        super(PhotoAPIRouteTests, cls).setUpClass()

        os.system('mkdir {}'.format(
            os.path.join(settings.BASE_DIR, 'test_media_for_photos_api_routes')
        ))

        user = UserFactory(username='******')
        user.set_password('password')
        user.save()
        cls.user = user

        for _ in range(10):
            photo = PhotoFactory(user=user)
            photo.save()

        user = UserFactory()
        user.set_password(factory.Faker('password'))
        user.save()
        cls.second_user = user

        for _ in range(5):
            photo = PhotoFactory(user=user)
            photo.save()
Exemplo n.º 17
0
 def setUp(self):
     """Initialize a photo."""
     self.user = UserFactory.create()
     self.photo = PhotoFactory.create(
         owner=self.user,
     )
Exemplo n.º 18
0
 def setUp(self):
     """Initialize an album."""
     self.user = UserFactory.create()
     self.album = AlbumFactory.create(
         owner=self.user,
     )
Exemplo n.º 19
0
 def setUp(self):
     """Set up a user for testing login.."""
     user = UserFactory(username='******', email='*****@*****.**')
     user.set_password('password')
     user.save()