'POST /maps/new/data -> Test saving a new map'

def test_map_save(self):

    new_map = reverse('new_map_json')
    response = self.client.post(new_map, data=self.viewer_config, content_type='text/json')
    self.assertEqual(response.status_code, 401)
    self.client.login(username=self.user, password=self.passwd)
    response = self.client.post(new_map, data=self.viewer_config, content_type='text/json')
    self.assertEquals(response.status_code, 200)
    map_id = int(json.loads(response.content)['id'])
    self.client.logout()
    self.assertEquals(map_id, 18)
    map_obj = Map.objects.get(id=map_id)
    self.assertEquals(map_obj.title, 'Title')
    self.assertEquals(map_obj.abstract, 'Abstract')
    self.assertEquals(map_obj.layer_set.all().count(), 1)
    self.assertEquals(map_obj.keyword_list(), [u'keywords', u'saving'])
    self.assertNotEquals(map_obj.bbox_x0, None)
    self.client.login(username=self.user, password=self.passwd)
    response = self.client.post(new_map, data='not    a    valid    viewer    config', content_type='text/json')
    self.assertEquals(response.status_code, 400)
    self.client.logout()
