Skip to content

Commit

Permalink
pytest for upload_sync_test
Browse files Browse the repository at this point in the history
  • Loading branch information
DoKu88 committed Nov 5, 2024
1 parent 2cdeca3 commit d84edab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
# Find all files in the 'Test' directory and join them into a space-separated string
#TEST_SCRIPTS=$(find Test -type f ! -name '__init__.py' -print | tr '\n' ' ')
TEST_SCRIPTS=$(find testing -type f -name '*test_test.py' -print | tr '\n' ' ')
TEST_SCRIPTS=("testing/pytest_test.py", "testing/upload_sync_test.py")
echo "Found test scripts: $TEST_SCRIPTS"
echo "TEST_SCRIPTS=$TEST_SCRIPTS" >> $GITHUB_ENV
- name: Run Tests
Expand Down
16 changes: 5 additions & 11 deletions testing/upload_test_sync.py → testing/upload_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import json
import logging
from pprint import pprint
import pytest

# Configure logging
logging.basicConfig(
Expand Down Expand Up @@ -79,8 +80,8 @@ def generate_payload_from_data(self, dataset: Dataset) -> Dict:
}
return payload


async def run_test(show_payload: bool = False):
@pytest.mark.asyncio
async def test_upload(show_payload: bool = False):
logger.info("Starting run_test")
# Create test agent
agent = TestAgent()
Expand All @@ -99,11 +100,9 @@ async def run_test(show_payload: bool = False):
for i, question in enumerate(questions):
logger.info("Processing question %d: %s", i, question)
try:
# First process in environment ==========================================================
env_result = agent.process_environment(question)
logger.debug("Environment processing result: %s", env_result)

# Then make LM call =====================================================================
response = agent.make_lm_call(question)
responses.append(response)
logger.debug("Response received and stored: %s", response)
Expand Down Expand Up @@ -148,13 +147,6 @@ async def run_test(show_payload: bool = False):
logger.info("Payload sent to server:")
pprint(payload)

try:
assert(payload == agent.generate_payload_from_data(dataset))
logger.info("Payload correct")
except AssertionError:
logger.error("Payload incorrect")
pprint(payload)

except Exception as e:
logger.error("Upload failed: %s", str(e), exc_info=True)
print(f"Upload failed: {str(e)}")
Expand Down Expand Up @@ -192,9 +184,11 @@ async def run_test(show_payload: bool = False):
f"Error during cleanup of event {event_type}: {str(e)}"
)
logger.info("Cleanup completed")
assert payload == agent.generate_payload_from_data(dataset)

# Run a sample agent using the async decorator and tracker
if __name__ == "__main__":
assert 1 + 1 == 2
logger.info("Starting main execution")
asyncio.run(run_test())
logger.info("Main execution completed")
Expand Down

0 comments on commit d84edab

Please sign in to comment.