import pytest


class TestUserGroups(object):

    def test_get_usergroup_selection(self, mock_user, mock_group):
        assert mock_user.as_usergroup_selection() == {
            '$type': 'Core.Models.Utilities.UserGroupSelection, Core',
            'id': '58de1d1c07637a0264c0ca6a',
            'name': 'admin'
        }

        assert mock_group.as_usergroup_selection() == {
            '$type': 'Core.Models.Utilities.UserGroupSelection, Core',
            'id': '58de1d1c07637a0264c0ca71',
            'name': 'Everyone'
        }

    def test_metamethods(self, mock_user, mock_group, mock_record):
        """Test handful of simple metamethods for id and hashing, sorting, uniqueness, etc."""
        # Equality by id
        assert mock_user != mock_group

        # Ordering by name (Everyone < admin)
        assert mock_group < mock_user

        # Ordering type support
        with pytest.raises(TypeError):
            mock_user < mock_record

        # Hash
        local_set = set()
        local_set.add(mock_user)

        assert mock_user in local_set

        local_set.add(mock_user)

        assert len(local_set) == 1

        # Str
        assert str(mock_user) == mock_user.name

@@ -7,16 +7,96 @@
  pytest%0A
+from mock import patch%0A%0Afrom swimlane.core.resources.usergroup import UserGroup%0A
 %0A%0Aclass 
@@ -1280,8 +1280,846 @@
 er.name%0A
+%0A    def test_resolve(self, mock_swimlane, mock_user, mock_group):%0A        %22%22%22Test resolving a generic UserGroup to more specific type%22%22%22%0A        ug_user = UserGroup(mock_user._swimlane, mock_user._raw)%0A        ug_group = UserGroup(mock_group._swimlane, mock_group._raw)%0A%0A        # Test resolve is no-op when already resolved%0A        for ug in (mock_user, mock_group):%0A            assert ug.resolve() is ug%0A%0A        with patch.object(mock_swimlane.users, 'get') as mock_user_get:%0A            with patch.object(mock_swimlane.groups, 'get') as mock_group_get:%0A                mock_group_get.return_value = mock_group%0A                mock_user_get.return_value = mock_user%0A%0A                assert ug_user.resolve() is mock_user%0A%0A                mock_user_get.side_effect = ValueError%0A%0A                assert ug_group.resolve() is mock_group%0A

Add usergroup resource test coverage