Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ LICENSE.md
# Files that avoid breaking changes due to renames.
src/merge/resources/accounting/types/currency_enum.py

tests/integration/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we not want to ingore all tests?

tests/integration/test_filestorage.py
tests/integration/test_knowledgebase.py
125 changes: 125 additions & 0 deletions tests/integration/test_filestorage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import os
import pytest
from merge import Merge
from merge.resources.filestorage.types.permission import Permission


@pytest.fixture
def client():
account_token = os.environ["SDK_TESTING_FILE_STORAGE_ACCOUNT_TOKEN"]
api_key = os.environ["SDK_TESTING_KEY"]

return Merge(
account_token=account_token,
api_key=api_key,
)

def test_files_list(client):
response = client.filestorage.files.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)


def test_files_list_permissions(client):

response = client.filestorage.files.list(page_size=1)
assert response.results
file = response.results[0]
first_permission = file.permissions[0]

assert isinstance(first_permission, Permission), type(first_permission)

def test_files_retrieve(client):
files_response = client.filestorage.files.list(page_size=1)

assert files_response.results, "No files available to test retrieve"

file_id = files_response.results[0].id
file = client.filestorage.files.retrieve(id=file_id)

assert file is not None
assert file.id == file_id

def test_sync_status_list(client):
response = client.filestorage.sync_status.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_account_details_retrieve(client):
account_details = client.filestorage.account_details.retrieve()
assert account_details is not None
assert hasattr(account_details, 'id')

def test_drives_list(client):
response = client.filestorage.drives.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_drives_retrieve(client):
drives_response = client.filestorage.drives.list(page_size=1)

assert drives_response.results, "No drives available to test retrieve"
drive_id = drives_response.results[0].id
drive = client.filestorage.drives.retrieve(id=drive_id)
assert drive is not None
assert drive.id == drive_id

def test_folders_list(client):
response = client.filestorage.folders.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_users_list(client):
response = client.filestorage.users.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_users_retrieve(client):
users_response = client.filestorage.users.list(page_size=1)

assert users_response.results, "No users available to test retrieve"

user_id = users_response.results[0].id
user = client.filestorage.users.retrieve(id=user_id)

assert user is not None
assert user.id == user_id

def test_groups_list(client):
response = client.filestorage.groups.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_audit_trail_list(client):
response = client.filestorage.audit_trail.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_available_actions_retrieve(client):
available_actions = client.filestorage.available_actions.retrieve()

assert available_actions is not None

def test_linked_accounts_list(client):
response = client.filestorage.linked_accounts.list()

assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_scopes_default_scopes_retrieve(client):
response = client.filestorage.scopes.default_scopes_retrieve()

assert response is not None

def test_scopes_linked_account_scopes_retrieve(client):
response = client.filestorage.scopes.linked_account_scopes_retrieve()

assert response is not None
177 changes: 177 additions & 0 deletions tests/integration/test_knowledgebase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import os
import pytest
from merge import Merge
from merge.resources.knowledgebase.resources.articles.types.articles_list_request_expand import ArticlesListRequestExpand
from merge.resources.knowledgebase.resources.articles.types.articles_retrieve_request_expand import ArticlesRetrieveRequestExpand
from merge.resources.knowledgebase.resources.containers.types.containers_list_request_expand import ContainersListRequestExpand
from merge.resources.knowledgebase.resources.containers.types.containers_retrieve_request_expand import ContainersRetrieveRequestExpand
from merge.resources.knowledgebase.resources.groups.types.groups_list_request_expand import GroupsListRequestExpand
from merge.resources.knowledgebase.resources.groups.types.groups_retrieve_request_expand import GroupsRetrieveRequestExpand


@pytest.fixture
def client():
account_token = os.environ["SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN"]
api_key = os.environ["SDK_TESTING_KEY"]

return Merge(
account_token=account_token,
api_key=api_key,
)

def test_articles_list(client):
response = client.knowledgebase.articles.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_articles_list_with_expand_author(client):
response = client.knowledgebase.articles.list(expand=ArticlesListRequestExpand.AUTHOR)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_articles_list_with_expand_attachments(client):
response = client.knowledgebase.articles.list(expand=ArticlesListRequestExpand.ATTACHMENTS)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_articles_list_with_expand_permissions(client):
response = client.knowledgebase.articles.list(expand=ArticlesListRequestExpand.PERMISSIONS)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_attachments_list(client):
response = client.knowledgebase.attachments.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_attachments_retrieve(client):
attachments_response = client.knowledgebase.attachments.list(page_size=1)

if attachments_response.results:
attachment_id = attachments_response.results[0].id
attachment = client.knowledgebase.attachments.retrieve(id=attachment_id)
assert attachment is not None
assert attachment.id == attachment_id

def test_containers_list(client):
response = client.knowledgebase.containers.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_containers_retrieve(client):
containers_response = client.knowledgebase.containers.list(page_size=1)

if containers_response.results:
container_id = containers_response.results[0].id
container = client.knowledgebase.containers.retrieve(id=container_id)
assert container is not None
assert container.id == container_id

def test_containers_list_with_expand_permissions(client):
response = client.knowledgebase.containers.list(expand=ContainersListRequestExpand.PERMISSIONS)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_containers_list_with_expand_parent_container(client):
response = client.knowledgebase.containers.list(expand=ContainersListRequestExpand.PARENT_CONTAINER)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_containers_retrieve_with_expand_permissions(client):
containers_response = client.knowledgebase.containers.list(page_size=1)

if containers_response.results:
container_id = containers_response.results[0].id
container = client.knowledgebase.containers.retrieve(id=container_id, expand=ContainersRetrieveRequestExpand.PERMISSIONS)
assert container is not None
assert container.id == container_id

def test_containers_retrieve_with_expand_parent_container(client):
containers_response = client.knowledgebase.containers.list(page_size=1)

if containers_response.results:
container_id = containers_response.results[0].id
container = client.knowledgebase.containers.retrieve(id=container_id, expand=ContainersRetrieveRequestExpand.PARENT_CONTAINER)
assert container is not None
assert container.id == container_id

def test_sync_status_list(client):
response = client.knowledgebase.sync_status.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_account_details_retrieve(client):
account_details = client.knowledgebase.account_details.retrieve()
assert account_details is not None
assert hasattr(account_details, 'id')

def test_users_list(client):
response = client.knowledgebase.users.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_users_retrieve(client):
users_response = client.knowledgebase.users.list(page_size=1)

if users_response.results:
user_id = users_response.results[0].id
user = client.knowledgebase.users.retrieve(id=user_id)

assert user is not None
assert user.id == user_id

def test_groups_list(client):
response = client.knowledgebase.groups.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_groups_list_with_expand_users(client):
response = client.knowledgebase.groups.list(expand=GroupsListRequestExpand.USERS)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_groups_list_with_expand_parent_group(client):
response = client.knowledgebase.groups.list(expand=GroupsListRequestExpand.PARENT_GROUP)
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_audit_trail_list(client):
response = client.knowledgebase.audit_trail.list()
assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_available_actions_retrieve(client):
available_actions = client.knowledgebase.available_actions.retrieve()

assert available_actions is not None

def test_linked_accounts_list(client):
response = client.knowledgebase.linked_accounts.list()

assert response is not None
assert hasattr(response, 'results')
assert isinstance(response.results, list)

def test_scopes_default_scopes_retrieve(client):
response = client.knowledgebase.scopes.default_scopes_retrieve()

assert response is not None

def test_scopes_linked_account_scopes_retrieve(client):
response = client.knowledgebase.scopes.linked_account_scopes_retrieve()

assert response is not None