'Test the correct permissions on layers on map download'

def test_map_download(self):

    create_models(type='map')
    create_maplayers()
    the_map = Map.objects.get(title='GeoNode    Default    Map')
    map_layer = the_map.layer_set.get(name='geonode:CA')
    map_layer.local = True
    map_layer.group = 'overlay'
    map_layer.save()
    the_map.layer_set.all().delete()
    the_map.layer_set.add(map_layer)
    bobby = Profile.objects.get(username='bobby')
    the_layer = Layer.objects.get(alternate='geonode:CA')
    remove_perm('download_resourcebase', bobby, the_layer.get_self_resource())
    remove_perm('download_resourcebase', Group.objects.get(name='anonymous'), the_layer.get_self_resource())
    assign_perm('view_resourcebase', bobby, the_layer.get_self_resource())
    assign_perm('download_resourcebase', bobby, the_map.get_self_resource())
    self.client.login(username='bobby', password='bob')
    response = self.client.get(reverse('map_download', args=(the_map.id,)))
    self.assertTrue(('Could    not    find    downloadable    layers    for    this    map' in response.content))
