コード例 #1
0
ファイル: test_model_sql.py プロジェクト: chenbillcat/AuthDog
    def test_get_group(self):
        write_test_data()
        session = connection.get_session()
        group_api = GroupApi(session)
        group = group_api.get_group(group_id="1")
        assert group.get("name") == "test_group1"

        try:
            group = group_api.get_group(group_id="5")
        except exception.GroupNotFound as e:
            assert isinstance(e, exception.GroupNotFound)
        else:
            raise Exception("GroupNotFound didn't happen")
コード例 #2
0
ファイル: test_model_sql.py プロジェクト: chenbillcat/AuthDog
    def test_update_group(self):
        write_test_data()
        session = connection.get_session()
        group_api = GroupApi(session)
        group = {"name": "group_update"}
        group_api.update_group("2", group)
        g = group_api.get_group("2")
        assert g.get("name") == "group_update"

        try:
            group = {"name": "test_group1"}
            group_api.update_group("2", group)
        except exception.Conflict as e:
            assert isinstance(e, exception.Conflict)
        else:
            raise Exception("Conflict didn't happen")
コード例 #3
0
ファイル: test_model_sql.py プロジェクト: chenbillcat/AuthDog
    def test_delete_group(self):
        write_test_data()
        session = connection.get_session()
        group_api = GroupApi(session)
        ugms = group_api.list_user_group_membership(group_id="2")
        assert len(ugms) == 2
        grms = group_api.list_group_role_membership(group_id="2")
        assert len(grms) == 3

        group_api.delete_group(group_id="2")
        try:
            group = group_api.get_group(group_id="2")
        except exception.GroupNotFound as e:
            assert isinstance(e, exception.GroupNotFound)
        else:
            raise Exception("GroupNotFound didn't happen")

        ugms = session.query(default_model.UserGroupMembership).filter_by(group_id="2").all()
        assert len(ugms) == 0
        grms = session.query(default_model.GroupRoleMembership).filter_by(group_id="2").all()
        assert len(grms) == 0