'Test that new map config can be properly assigned'

def test_new_map_config(self):

    self.client.login(username='admin', password='admin')
    m = Map()
    admin_user = get_user_model().objects.get(username='admin')
    layer_name = Layer.objects.all()[0].alternate
    m.create_from_layer_list(admin_user, [layer_name], 'title', 'abstract')
    map_id = m.id
    url = reverse('new_map_json')
    response = self.client.get(url, {'copy': map_id})
    self.assertEquals(response.status_code, 200)
    map_obj = Map.objects.get(id=map_id)
    config_map = map_obj.viewer_json(None, None)
    response_config_dict = json.loads(response.content)
    self.assertEquals(config_map['map']['layers'], response_config_dict['map']['layers'])
    response = self.client.get(url)
    self.assertEquals(response.status_code, 200)
    config_default = default_map_config(None)[0]
    response_config_dict = json.loads(response.content)
    self.assertEquals(config_default['about']['abstract'], response_config_dict['about']['abstract'])
    self.assertEquals(config_default['about']['title'], response_config_dict['about']['title'])
    response = self.client.get(url, {'layer': layer_name})
    self.assertEquals(response.status_code, 200)
    response_dict = json.loads(response.content)
    self.assertEquals(response_dict['fromLayer'], True)
    self.client.logout()
    response = self.client.post(url, {'layer': layer_name})
    self.assertEquals(response.status_code, 401)
    self.client.login(username='admin', password='admin')
    response = self.client.post(url, {'layer': layer_name})
    self.assertEquals(response.status_code, 400)
    response = self.client.post(url, data=self.viewer_config, content_type='text/json')
    self.assertEquals(response.status_code, 200)
    map_id = int(json.loads(response.content)['id'])
    response = self.client.put(url)
    self.assertEquals(response.status_code, 405)
