'Ensures that when a user is in a group, the group permissions
extend to the user.'

def test_group_permissions_extend_to_user(self):

    layer = Layer.objects.all()[0]
    layer.set_default_permissions()
    self.assertTrue(self.anonymous_user.has_perm('view_resourcebase', layer.get_self_resource()))
    self.assertTrue(self.norman.has_perm('view_resourcebase', layer.get_self_resource()))
    self.assertFalse(self.norman.has_perm('change_resourcebase', layer.get_self_resource()))
    self.assertFalse(self.bar.user_is_member(self.norman))
    self.bar.join(self.norman)
    self.assertTrue(self.bar.user_is_member(self.norman))
    permissions = {'groups': {'bar': ['view_resourcebase', 'change_resourcebase']}}
    layer.set_permissions(permissions)
    self.assertTrue(self.norman.has_perm('view_resourcebase', layer.get_self_resource()))
    self.assertTrue(self.norman.has_perm('change_resourcebase', layer.get_self_resource()))
    self.assertFalse(self.bar.user_is_member(self.test_user))
    self.assertFalse(self.test_user.has_perm('change_resourcebase', layer.get_self_resource()))
    self.bar.join(self.test_user)
    self.assertTrue(self.test_user.has_perm('change_resourcebase', layer.get_self_resource()))
