'Verify that the ajax_layer_permissions view is behaving as expected'

def test_ajax_layer_permissions(self):

    valid_layer_typename = Layer.objects.all()[0].id
    invalid_layer_id = 9999999
    response = self.client.post(reverse('resource_permissions', args=(invalid_layer_id,)), data=json.dumps(self.perm_spec), content_type='application/json')
    self.assertEquals(response.status_code, 404)
    response = self.client.get(reverse('resource_permissions', args=(valid_layer_typename,)))
    assert ('permissions' in response.content)
    response = self.client.post(reverse('resource_permissions', args=(valid_layer_typename,)), data=json.dumps(self.perm_spec), content_type='application/json')
    self.assertEquals(response.status_code, 401)
    logged_in = self.client.login(username='bobby', password='bob')
    self.assertEquals(logged_in, True)
    response = self.client.post(reverse('resource_permissions', args=(valid_layer_typename,)), data=json.dumps(self.perm_spec), content_type='application/json')
    self.assertEquals(response.status_code, 401)
    logged_in = self.client.login(username='admin', password='admin')
    self.assertEquals(logged_in, True)
    response = self.client.post(reverse('resource_permissions', args=(valid_layer_typename,)), data=json.dumps(self.perm_spec), content_type='application/json')
    self.assertEquals(response.status_code, 200)
