|
|
|
@ -2,40 +2,53 @@ import pytest
|
|
|
|
|
from unittest.mock import Mock, patch
|
|
|
|
|
from swarms.models.multion import MultiOn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def multion_instance():
|
|
|
|
|
return MultiOn()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_multion():
|
|
|
|
|
return Mock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multion_import():
|
|
|
|
|
with pytest.raises(ImportError):
|
|
|
|
|
import multion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multion_init():
|
|
|
|
|
multion = MultiOn()
|
|
|
|
|
assert isinstance(multion, MultiOn)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multion_run_with_valid_input(multion_instance, mock_multion):
|
|
|
|
|
task = "Order chicken tendies"
|
|
|
|
|
url = "https://www.google.com/"
|
|
|
|
|
mock_multion.new_session.return_value = "Order chicken tendies. https://www.google.com/"
|
|
|
|
|
mock_multion.new_session.return_value = (
|
|
|
|
|
"Order chicken tendies. https://www.google.com/"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
with patch('swarms.models.multion.multion', mock_multion):
|
|
|
|
|
with patch("swarms.models.multion.multion", mock_multion):
|
|
|
|
|
response = multion_instance.run(task, url)
|
|
|
|
|
|
|
|
|
|
assert response == "Order chicken tendies. https://www.google.com/"
|
|
|
|
|
assert (
|
|
|
|
|
response == "Order chicken tendies. https://www.google.com/"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multion_run_with_invalid_input(multion_instance, mock_multion):
|
|
|
|
|
def test_multion_run_with_invalid_input(
|
|
|
|
|
multion_instance, mock_multion
|
|
|
|
|
):
|
|
|
|
|
task = ""
|
|
|
|
|
url = "https://www.google.com/"
|
|
|
|
|
mock_multion.new_session.return_value = None
|
|
|
|
|
|
|
|
|
|
with patch('swarms.models.multion.multion', mock_multion):
|
|
|
|
|
with patch("swarms.models.multion.multion", mock_multion):
|
|
|
|
|
response = multion_instance.run(task, url)
|
|
|
|
|
|
|
|
|
|
assert response is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add more test cases to cover different scenarios, edge cases, and error handling as needed.
|
|
|
|
|