Beispiel #1
0
    def test_home_page_displays_all_list_movies(self):
        Movie.objects.create(name='X-men 2')
        Movie.objects.create(name='Captian America')

        request = HttpRequest()
        response = home_page(request)

        self.assertIn('X-men 2', response.content.decode())
        self.assertIn('Captian America', response.content.decode())
Beispiel #2
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)
Beispiel #3
0
    def test_add_movie_can_save_a_POST_request(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['name_text'] = 'X-men'
        request.POST['actor_text'] = ''
        request.POST['director_text'] = ''
        request.POST['genre_text'] = ''
        request.POST['clip_url'] = ''
        request.POST['detail_text'] = '3D/IMAX'
        request.POST['date_text'] = '2015-04-21'
        request.POST['poster_url'] = (
            'https://siam-movie.com/wp-content/uploads/2014/05/1395818775261.jpg'
        )
        request.POST['Add_send_Detail'] = 'submit_send_data'

        response = home_page(request)

        new_movie = Movie.objects.first()
        self.assertEqual(new_movie.name, 'X-men')
        self.assertEqual(new_movie.release_date, '2015-04-21')
        self.assertEqual(new_movie.detail, '3D/IMAX')
        self.assertEqual(new_movie.poster, (
            'https://siam-movie.com/wp-content/uploads/2014/05/1395818775261.jpg'
        ))
Beispiel #4
0
 def test_home_page_only_saves_movie_when_necessary(self):
     request = HttpRequest()
     home_page(request)
Beispiel #5
0
 def test_home_page_returns_correct_html(self):
     request = HttpRequest()
     response = home_page(request)
     expected_html = render_to_string('home.html')
     self.assertEqual(response.content.decode(), expected_html)