'Verify that the layer_acls view is behaving as expected'

def test_layer_acls(self):

    valid_uname_pw = ('%s:%s' % ('bobby', 'bob'))
    invalid_uname_pw = ('%s:%s' % ('n0t', 'v@l1d'))
    valid_auth_headers = {'HTTP_AUTHORIZATION': ('basic    ' + base64.b64encode(valid_uname_pw))}
    invalid_auth_headers = {'HTTP_AUTHORIZATION': ('basic    ' + base64.b64encode(invalid_uname_pw))}
    bob = get_user_model().objects.get(username='bobby')
    layer_ca = Layer.objects.get(alternate='geonode:CA')
    assign_perm('change_layer_data', bob, layer_ca)
    expected_result = {u'email': u'bobby@bob.com', u'fullname': u'bobby', u'is_anonymous': False, u'is_superuser': False, u'name': u'bobby', u'ro': [u'geonode:layer2', u'geonode:mylayer', u'geonode:foo', u'geonode:whatever', u'geonode:fooey', u'geonode:quux', u'geonode:fleem'], u'rw': [u'geonode:CA']}
    response = self.client.get(reverse('layer_acls'), **valid_auth_headers)
    response_json = json.loads(response.content)
    self.assertEquals(sorted(expected_result), sorted(response_json))
    response = self.client.get(reverse('layer_acls'), **invalid_auth_headers)
    self.assertEquals(response.status_code, 401)
    self.client.login(username='admin', password='admin')
    response = self.client.get(reverse('layer_acls'))
    response_json = json.loads(response.content)
    self.assertEquals('admin', response_json['fullname'])
    self.assertEquals('', response_json['email'])
