tests: improve RAGFlow coverage based on Codecov report (#13200)

### What problem does this PR solve?

Codecov’s coverage report shows that several RAGFlow code paths are
currently untested or under-tested. This makes it easier for regressions
to slip in during refactors and feature work.
This PR adds targeted automated tests to cover the files and branches
highlighted by Codecov, improving confidence in core behavior while
keeping runtime functionality unchanged.

### Type of change

- [x] Other (please describe): Test coverage improvement (adds/extends
unit and integration tests to address Codecov-reported gaps)
This commit is contained in:
6ba3i
2026-02-25 19:12:11 +08:00
committed by GitHub
parent 2a5ddf064d
commit 38011f2c16
56 changed files with 11453 additions and 17 deletions

View File

@@ -20,8 +20,6 @@ import pytest
from test_web_api.common import create_memory
from configs import INVALID_API_TOKEN
from libs.auth import RAGFlowWebApiAuth
from hypothesis import example, given, settings
from utils.hypothesis_utils import valid_names
class TestAuthorization:
@@ -42,9 +40,7 @@ class TestAuthorization:
class TestMemoryCreate:
@pytest.mark.p1
@given(name=valid_names())
@example("d" * 128)
@settings(max_examples=20)
@pytest.mark.parametrize("name", ["test_memory_name", "d" * 128])
def test_name(self, WebApiAuth, name):
payload = {
"name": name,
@@ -79,7 +75,7 @@ class TestMemoryCreate:
assert res["message"] == expected_message, res
@pytest.mark.p2
@given(name=valid_names())
@pytest.mark.parametrize("name", ["invalid_type_name", "memory_alpha"])
def test_type_invalid(self, WebApiAuth, name):
payload = {
"name": name,

View File

@@ -13,14 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import re
import pytest
from test_web_api.common import update_memory
from configs import INVALID_API_TOKEN
from libs.auth import RAGFlowWebApiAuth
from hypothesis import HealthCheck, example, given, settings
from utils import encode_avatar
from utils.file_utils import create_image_file
from utils.hypothesis_utils import valid_names
class TestAuthorization:
@@ -42,15 +42,14 @@ class TestAuthorization:
class TestMemoryUpdate:
@pytest.mark.p1
@given(name=valid_names())
@example("f" * 128)
@settings(max_examples=20, suppress_health_check=[HealthCheck.function_scoped_fixture])
@pytest.mark.parametrize("name", ["updated_memory", "f" * 128])
def test_name(self, WebApiAuth, add_memory_func, name):
memory_ids = add_memory_func
payload = {"name": name}
res = update_memory(WebApiAuth, memory_ids[0], payload)
assert res["code"] == 0, res
assert res["data"]["name"] == name, res
pattern = rf"^{re.escape(name)}(?:\(\d+\))?$"
assert re.match(pattern, res["data"]["name"]), res
@pytest.mark.p2
@pytest.mark.parametrize(