delete SDK repo and edit readme (#1054)

### What problem does this PR solve?

delete SDK repo and edit readme

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
cecilia-uu
2024-06-04 11:13:26 +08:00
committed by GitHub
parent 037657c1ce
commit 8295979bb2
12 changed files with 65 additions and 93 deletions

View File

@ -2,9 +2,16 @@ from test_sdkbase import TestSdk
import ragflow
from ragflow.ragflow import RAGFLow
import pytest
from unittest.mock import MagicMock
class TestCase(TestSdk):
@pytest.fixture
def ragflow_instance(self):
# Here we create a mock instance of RAGFlow for testing
return ragflow.ragflow.RAGFLow('123', 'url')
def test_version(self):
print(ragflow.__version__)
@ -12,4 +19,33 @@ class TestCase(TestSdk):
assert ragflow.ragflow.RAGFLow('123', 'url').create_dataset('abc') == 'abc'
def test_delete_dataset(self):
assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
assert ragflow.ragflow.RAGFLow('123', 'url').delete_dataset('abc') == 'abc'
def test_list_dataset_success(self, ragflow_instance, monkeypatch):
# Mocking the response of requests.get method
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {'datasets': [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]}
# Patching requests.get to return the mock_response
monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
# Call the method under test
result = ragflow_instance.list_dataset()
# Assertion
assert result == [{'id': 1, 'name': 'dataset1'}, {'id': 2, 'name': 'dataset2'}]
def test_list_dataset_failure(self, ragflow_instance, monkeypatch):
# Mocking the response of requests.get method
mock_response = MagicMock()
mock_response.status_code = 404 # Simulating a failed request
# Patching requests.get to return the mock_response
monkeypatch.setattr("requests.get", MagicMock(return_value=mock_response))
# Call the method under test
result = ragflow_instance.list_dataset()
# Assertion
assert result is None