예제 #1
0
class UserGalleryTest(TestCase):
    def setUp(self):
        self.profile = ProfileFactory()
        self.gallery = GalleryFactory()
        self.image1 = ImageFactory(gallery=self.gallery)
        self.image2 = ImageFactory(gallery=self.gallery)
        self.user_gallery = UserGalleryFactory(user=self.profile.user,
                                               gallery=self.gallery)

    def tearDown(self):
        self.image1.delete()
        self.image2.delete()
        self.user_gallery.delete()
        self.gallery.delete()

    def test_can_write(self):
        self.user_gallery.mode = 'W'

        self.assertTrue(self.user_gallery.can_write())
        self.assertFalse(self.user_gallery.can_read())

    def test_can_read(self):
        self.user_gallery.mode = 'R'

        self.assertFalse(self.user_gallery.can_write())
        self.assertTrue(self.user_gallery.can_read())

    def test_get_images(self):
        self.assertEqual(2, len(self.user_gallery.get_images()))

        self.assertEqual(self.image1, self.user_gallery.get_images()[0])
        self.assertEqual(self.image2, self.user_gallery.get_images()[1])
예제 #2
0
class UserGalleryTest(TestCase):

    def setUp(self):
        self.profile = ProfileFactory()
        self.gallery = GalleryFactory()
        self.image1 = ImageFactory(gallery=self.gallery)
        self.image2 = ImageFactory(gallery=self.gallery)
        self.user_gallery = UserGalleryFactory(user=self.profile.user, gallery=self.gallery)

    def tearDown(self):
        self.image1.delete()
        self.image2.delete()
        self.user_gallery.delete()
        self.gallery.delete()

    def test_can_write(self):
        self.user_gallery.mode = 'W'

        self.assertTrue(self.user_gallery.can_write())
        self.assertFalse(self.user_gallery.can_read())

    def test_can_read(self):
        self.user_gallery.mode = 'R'

        self.assertFalse(self.user_gallery.can_write())
        self.assertTrue(self.user_gallery.can_read())

    def test_get_images(self):
        self.assertEqual(2, len(self.user_gallery.get_images()))

        self.assertEqual(self.image1, self.user_gallery.get_images()[0])
        self.assertEqual(self.image2, self.user_gallery.get_images()[1])
예제 #3
0
class UserGalleryTest(TestCase):
    def setUp(self):
        self.profile = ProfileFactory()
        self.gallery = GalleryFactory()
        self.image1 = ImageFactory(gallery=self.gallery)
        self.image2 = ImageFactory(gallery=self.gallery)
        self.user_gallery = UserGalleryFactory(user=self.profile.user,
                                               gallery=self.gallery)

    def tearDown(self):
        self.image1.delete()
        self.image2.delete()
        self.user_gallery.delete()
        self.gallery.delete()

    def test_unicode(self):
        result = u'Galerie "{0}" envoye par {1}'.format(
            self.gallery, self.profile.user)

        self.assertEqual(result, self.user_gallery.__unicode__())

    def test_is_write(self):
        self.user_gallery.mode = 'W'

        self.assertTrue(self.user_gallery.is_write())
        self.assertFalse(self.user_gallery.is_read())

    def test_is_read(self):
        self.user_gallery.mode = 'R'

        self.assertFalse(self.user_gallery.is_write())
        self.assertTrue(self.user_gallery.is_read())

    def test_get_images(self):
        self.assertEqual(2, len(self.user_gallery.get_images()))

        self.assertEqual(self.image1, self.user_gallery.get_images()[0])
        self.assertEqual(self.image2, self.user_gallery.get_images()[1])

    def test_get_gallery(self):
        gallery_results = self.user_gallery.get_gallery(self.profile.user)

        self.assertEqual(1, len(gallery_results))
        self.assertEqual(self.gallery, gallery_results[0])
예제 #4
0
class UserGalleryTest(TestCase):

    def setUp(self):
        self.profile = ProfileFactory()
        self.gallery = GalleryFactory()
        self.image1 = ImageFactory(gallery=self.gallery)
        self.image2 = ImageFactory(gallery=self.gallery)
        self.user_gallery = UserGalleryFactory(user=self.profile.user, gallery=self.gallery)

    def tearDown(self):
        self.image1.delete()
        self.image2.delete()
        self.user_gallery.delete()
        self.gallery.delete()

    def test_unicode(self):
        result = u'Galerie "{0}" envoye par {1}'.format(self.gallery, self.profile.user)

        self.assertEqual(result, self.user_gallery.__unicode__())

    def test_is_write(self):
        self.user_gallery.mode = 'W'

        self.assertTrue(self.user_gallery.is_write())
        self.assertFalse(self.user_gallery.is_read())

    def test_is_read(self):
        self.user_gallery.mode = 'R'

        self.assertFalse(self.user_gallery.is_write())
        self.assertTrue(self.user_gallery.is_read())

    def test_get_images(self):
        self.assertEqual(2, len(self.user_gallery.get_images()))

        self.assertEqual(self.image1, self.user_gallery.get_images()[0])
        self.assertEqual(self.image2, self.user_gallery.get_images()[1])

    def test_get_gallery(self):
        gallery_results = self.user_gallery.get_gallery(self.profile.user)

        self.assertEqual(1, len(gallery_results))
        self.assertEqual(self.gallery, gallery_results[0])