Skip to content

Commit

Permalink
Models Uninstall Test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jedan2506 committed Sep 18, 2023
1 parent c33afe3 commit 3e41582
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/unit_tests/controllers/test_models_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ def test_get_marketplace_models_list_success(mock_get_db):
patch('superagi.helper.auth.db') as mock_auth_db:
response = client.get("/models_controller/marketplace/list/0")
assert response.status_code == 200


@patch('superagi.controllers.models_controller.db')
def test_delete_model(mock_get_db):
request = {
"model": "model_name"
}
with patch('superagi.helper.auth.get_user_organisation') as mock_get_user_org, \
patch('superagi.helper.auth.db') as mock_auth_db:
response = client.post("/models_controller/delete_model", json=request)
assert response.status_code == 200
19 changes: 19 additions & 0 deletions tests/unit_tests/models/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,23 @@ def test_fetch_model_details(mock_models_config, mock_session):
"model_provider": "example_provider"
}

@patch('superagi.models.models.Models')
def test_delete_model_when_model_exists(mock_session):
# Arrange
mock_existing_model = MagicMock()
mock_session.query.return_value.filter.return_value.first.return_value = mock_existing_model
mock_session.commit = MagicMock()

# Act
response = Models.delete_model(
mock_session,
organisation_id=1,
model_name="example_model",
)

# Assert
assert response == {"success": "Model has been Successfully Uninstalled"}
assert mock_existing_model.state == IsInstalled.UNINSTALLED.value
mock_session.commit.assert_called_once()


0 comments on commit 3e41582

Please sign in to comment.