def test_split_group_action():
    user_template = six.text_type("user.{}@example.com")
    add_users = [user_template.format(n+1) for n in range(0, 25)]
    group = UserGroupAction(group_name="Test Group")
    group.add_users(users=add_users)
    assert group.maybe_split_groups(10) is True
    assert len(group.commands) == 3
Exemple #2
0
def test_remove_from_products_all():
    group = UserGroupAction(group_name="SampleUsers")
    group.remove_from_products(all_products=True)
    assert group.wire_dict() == {
        "do": [{
            "remove": "all"
        }],
        "usergroup": "SampleUsers"
    }
Exemple #3
0
def test_delete_user_group():
    group = UserGroupAction("Test Group")
    group.delete()
    assert group.wire_dict() == {
        'do': [{
            'deleteUserGroup': {}
        }],
        'usergroup': 'Test Group'
    }
Exemple #4
0
def test_add_to_products_all():
    group = UserGroupAction(group_name="SampleUsers")
    group.add_to_products(all_products=True)
    assert group.wire_dict() == {
        "do": [{
            "add": "all"
        }],
        "usergroup": "SampleUsers"
    }
Exemple #5
0
def test_remove_users():
    group = UserGroupAction(group_name="SampleUsers")
    group.remove_users(users=["*****@*****.**", "*****@*****.**"])
    assert group.wire_dict() == {
        "do": [{
            "remove": {
                "user": ["*****@*****.**", "*****@*****.**"]
            }
        }],
        "usergroup": "SampleUsers"
    }
Exemple #6
0
def test_remove_from_products():
    group = UserGroupAction(group_name="SampleUsers")
    group.remove_from_products(products=["Photoshop", "Illustrator"])
    assert group.wire_dict() == {
        "do": [{
            "remove": {
                "productConfiguration": ["Photoshop", "Illustrator"]
            }
        }],
        "usergroup": "SampleUsers"
    }
def test_add_to_products():
    group = UserGroupAction(group_name="SampleUsers")
    group.add_to_products(products=["Photoshop", "Illustrator"])
    assert group.wire_dict() == {
        "do": [{
            "add": {
                "product": ["Photoshop", "Illustrator"]
            }
        }],
        "usergroup": "SampleUsers"
    }
Exemple #8
0
def test_create_user_group():
    group = UserGroupAction(group_name="Test Group")
    group.create(description="Test Group Description")
    assert group.wire_dict() == {
        'do': [{
            'createUserGroup': {
                'option': 'ignoreIfAlreadyExists',
                'description': 'Test Group Description'
            }
        }],
        'usergroup':
        'Test Group'
    }
Exemple #9
0
def test_update_user_group():
    group = UserGroupAction(group_name="Test Group")
    group.update(name="Renamed Test Group",
                 description="Test Group Description")
    assert group.wire_dict() == {
        'do': [{
            'updateUserGroup': {
                'name': 'Renamed Test Group',
                'description': 'Test Group Description'
            }
        }],
        'usergroup':
        'Test Group'
    }
Exemple #10
0
def test_add_users_unicode():
    group = UserGroupAction(group_name=u"người quản lý")
    group.add_users(
        users=[u"lwałę[email protected]", u"tkolář@test1.on-the-side.net"])
    assert group.wire_dict() == {
        "do": [{
            "add": {
                "user":
                [u"lwałę[email protected]", u"tkolář@test1.on-the-side.net"]
            }
        }],
        "usergroup":
        u"người quản lý"
    }
def test_long_user_group_name():
    long_group_name = """
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna 
    aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur 
    sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
    group = UserGroupAction(group_name=long_group_name)
    with pytest.raises(ArgumentError):
        group.create()
    with pytest.raises(ArgumentError):
        group.update(name=long_group_name)
def test_invalid_user_group_name():
    group = UserGroupAction(group_name="_Invalid Group Name")
    with pytest.raises(ArgumentError):
        group.create()
    with pytest.raises(ArgumentError):
        group.update(name="_Another invalid group name")
def test_create_user_group_error():
    group = UserGroupAction(group_name="Test Group")
    group.create(description="Test Group Description")
    with pytest.raises(ArgumentError):
        group.create()
def test_remove_users_error():
    group = UserGroupAction(group_name="SampleUsers")
    with pytest.raises(ValueError):
        group.remove_users(users=[])
def test_remove_from_products_all_error():
    group = UserGroupAction(group_name="SampleUsers")
    with pytest.raises(ValueError):
        group.remove_from_products(all_products=True, products=["Photoshop"])