Exemplo n.º 1
0
    def test_edit_movie(self):
        movie_ = Movie()
        movie_.name = 'X-men'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.lead_actors = ''
        movie_.director = ''
        movie_.genre = ''
        movie_.clip = ''
        movie_.save()
        movie = Movie.objects.first()
        movie_id = movie.id
        request = HttpRequest()
        request.method = 'POST'
        request.POST['name_text'] = 'Kamenraider'
        request.POST['detail_text'] = '3D/IMAX'
        request.POST['date_text'] = '2015-04-01'
        request.POST['poster_url'] = ('http://upic.me/i/6r/wallpaper3.jpg')
        request.POST['actor_text'] = ''
        request.POST['director_text'] = ''
        request.POST['genre_text'] = ''
        request.POST['clip_url'] = ''
        request.POST['Update_send_Detail'] = 'submit_send_update'

        response = edit_page(request, movie_id)

        edit_movie = Movie.objects.first()
        self.assertEqual(edit_movie.name, 'Kamenraider')
        self.assertEqual(edit_movie.release_date, '2015-04-01')
        self.assertEqual(edit_movie.detail, '3D/IMAX')
        self.assertEqual(edit_movie.poster,
                         ('http://upic.me/i/6r/wallpaper3.jpg'))
Exemplo n.º 2
0
    def test_root_url_resolves_to_detail_page_view(self):
        movie_ = Movie()
        movie_.name = 'Kamenraider'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.save()
        movie = Movie.objects.first()
        movie_id = movie.id
        request = HttpRequest()

        response = movie_detail_page(request, movie_id)

        found = resolve('/movie_detail/1/')
        self.assertEqual(found.func, movie_detail_page)
Exemplo n.º 3
0
    def test_delete_movie(self):
        movie_ = Movie()
        movie_.name = 'X-men'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.save()
        request = HttpRequest()
        request.method = 'POST'
        request.POST['id_delete'] = '1'
        request.POST['delete'] = 'delete'

        response = home_page(request)

        self.assertEqual(Movie.objects.count(), 0)
Exemplo n.º 4
0
    def test_rating_movie(self):
        movie_ = Movie()
        movie_.name = 'X-men'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.save()
        movie = Movie.objects.first()
        movie_id = movie.id
        request = HttpRequest()
        request.method = 'POST'
        request.POST['star'] = '3'
        request.POST['send_rate'] = 'send_rate'

        response = movie_detail_page(request, movie_id)

        edit_movie = Movie.objects.first()
        self.assertEqual(edit_movie.rate, 3.0)
Exemplo n.º 5
0
    def test_comment_movie(self):
        movie_ = Movie()
        movie_.name = 'X-men'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.save()
        movie = Movie.objects.first()
        movie_id = movie.id
        request = HttpRequest()
        request.method = 'POST'
        request.POST['user_name'] = 'Poowapong'
        request.POST['comment_text'] = 'Perfect'
        request.POST['send_comment'] = 'send_Comment'

        response = movie_detail_page(request, movie_id)

        comment_movie = Comment.objects.first()
        self.assertEqual(comment_movie.user, 'Poowapong')
        self.assertEqual(comment_movie.comment_text, 'Perfect')
Exemplo n.º 6
0
    def test_like_comment_movie(self):
        movie_ = Movie()
        movie_.name = 'X-men'
        movie_.detail = ''
        movie_.release_date = '2015-04-21'
        movie_.poster = 'http://upic.me/i/6r/wallpaper3.jpg'
        movie_.save()
        movie = Movie.objects.first()
        movie_id = movie.id
        comment_ = Comment()
        comment_.movie = movie
        comment_.user = '******'
        comment_.comment_text = 'Great'
        comment_.save()
        request = HttpRequest()
        request.method = 'POST'
        request.POST['like'] = '1'
        request.POST['id_send_like'] = '1'
        request.POST['send_like'] = 'submit_like'

        response = movie_detail_page(request, movie_id)

        comment_movie = Comment.objects.first()
        self.assertEqual(comment_movie.like, 1)