File size: 1,954 Bytes
0874636
7889c99
 
 
 
 
 
 
0874636
cf772f7
0874636
7889c99
 
0874636
 
 
 
7889c99
0874636
7889c99
cf772f7
7889c99
 
 
0874636
cf772f7
2e482fd
 
cf772f7
 
0874636
40a1db3
cf772f7
 
 
 
 
 
 
40a1db3
2e482fd
0874636
cf772f7
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from ragflow import RAGFlow, DataSet

from common import API_KEY, HOST_ADDRESS
from test_sdkbase import TestSdk


class TestDataset(TestSdk):
    def test_create_dataset_with_success(self):
        """

        Test creating a dataset with success

        """
        rag = RAGFlow(API_KEY, HOST_ADDRESS)
        ds = rag.create_dataset("God")
        if isinstance(ds, DataSet):
            assert ds.name == "God", "Name does not match."
        else:
            assert False, f"Failed to create dataset, error: {ds}"

    def test_update_dataset_with_success(self):
        """

        Test updating a dataset with success.

        """
        rag = RAGFlow(API_KEY, HOST_ADDRESS)
        ds = rag.create_dataset("ABC")
        if isinstance(ds, DataSet):
            assert ds.name == "ABC", "Name does not match."
            res = ds.update({"name":"DEF"})
            assert res is None, f"Failed to update dataset, error: {res}"
        else:
            assert False, f"Failed to create dataset, error: {ds}"

    def test_delete_datasets_with_success(self):
        """

        Test deleting a dataset with success

        """
        rag = RAGFlow(API_KEY, HOST_ADDRESS)
        ds = rag.create_dataset("MA")
        if isinstance(ds, DataSet):
            assert ds.name == "MA", "Name does not match."
            res = rag.delete_datasets(ids=[ds.id])
            assert res is None, f"Failed to delete dataset, error: {res}"
        else:
            assert False, f"Failed to create dataset, error: {ds}"

    def test_list_datasets_with_success(self):
        """

        Test listing datasets with success

        """
        rag = RAGFlow(API_KEY, HOST_ADDRESS)
        list_datasets = rag.list_datasets()
        assert len(list_datasets) > 0, "Do not exist any dataset"
        for ds in list_datasets:
            assert isinstance(ds, DataSet), "Existence type is not dataset."