def test_download_csv(self): map_id = 1 # stuff = {"id": 1, # "canvas_course_id": 73, # "title": "title", # "latitude": "43", # "longitude": "72", # "zoom": 4, # "maptype": 1, # "thumbnail": "https://maps.googleapis.com/maps/api/staticmap?center=43,72&zoom=4&size=200x150&maptype=satellite", # "markers": [{"title": "title", # "map": 1, # "latitude": "24", # "longitude": "25", # "description": "description", # "external_url": "blank", # "created_by_id": "huid", # "created_by_full_name": "name", # "modified_by_id": "huid", # "date_created": "2015-09-12T03:26:23.222000Z", # "date_modified": "2015-09-12T03:26:23.222000Z"}], # "date_created": "2015-09-12T03:26:23.222000Z", # "date_modified": "2015-09-12T03:26:23.222000Z", # "created_by_id": "huid", # "created_by_full_name": "name", # "modified_by_id": "huid", # "description": "description"} # mock_map.objects.get.return_value = stuff mockvalue = "title,map,latitude,longitude,description,external_url,created_by_full_name,date_created,date_modified\r\ntitle,1,24,25,description,blank,name,2015-09-12T03:26:23.222000Z,2015-09-12T03:26:23.222000Z\r\n" # mock_serializer = SerializerStub(stuff).map # print SerializerStub(stuff).map result = download_csv(self.request, map_id) # print "\n\n\n\n\n\n\n\n" # print result.status_code() self.assertTrue(status.is_success(result.status_code)) self.assertEqual(result.content, mockvalue)
def test_download_csv_Key_DoesnotExist(self): map_id = 5 result = download_csv(self.request, map_id) self.assertTrue(status.is_client_error(result.status_code))