mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 21:13:49 +08:00
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:
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user