-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from rogers-obrien-rad/feature/37/corresponden…
…ce-tests Feature/37/correspondence tests
- Loading branch information
Showing
3 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import pytest | ||
from propycore.procore import Procore | ||
from dotenv import load_dotenv | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
|
||
# Fixture for Procore connection | ||
@pytest.fixture | ||
def procore_connection(): | ||
return Procore( | ||
client_id=os.getenv("CLIENT_ID"), | ||
client_secret=os.getenv("CLIENT_SECRET"), | ||
redirect_uri=os.getenv("REDIRECT_URI"), | ||
oauth_url=os.getenv("OAUTH_URL"), | ||
base_url=os.getenv("BASE_URL") | ||
) | ||
|
||
def test_procore_integration(procore_connection): | ||
# Get IDs for company, project, and tool | ||
company = procore_connection.__companies__.find(identifier="Rogers-O`Brien Construction") | ||
project = procore_connection.__projects__.find( | ||
company_id=company["id"], | ||
identifier="Sandbox Test Project" | ||
) | ||
tool = procore_connection.__tools__.find_tool( | ||
company_id=company["id"], | ||
identifier="Idea Submission" | ||
) | ||
|
||
assert company is not None | ||
assert project is not None | ||
assert tool is not None | ||
|
||
# Example 1: list all items for idea submission tool | ||
tool_items = procore_connection.__tools__.get_tool_items( | ||
company_id=company["id"], | ||
project_id=project["id"], | ||
tool_id=tool["id"] | ||
) | ||
|
||
assert isinstance(tool_items, list) # or any other assertion based on expected response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from unittest.mock import MagicMock | ||
from propycore.access.generic_tools import GenericTool | ||
from propycore.exceptions import NotFoundItemError | ||
|
||
# Fixture for GenericTool instance | ||
@pytest.fixture | ||
def generic_tool_instance(): | ||
return GenericTool('mock_access_token', 'mock_server_url') | ||
|
||
# Test for get_tools method | ||
def test_get_tools(generic_tool_instance): | ||
# Mock the get_request method | ||
mock_response = [{'id': 1, 'title': 'Tool 1'}, {'id': 2, 'title': 'Tool 2'}] | ||
generic_tool_instance.get_request = MagicMock(return_value=mock_response) | ||
|
||
response = generic_tool_instance.get_tools(123) | ||
|
||
assert isinstance(response, list) | ||
assert response == mock_response | ||
|
||
# Test for find_tool by id | ||
def test_find_tool_by_id(generic_tool_instance): | ||
# Mock the get_tools method | ||
mock_response = [{'id': 1, 'title': 'Tool 1'}, {'id': 2, 'title': 'Tool 2'}] | ||
generic_tool_instance.get_tools = MagicMock(return_value=mock_response) | ||
|
||
tool = generic_tool_instance.find_tool(123, 1) | ||
|
||
assert tool == {'id': 1, 'title': 'Tool 1'} | ||
|
||
# Test for find_tool by title | ||
def test_find_tool_by_title(generic_tool_instance): | ||
# Mock the get_tools method | ||
mock_response = [{'id': 1, 'title': 'Tool 1'}, {'id': 2, 'title': 'Tool 2'}] | ||
generic_tool_instance.get_tools = MagicMock(return_value=mock_response) | ||
|
||
tool = generic_tool_instance.find_tool(123, 'Tool 2') | ||
|
||
assert tool == {'id': 2, 'title': 'Tool 2'} |