import json import os import unittest from unittest.mock import Mock # Testing various imports rerouted from appian_locust import AppianClient, AppianTaskSet, helper, appianclient, records_helper, uiform, logger from appian_locust.exceptions import BadCredentialsException, MissingCsrfTokenException, MissingConfigurationException from appian_locust.appianclient import procedurally_generate_credentials, setup_distributed_creds from locust import Locust, TaskSet from .mock_client import CustomLocust, MockClient, SampleAppianTaskSequence from .mock_reader import read_mock_file log = logger.getLogger(__name__) class TestAppianBase(unittest.TestCase): dir_path = os.path.dirname(os.path.realpath(__file__)) form_content = read_mock_file("form_content_response.json") form_content_2 = read_mock_file("sites_record_nav.json") form_content_3 = read_mock_file("sites_record_recordType_resp.json") nested_dynamic_link_json = read_mock_file( "nested_dynamic_link_response.json") def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) self.parent_task_set = TaskSet(self.custom_locust) setattr(self.parent_task_set, "host", "") setattr(self.parent_task_set, "credentials", [["", ""]])
#!/usr/bin/env python3 import sys import random from locust import HttpUser, task, between from appian_locust import AppianTaskSet from appian_locust.loadDriverUtils import utls from appian_locust import logger utls.load_config() CONFIG = utls.c logger = logger.getLogger(__file__) class RecordsTaskSet(AppianTaskSet): def on_start(self): super().on_start() self.all_records = self.appian.records.get_all() # could be either view or list: if "endpoint_type" not in CONFIG: # could be either view or list: logger.error("endpoint_type not found in config.json") sys.exit(1) self.endpoint_type = CONFIG["endpoint_type"] if "view" not in self.endpoint_type and "list" not in self.endpoint_type: logger.error(