liuhua liuhua commited on
Commit
8faf53b
Β·
1 Parent(s): a27d105

Add tests for frontend API (#3552)

Browse files

### What problem does this PR solve?

Add tests for frontend API

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: liuhua <[email protected]>

Files changed (23) hide show
  1. .github/workflows/tests.yml +25 -4
  2. sdk/python/test/conftest.py +9 -3
  3. sdk/python/test/{common.py β†’ test_frontend_api/common.py} +0 -0
  4. sdk/python/test/test_frontend_api/get_email.py +3 -0
  5. sdk/python/test/test_frontend_api/test_dataset.py +10 -0
  6. sdk/python/test/test_sdk_api/common.py +2 -0
  7. sdk/python/test/test_sdk_api/get_email.py +3 -0
  8. sdk/python/test/{t_chat.py β†’ test_sdk_api/t_chat.py} +4 -4
  9. sdk/python/test/{t_chunk.py β†’ test_sdk_api/t_chunk.py} +3 -3
  10. sdk/python/test/{t_dataset.py β†’ test_sdk_api/t_dataset.py} +0 -0
  11. sdk/python/test/{t_document.py β†’ test_sdk_api/t_document.py} +11 -11
  12. sdk/python/test/{t_session.py β†’ test_sdk_api/t_session.py} +5 -5
  13. sdk/python/test/{ragflow.txt β†’ test_sdk_api/test_data/ragflow.txt} +0 -0
  14. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/ragflow_test.txt +0 -0
  15. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.docx +0 -0
  16. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.html +0 -0
  17. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.jpg +0 -0
  18. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.json +0 -0
  19. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.md +0 -0
  20. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.pdf +0 -0
  21. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.ppt +0 -0
  22. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.txt +0 -0
  23. sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.xlsx +0 -0
.github/workflows/tests.yml CHANGED
@@ -70,7 +70,7 @@ jobs:
70
  echo "RAGFLOW_IMAGE=infiniflow/ragflow:dev" >> docker/.env
71
  sudo docker compose -f docker/docker-compose.yml up -d
72
 
73
- - name: Run tests against Elasticsearch
74
  run: |
75
  export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
76
  export HOST_ADDRESS=http://host.docker.internal:9380
@@ -78,7 +78,18 @@ jobs:
78
  echo "Waiting for service to be available..."
79
  sleep 5
80
  done
81
- cd sdk/python && poetry install && source .venv/bin/activate && cd test && pytest --tb=short t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  - name: Stop ragflow:dev
84
  if: always() # always run this step even if previous steps failed
@@ -89,7 +100,17 @@ jobs:
89
  run: |
90
  sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d
91
 
92
- - name: Run tests against Infinity
 
 
 
 
 
 
 
 
 
 
93
  run: |
94
  export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
95
  export HOST_ADDRESS=http://host.docker.internal:9380
@@ -97,7 +118,7 @@ jobs:
97
  echo "Waiting for service to be available..."
98
  sleep 5
99
  done
100
- cd sdk/python && poetry install && source .venv/bin/activate && cd test && pytest --tb=short t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py
101
 
102
  - name: Stop ragflow:dev
103
  if: always() # always run this step even if previous steps failed
 
70
  echo "RAGFLOW_IMAGE=infiniflow/ragflow:dev" >> docker/.env
71
  sudo docker compose -f docker/docker-compose.yml up -d
72
 
73
+ - name: Run sdk tests against Elasticsearch
74
  run: |
75
  export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
76
  export HOST_ADDRESS=http://host.docker.internal:9380
 
78
  echo "Waiting for service to be available..."
79
  sleep 5
80
  done
81
+ cd sdk/python && poetry install && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py
82
+
83
+ - name: Run frontend api tests against Elasticsearch
84
+ run: |
85
+ export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
86
+ export HOST_ADDRESS=http://host.docker.internal:9380
87
+ until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
88
+ echo "Waiting for service to be available..."
89
+ sleep 5
90
+ done
91
+ cd sdk/python && poetry install && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py
92
+
93
 
94
  - name: Stop ragflow:dev
95
  if: always() # always run this step even if previous steps failed
 
100
  run: |
101
  sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d
102
 
103
+ - name: Run sdk tests against Infinity
104
+ run: |
105
+ export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
106
+ export HOST_ADDRESS=http://host.docker.internal:9380
107
+ until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do
108
+ echo "Waiting for service to be available..."
109
+ sleep 5
110
+ done
111
+ cd sdk/python && poetry install && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py
112
+
113
+ - name: Run frontend api tests against Infinity
114
  run: |
115
  export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
116
  export HOST_ADDRESS=http://host.docker.internal:9380
 
118
  echo "Waiting for service to be available..."
119
  sleep 5
120
  done
121
+ cd sdk/python && poetry install && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py
122
 
123
  - name: Stop ragflow:dev
124
  if: always() # always run this step even if previous steps failed
sdk/python/test/conftest.py CHANGED
@@ -16,9 +16,6 @@ PASSWORD='''ctAseGvejiaSWWZ88T/m4FQVOpQyUvP+x7sXtdv3feqZACiQleuewkUi35E16wSd5C5Q
16
  fN33jCHRoDUW81IH9zjij/vaw8IbVyb6vuwg6MX6inOEBRRzVbRYxXOu1wkWY6SsI8X70oF9aeLFp/PzQpjoe/YbSqpTq8qqrmHzn9vO+yvyYyvmDsphXe
17
  X8f7fp9c7vUsfOCkM+gHY3PadG+QHa7KI7mzTKgUTZImK6BZtfRBATDTthEUbbaTewY4H0MnWiCeeDhcbeQao6cFy1To8pE3RpmxnGnS8BsBn8w=='''
18
 
19
- def get_email():
20
- return EMAIL
21
-
22
  def register():
23
  url = HOST_ADDRESS + "/v1/user/register"
24
  name = "user"
@@ -50,3 +47,12 @@ def get_api_key_fixture():
50
  raise Exception(res.get("message"))
51
  return res["data"].get("token")
52
 
 
 
 
 
 
 
 
 
 
 
16
  fN33jCHRoDUW81IH9zjij/vaw8IbVyb6vuwg6MX6inOEBRRzVbRYxXOu1wkWY6SsI8X70oF9aeLFp/PzQpjoe/YbSqpTq8qqrmHzn9vO+yvyYyvmDsphXe
17
  X8f7fp9c7vUsfOCkM+gHY3PadG+QHa7KI7mzTKgUTZImK6BZtfRBATDTthEUbbaTewY4H0MnWiCeeDhcbeQao6cFy1To8pE3RpmxnGnS8BsBn8w=='''
18
 
 
 
 
19
  def register():
20
  url = HOST_ADDRESS + "/v1/user/register"
21
  name = "user"
 
47
  raise Exception(res.get("message"))
48
  return res["data"].get("token")
49
 
50
+ @pytest.fixture(scope="session")
51
+ def get_auth():
52
+ register()
53
+ auth = login()
54
+ return auth
55
+
56
+ @pytest.fixture(scope="session")
57
+ def get_email():
58
+ return EMAIL
sdk/python/test/{common.py β†’ test_frontend_api/common.py} RENAMED
File without changes
sdk/python/test/test_frontend_api/get_email.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ def test_get_email(get_email):
2
+ print(f"\nEmail account:",flush=True)
3
+ print(f"{get_email}\n",flush=True)
sdk/python/test/test_frontend_api/test_dataset.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from common import HOST_ADDRESS
2
+ import requests
3
+ def test_create_dataset(get_auth):
4
+ authorization={"Authorization": get_auth}
5
+ url = f"{HOST_ADDRESS}/v1/kb/create"
6
+ json = {"name":"test_create_dataset"}
7
+ res = requests.post(url=url,headers=authorization,json=json)
8
+ res = res.json()
9
+ assert res.get("code") == 0,f"{res.get('message')}"
10
+
sdk/python/test/test_sdk_api/common.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import os
2
+ HOST_ADDRESS=os.getenv('HOST_ADDRESS', 'http://127.0.0.1:9380')
sdk/python/test/test_sdk_api/get_email.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ def test_get_email(get_email):
2
+ print(f"\nEmail account:",flush=True)
3
+ print(f"{get_email}\n",flush=True)
sdk/python/test/{t_chat.py β†’ test_sdk_api/t_chat.py} RENAMED
@@ -6,7 +6,7 @@ def test_create_chat_with_name(get_api_key_fixture):
6
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
7
  kb = rag.create_dataset(name="test_create_chat")
8
  displayed_name = "ragflow.txt"
9
- with open("ragflow.txt", "rb") as file:
10
  blob = file.read()
11
  document = {"displayed_name":displayed_name,"blob":blob}
12
  documents = []
@@ -22,7 +22,7 @@ def test_update_chat_with_name(get_api_key_fixture):
22
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
23
  kb = rag.create_dataset(name="test_update_chat")
24
  displayed_name = "ragflow.txt"
25
- with open("ragflow.txt", "rb") as file:
26
  blob = file.read()
27
  document = {"displayed_name": displayed_name, "blob": blob}
28
  documents = []
@@ -39,7 +39,7 @@ def test_delete_chats_with_success(get_api_key_fixture):
39
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
40
  kb = rag.create_dataset(name="test_delete_chat")
41
  displayed_name = "ragflow.txt"
42
- with open("ragflow.txt", "rb") as file:
43
  blob = file.read()
44
  document = {"displayed_name": displayed_name, "blob": blob}
45
  documents = []
@@ -55,7 +55,7 @@ def test_list_chats_with_success(get_api_key_fixture):
55
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
56
  kb = rag.create_dataset(name="test_list_chats")
57
  displayed_name = "ragflow.txt"
58
- with open("ragflow.txt", "rb") as file:
59
  blob = file.read()
60
  document = {"displayed_name": displayed_name, "blob": blob}
61
  documents = []
 
6
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
7
  kb = rag.create_dataset(name="test_create_chat")
8
  displayed_name = "ragflow.txt"
9
+ with open("test_data/ragflow.txt", "rb") as file:
10
  blob = file.read()
11
  document = {"displayed_name":displayed_name,"blob":blob}
12
  documents = []
 
22
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
23
  kb = rag.create_dataset(name="test_update_chat")
24
  displayed_name = "ragflow.txt"
25
+ with open("test_data/ragflow.txt", "rb") as file:
26
  blob = file.read()
27
  document = {"displayed_name": displayed_name, "blob": blob}
28
  documents = []
 
39
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
40
  kb = rag.create_dataset(name="test_delete_chat")
41
  displayed_name = "ragflow.txt"
42
+ with open("test_data/ragflow.txt", "rb") as file:
43
  blob = file.read()
44
  document = {"displayed_name": displayed_name, "blob": blob}
45
  documents = []
 
55
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
56
  kb = rag.create_dataset(name="test_list_chats")
57
  displayed_name = "ragflow.txt"
58
+ with open("test_data/ragflow.txt", "rb") as file:
59
  blob = file.read()
60
  document = {"displayed_name": displayed_name, "blob": blob}
61
  documents = []
sdk/python/test/{t_chunk.py β†’ test_sdk_api/t_chunk.py} RENAMED
@@ -7,7 +7,7 @@ def test_parse_document_with_txt(get_api_key_fixture):
7
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
8
  ds = rag.create_dataset(name="test_parse_document")
9
  name = 'ragflow_test.txt'
10
- with open("test_data/ragflow_test.txt","rb") as file :
11
  blob = file.read()
12
  docs = ds.upload_documents([{"displayed_name": name, "blob": blob}])
13
  doc = docs[0]
@@ -26,7 +26,7 @@ def test_parse_and_cancel_document(get_api_key_fixture):
26
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
27
  ds = rag.create_dataset(name="test_parse_and_cancel_document")
28
  name = 'ragflow_test.txt'
29
- with open("test_data/ragflow_test.txt","rb") as file :
30
  blob = file.read()
31
  docs=ds.upload_documents([{"displayed_name": name, "blob": blob}])
32
  doc = docs[0]
@@ -40,7 +40,7 @@ def test_bulk_parse_documents(get_api_key_fixture):
40
  API_KEY = get_api_key_fixture
41
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
42
  ds = rag.create_dataset(name="test_bulk_parse_and_cancel_documents")
43
- with open("ragflow.txt","rb") as file:
44
  blob = file.read()
45
  documents = [
46
  {'displayed_name': 'test1.txt', 'blob': blob},
 
7
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
8
  ds = rag.create_dataset(name="test_parse_document")
9
  name = 'ragflow_test.txt'
10
+ with open("test_data/ragflow_test.txt", "rb") as file :
11
  blob = file.read()
12
  docs = ds.upload_documents([{"displayed_name": name, "blob": blob}])
13
  doc = docs[0]
 
26
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
27
  ds = rag.create_dataset(name="test_parse_and_cancel_document")
28
  name = 'ragflow_test.txt'
29
+ with open("test_data/ragflow_test.txt", "rb") as file :
30
  blob = file.read()
31
  docs=ds.upload_documents([{"displayed_name": name, "blob": blob}])
32
  doc = docs[0]
 
40
  API_KEY = get_api_key_fixture
41
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
42
  ds = rag.create_dataset(name="test_bulk_parse_and_cancel_documents")
43
+ with open("test_data/ragflow.txt", "rb") as file:
44
  blob = file.read()
45
  documents = [
46
  {'displayed_name': 'test1.txt', 'blob': blob},
sdk/python/test/{t_dataset.py β†’ test_sdk_api/t_dataset.py} RENAMED
File without changes
sdk/python/test/{t_document.py β†’ test_sdk_api/t_document.py} RENAMED
@@ -7,7 +7,7 @@ def test_upload_document_with_success(get_api_key_fixture):
7
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
8
  ds = rag.create_dataset(name="test_upload_document")
9
  blob = b"Sample document content for test."
10
- with open("ragflow.txt","rb") as file:
11
  blob_2=file.read()
12
  document_infos = []
13
  document_infos.append({"displayed_name": "test_1.txt","blob": blob})
@@ -63,7 +63,7 @@ def test_upload_and_parse_pdf_documents_with_general_parse_method(get_api_key_fi
63
  API_KEY = get_api_key_fixture
64
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
65
  ds = rag.create_dataset(name="test_pdf_document")
66
- with open("test_data/test.pdf","rb") as file:
67
  blob=file.read()
68
  document_infos = [{"displayed_name": "test.pdf","blob": blob}]
69
  docs=ds.upload_documents(document_infos)
@@ -74,7 +74,7 @@ def test_upload_and_parse_docx_documents_with_general_parse_method(get_api_key_f
74
  API_KEY = get_api_key_fixture
75
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
76
  ds = rag.create_dataset(name="test_docx_document")
77
- with open("test_data/test.docx","rb") as file:
78
  blob=file.read()
79
  document_infos = [{"displayed_name": "test.docx","blob": blob}]
80
  docs=ds.upload_documents(document_infos)
@@ -84,7 +84,7 @@ def test_upload_and_parse_excel_documents_with_general_parse_method(get_api_key_
84
  API_KEY = get_api_key_fixture
85
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
86
  ds = rag.create_dataset(name="test_excel_document")
87
- with open("test_data/test.xlsx","rb") as file:
88
  blob=file.read()
89
  document_infos = [{"displayed_name": "test.xlsx","blob": blob}]
90
  docs=ds.upload_documents(document_infos)
@@ -94,7 +94,7 @@ def test_upload_and_parse_ppt_documents_with_general_parse_method(get_api_key_fi
94
  API_KEY = get_api_key_fixture
95
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
96
  ds = rag.create_dataset(name="test_ppt_document")
97
- with open("test_data/test.ppt","rb") as file:
98
  blob=file.read()
99
  document_infos = [{"displayed_name": "test.ppt","blob": blob}]
100
  docs=ds.upload_documents(document_infos)
@@ -104,7 +104,7 @@ def test_upload_and_parse_image_documents_with_general_parse_method(get_api_key_
104
  API_KEY = get_api_key_fixture
105
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
106
  ds = rag.create_dataset(name="test_image_document")
107
- with open("test_data/test.jpg","rb") as file:
108
  blob=file.read()
109
  document_infos = [{"displayed_name": "test.jpg","blob": blob}]
110
  docs=ds.upload_documents(document_infos)
@@ -114,7 +114,7 @@ def test_upload_and_parse_txt_documents_with_general_parse_method(get_api_key_fi
114
  API_KEY = get_api_key_fixture
115
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
116
  ds = rag.create_dataset(name="test_txt_document")
117
- with open("test_data/test.txt","rb") as file:
118
  blob=file.read()
119
  document_infos = [{"displayed_name": "test.txt","blob": blob}]
120
  docs=ds.upload_documents(document_infos)
@@ -124,7 +124,7 @@ def test_upload_and_parse_md_documents_with_general_parse_method(get_api_key_fix
124
  API_KEY = get_api_key_fixture
125
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
126
  ds = rag.create_dataset(name="test_md_document")
127
- with open("test_data/test.md","rb") as file:
128
  blob=file.read()
129
  document_infos = [{"displayed_name": "test.md","blob": blob}]
130
  docs=ds.upload_documents(document_infos)
@@ -135,7 +135,7 @@ def test_upload_and_parse_json_documents_with_general_parse_method(get_api_key_f
135
  API_KEY = get_api_key_fixture
136
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
137
  ds = rag.create_dataset(name="test_json_document")
138
- with open("test_data/test.json","rb") as file:
139
  blob=file.read()
140
  document_infos = [{"displayed_name": "test.json","blob": blob}]
141
  docs=ds.upload_documents(document_infos)
@@ -147,7 +147,7 @@ def test_upload_and_parse_eml_documents_with_general_parse_method(get_api_key_fi
147
  API_KEY = get_api_key_fixture
148
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
149
  ds = rag.create_dataset(name="test_eml_document")
150
- with open("test_data/test.eml","rb") as file:
151
  blob=file.read()
152
  document_infos = [{"displayed_name": "test.eml","blob": blob}]
153
  docs=ds.upload_documents(document_infos)
@@ -158,7 +158,7 @@ def test_upload_and_parse_html_documents_with_general_parse_method(get_api_key_f
158
  API_KEY = get_api_key_fixture
159
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
160
  ds = rag.create_dataset(name="test_html_document")
161
- with open("test_data/test.html","rb") as file:
162
  blob=file.read()
163
  document_infos = [{"displayed_name": "test.html","blob": blob}]
164
  docs=ds.upload_documents(document_infos)
 
7
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
8
  ds = rag.create_dataset(name="test_upload_document")
9
  blob = b"Sample document content for test."
10
+ with open("test_data/ragflow.txt", "rb") as file:
11
  blob_2=file.read()
12
  document_infos = []
13
  document_infos.append({"displayed_name": "test_1.txt","blob": blob})
 
63
  API_KEY = get_api_key_fixture
64
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
65
  ds = rag.create_dataset(name="test_pdf_document")
66
+ with open("test_data/test.pdf", "rb") as file:
67
  blob=file.read()
68
  document_infos = [{"displayed_name": "test.pdf","blob": blob}]
69
  docs=ds.upload_documents(document_infos)
 
74
  API_KEY = get_api_key_fixture
75
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
76
  ds = rag.create_dataset(name="test_docx_document")
77
+ with open("test_data/test.docx", "rb") as file:
78
  blob=file.read()
79
  document_infos = [{"displayed_name": "test.docx","blob": blob}]
80
  docs=ds.upload_documents(document_infos)
 
84
  API_KEY = get_api_key_fixture
85
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
86
  ds = rag.create_dataset(name="test_excel_document")
87
+ with open("test_data/test.xlsx", "rb") as file:
88
  blob=file.read()
89
  document_infos = [{"displayed_name": "test.xlsx","blob": blob}]
90
  docs=ds.upload_documents(document_infos)
 
94
  API_KEY = get_api_key_fixture
95
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
96
  ds = rag.create_dataset(name="test_ppt_document")
97
+ with open("test_data/test.ppt", "rb") as file:
98
  blob=file.read()
99
  document_infos = [{"displayed_name": "test.ppt","blob": blob}]
100
  docs=ds.upload_documents(document_infos)
 
104
  API_KEY = get_api_key_fixture
105
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
106
  ds = rag.create_dataset(name="test_image_document")
107
+ with open("test_data/test.jpg", "rb") as file:
108
  blob=file.read()
109
  document_infos = [{"displayed_name": "test.jpg","blob": blob}]
110
  docs=ds.upload_documents(document_infos)
 
114
  API_KEY = get_api_key_fixture
115
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
116
  ds = rag.create_dataset(name="test_txt_document")
117
+ with open("test_data/test.txt", "rb") as file:
118
  blob=file.read()
119
  document_infos = [{"displayed_name": "test.txt","blob": blob}]
120
  docs=ds.upload_documents(document_infos)
 
124
  API_KEY = get_api_key_fixture
125
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
126
  ds = rag.create_dataset(name="test_md_document")
127
+ with open("test_data/test.md", "rb") as file:
128
  blob=file.read()
129
  document_infos = [{"displayed_name": "test.md","blob": blob}]
130
  docs=ds.upload_documents(document_infos)
 
135
  API_KEY = get_api_key_fixture
136
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
137
  ds = rag.create_dataset(name="test_json_document")
138
+ with open("test_data/test.json", "rb") as file:
139
  blob=file.read()
140
  document_infos = [{"displayed_name": "test.json","blob": blob}]
141
  docs=ds.upload_documents(document_infos)
 
147
  API_KEY = get_api_key_fixture
148
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
149
  ds = rag.create_dataset(name="test_eml_document")
150
+ with open("test_data/test.eml", "rb") as file:
151
  blob=file.read()
152
  document_infos = [{"displayed_name": "test.eml","blob": blob}]
153
  docs=ds.upload_documents(document_infos)
 
158
  API_KEY = get_api_key_fixture
159
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
160
  ds = rag.create_dataset(name="test_html_document")
161
+ with open("test_data/test.html", "rb") as file:
162
  blob=file.read()
163
  document_infos = [{"displayed_name": "test.html","blob": blob}]
164
  docs=ds.upload_documents(document_infos)
sdk/python/test/{t_session.py β†’ test_sdk_api/t_session.py} RENAMED
@@ -8,7 +8,7 @@ def test_create_session_with_success(get_api_key_fixture):
8
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
9
  kb = rag.create_dataset(name="test_create_session")
10
  displayed_name = "ragflow.txt"
11
- with open("ragflow.txt", "rb") as file:
12
  blob = file.read()
13
  document = {"displayed_name":displayed_name,"blob":blob}
14
  documents = []
@@ -25,7 +25,7 @@ def test_create_conversation_with_success(get_api_key_fixture):
25
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
26
  kb = rag.create_dataset(name="test_create_conversation")
27
  displayed_name = "ragflow.txt"
28
- with open("ragflow.txt", "rb") as file:
29
  blob = file.read()
30
  document = {"displayed_name": displayed_name, "blob": blob}
31
  documents = []
@@ -47,7 +47,7 @@ def test_delete_sessions_with_success(get_api_key_fixture):
47
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
48
  kb = rag.create_dataset(name="test_delete_session")
49
  displayed_name = "ragflow.txt"
50
- with open("ragflow.txt", "rb") as file:
51
  blob = file.read()
52
  document = {"displayed_name":displayed_name,"blob":blob}
53
  documents = []
@@ -65,7 +65,7 @@ def test_update_session_with_name(get_api_key_fixture):
65
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
66
  kb = rag.create_dataset(name="test_update_session")
67
  displayed_name = "ragflow.txt"
68
- with open("ragflow.txt", "rb") as file:
69
  blob = file.read()
70
  document = {"displayed_name": displayed_name, "blob": blob}
71
  documents = []
@@ -83,7 +83,7 @@ def test_list_sessions_with_success(get_api_key_fixture):
83
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
84
  kb = rag.create_dataset(name="test_list_session")
85
  displayed_name = "ragflow.txt"
86
- with open("ragflow.txt", "rb") as file:
87
  blob = file.read()
88
  document = {"displayed_name":displayed_name,"blob":blob}
89
  documents = []
 
8
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
9
  kb = rag.create_dataset(name="test_create_session")
10
  displayed_name = "ragflow.txt"
11
+ with open("test_data/ragflow.txt", "rb") as file:
12
  blob = file.read()
13
  document = {"displayed_name":displayed_name,"blob":blob}
14
  documents = []
 
25
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
26
  kb = rag.create_dataset(name="test_create_conversation")
27
  displayed_name = "ragflow.txt"
28
+ with open("test_data/ragflow.txt", "rb") as file:
29
  blob = file.read()
30
  document = {"displayed_name": displayed_name, "blob": blob}
31
  documents = []
 
47
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
48
  kb = rag.create_dataset(name="test_delete_session")
49
  displayed_name = "ragflow.txt"
50
+ with open("test_data/ragflow.txt", "rb") as file:
51
  blob = file.read()
52
  document = {"displayed_name":displayed_name,"blob":blob}
53
  documents = []
 
65
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
66
  kb = rag.create_dataset(name="test_update_session")
67
  displayed_name = "ragflow.txt"
68
+ with open("test_data/ragflow.txt", "rb") as file:
69
  blob = file.read()
70
  document = {"displayed_name": displayed_name, "blob": blob}
71
  documents = []
 
83
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
84
  kb = rag.create_dataset(name="test_list_session")
85
  displayed_name = "ragflow.txt"
86
+ with open("test_data/ragflow.txt", "rb") as file:
87
  blob = file.read()
88
  document = {"displayed_name":displayed_name,"blob":blob}
89
  documents = []
sdk/python/test/{ragflow.txt β†’ test_sdk_api/test_data/ragflow.txt} RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/ragflow_test.txt RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.docx RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.html RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.jpg RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.json RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.md RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.pdf RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.ppt RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.txt RENAMED
File without changes
sdk/python/test/{test_data β†’ test_sdk_api/test_data}/test.xlsx RENAMED
File without changes