'Verify that the set_layer_permissions view is behaving as expected'

def test_set_layer_permissions(self):

    layer = Layer.objects.all()[0]
    layer.set_permissions(self.perm_spec)
    self.assertFalse(self.anonymous_user.has_perm('view_resourcebase', layer.get_self_resource()))
    current_perms = layer.get_all_level_info()
    self.assertEqual(len(current_perms['users'].keys()), 2)
    for (username, perm) in self.perm_spec['users'].items():
        user = get_user_model().objects.get(username=username)
        self.assertTrue(user.has_perm(perm, layer.get_self_resource()))
