async def validate_training_data( background_tasks: BackgroundTasks, current_user: User = Depends(auth.get_current_user_and_bot), ): """ Validates bot training data. """ DataImporterLogProcessor.is_limit_exceeded(current_user.get_bot()) DataImporterLogProcessor.is_event_in_progress(current_user.get_bot()) Utility.make_dirs( os.path.join("training_data", current_user.get_bot(), str(datetime.utcnow()))) DataImporterLogProcessor.add_log(current_user.get_bot(), current_user.get_user(), is_data_uploaded=False) background_tasks.add_task(EventsTrigger.trigger_data_importer, current_user.get_bot(), current_user.get_user(), False, False) return {"message": "Event triggered! Check logs."}
def test_make_dirs_path_already_exists(self, resource_make_dirs): assert os.path.exists(pytest.temp_path) assert not Utility.make_dirs(pytest.temp_path)
def test_make_dirs_exception(self, resource_make_dirs): assert os.path.exists(pytest.temp_path) with pytest.raises(AppException) as e: Utility.make_dirs(pytest.temp_path, True) assert str(e).__contains__('Directory exists!')
def test_make_dirs(self, resource_make_dirs): path = os.path.join(pytest.temp_path, str(datetime.now())) Utility.make_dirs(path) assert os.path.exists(path)