@@ -598,14 +598,16 @@ class InfoViewsTestCase(TestCase):
598
598
Tests relating to info/views.py
599
599
"""
600
600
def setUp (self ):
601
- """
602
- Setup for tests in this class
603
- """
604
-
601
+ self .client = Client ()
602
+ self .user = get_user_model ().objects .create_user (username = "test_user" , password = "test_password" )
603
+ self .city = "Hyderabad"
604
+ self .country = "India"
605
+ self .client .login (username = "test_user" , password = "test_password" )
606
+
605
607
@patch ("os.getenv" , return_value = "test_google_api_key" )
606
608
def test_google_maps_api (self , mock_env ):
607
609
response = self .client .get (reverse ("google_maps_api" ))
608
- self .assertEqual (response .status_code , 302 )
610
+ self .assertEqual (response .status_code , 200 )
609
611
self .assertIn ("script" , response .json ())
610
612
self .assertIn ("test_google_api_key" , response .json ()["script" ])
611
613
@@ -619,11 +621,11 @@ def test_drop_pin_success(self, mock_geocode):
619
621
@patch ("googlemaps.Client.geocode" , return_value = [])
620
622
def test_drop_pin_location_not_found (self , mock_geocode ):
621
623
response = self .client .get (reverse ("drop_pin" ), {"location" : "Unknown" })
622
- self .assertEqual (response .status_code , 302 )
624
+ self .assertEqual (response .status_code , 404 )
623
625
624
626
def test_drop_pin_no_location (self ):
625
627
response = self .client .get (reverse ("drop_pin" ))
626
- self .assertEqual (response .status_code , 302 )
628
+ self .assertEqual (response .status_code , 400 )
627
629
628
630
def test_add_to_fav (self ):
629
631
response = self .client .get (reverse ("addToFav" ), {"city" : self .city , "country" : self .country })
@@ -640,7 +642,7 @@ def test_add_to_fav_missing_params(self):
640
642
641
643
def test_profile_page (self ):
642
644
response = self .client .get (reverse ("profile_page" ))
643
- self .assertEqual (response .status_code , 302 )
645
+ self .assertEqual (response .status_code , 200 )
644
646
self .assertTemplateUsed (response , "profile/profile.html" )
645
647
646
648
def test_itinerary_page (self ):
@@ -650,7 +652,7 @@ def test_itinerary_page(self):
650
652
651
653
def test_all_itineraries_page (self ):
652
654
response = self .client .get (reverse ("all_itineraries" ))
653
- self .assertEqual (response .status_code , 302 )
655
+ self .assertEqual (response .status_code , 200 )
654
656
self .assertTemplateUsed (response , "search/all_itineraries.html" )
655
657
656
658
def test_add_to_itinerary (self ):
0 commit comments