You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from ragflow import RAGFlow, DataSet
  2. from common import API_KEY, HOST_ADDRESS
  3. from test_sdkbase import TestSdk
  4. class TestDataset(TestSdk):
  5. def test_create_dataset_with_success(self):
  6. """
  7. Test creating a dataset with success
  8. """
  9. rag = RAGFlow(API_KEY, HOST_ADDRESS)
  10. ds = rag.create_dataset("God")
  11. if isinstance(ds, DataSet):
  12. assert ds.name == "God", "Name does not match."
  13. else:
  14. assert False, f"Failed to create dataset, error: {ds}"
  15. def test_update_dataset_with_success(self):
  16. """
  17. Test updating a dataset with success.
  18. """
  19. rag = RAGFlow(API_KEY, HOST_ADDRESS)
  20. ds = rag.create_dataset("ABC")
  21. if isinstance(ds, DataSet):
  22. assert ds.name == "ABC", "Name does not match."
  23. res = ds.update({"name":"DEF"})
  24. assert res is None, f"Failed to update dataset, error: {res}"
  25. else:
  26. assert False, f"Failed to create dataset, error: {ds}"
  27. def test_delete_dataset_with_success(self):
  28. """
  29. Test deleting a dataset with success
  30. """
  31. rag = RAGFlow(API_KEY, HOST_ADDRESS)
  32. ds = rag.create_dataset("MA")
  33. if isinstance(ds, DataSet):
  34. assert ds.name == "MA", "Name does not match."
  35. res = rag.delete_dataset(names=["MA"])
  36. assert res is None, f"Failed to delete dataset, error: {res}"
  37. else:
  38. assert False, f"Failed to create dataset, error: {ds}"
  39. def test_list_datasets_with_success(self):
  40. """
  41. Test listing datasets with success
  42. """
  43. rag = RAGFlow(API_KEY, HOST_ADDRESS)
  44. list_datasets = rag.list_datasets()
  45. assert len(list_datasets) > 0, "Do not exist any dataset"
  46. for ds in list_datasets:
  47. assert isinstance(ds, DataSet), "Existence type is not dataset."