# Path: sevenbridges/errors.py
# class SbgError(Exception):
#     """Base class for SBG errors.
# 
#     Provides a base exception for all errors
#     that are thrown by sevenbridges-python library.
#     """
# 
#     def __init__(self, message=None, code=None, status=None, more_info=None):
#         """
#         :param code: Custom error code
#         :param status: Http status code.
#         :param message: Message describing the error.
#         """
#         self.code = code
#         self.status = status
#         self.message = message
#         self.more_info = more_info
# 
#     def __str__(self):
#         return str(self.message)
# 
# class ResourceNotModified(SbgError):
#     def __init__(self):
#         super().__init__(
#             code=-1,
#             status=-1,
#             message=(
#                 'No relevant changes were detected in order to update the '
#                 'resource on the server.'
#             )
#         )


import faker
import pytest
from sevenbridges.errors import SbgError, ResourceNotModified
    given.project.has_member(id, project_name, member_username)

    # action
    project = api.projects.get(id)
    member = project.get_member(member_username)

    # verification
    assert member.username == member_username
    verifier.project.member_retrieved(id, member_username)


def test_project_add_member(api, given, verifier):
    # preconditions
    owner = generator.user_name()
    project_short_name = generator.slug()
    id = f'{owner}/{project_short_name}'
    username = generator.user_name()
    given.project.exists(id=id)
    mocked_member = given.member.member_exist(project=id, username=username)

    # action
    project = api.projects.get(id)
    member = project.add_member(mocked_member['username'],
                                mocked_member['permissions'])
    assert member.username == mocked_member['username']
    assert member.permissions['write'] == mocked_member['permissions']['write']
    assert member.permissions['read'] == mocked_member['permissions']['read']
    assert member.permissions['copy'] == mocked_member['permissions']['copy']
    assert member.permissions['execute'] == mocked_member['permissions'][
        'execute']

# Path: sevenbridges/errors.py
# class SbgError(Exception):
#     """Base class for SBG errors.
# 
#     Provides a base exception for all errors
#     that are thrown by sevenbridges-python library.
#     """
# 
#     def __init__(self, message=None, code=None, status=None, more_info=None):
#         """
#         :param code: Custom error code
#         :param status: Http status code.
#         :param message: Message describing the error.
#         """
#         self.code = code
#         self.status = status
#         self.message = message
#         self.more_info = more_info
# 
#     def __str__(self):
#         return str(self.message)
# 
# class ResourceNotModified(SbgError):
#     def __init__(self):
#         super().__init__(
#             code=-1,
#             status=-1,
#             message=(
#                 'No relevant changes were detected in order to update the '
#                 'resource on the server.'
#             )
#         )


# Path: tests/test_projects.py
import faker
import pytest
from sevenbridges.errors import SbgError, ResourceNotModified

    given.project.has_member(id, project_name, member_username)

    # action
    project = api.projects.get(id)
    member = project.get_member(member_username)

    # verification
    assert member.username == member_username
    verifier.project.member_retrieved(id, member_username)


def test_project_add_member(api, given, verifier):
    # preconditions
    owner = generator.user_name()
    project_short_name = generator.slug()
    id = f'{owner}/{project_short_name}'
    username = generator.user_name()
    given.project.exists(id=id)
    mocked_member = given.member.member_exist(project=id, username=username)

    # action
    project = api.projects.get(id)
    member = project.add_member(mocked_member['username'],
                                mocked_member['permissions'])
    assert member.username == mocked_member['username']
    assert member.permissions['write'] == mocked_member['permissions']['write']
    assert member.permissions['read'] == mocked_member['permissions']['read']
    assert member.permissions['copy'] == mocked_member['permissions']['copy']
    assert member.permissions['execute'] == mocked_member['permissions'][
        'execute']

    assert member.permissions['admin'] == mocked_member['permissions']['admin']