def __init__(self, num_cases, num_properties=None, specFile=None, case_id=None, device_id=None, creator_id=None, owner_id=None, user_id=None, username=None, case_type=None, case_name=None, cc_version="1.0", external_id=None, form_xmlns="http://www.commcarehq.org/example/hello-world", form_name="LOAD_TEST_FORM", verbosity=1): """ Assumes specFile is already converted into a python object (from JSON) <!-- user_id (==creator_id) - At Most One: the GUID of the user responsible for this case creation --> <!-- case_id - Exactly One: The id of the abstract case to be modified (even in the case of creation) --> <case_type/> <!-- At Most One: Modifies the Case Type for the case --> <case_name/> <!-- At Most One: A semantically meaningless but human readable name associated with the case --> <date_opened/> <!-- At Most One: Modifies the Date the case was opened --> <owner_id/> <!-- At Most One: Modifies the owner of this case --> """ self.num_properties = int(num_properties) self.has_user_specfile = specFile is not None self.specfile = specFile if specFile else getspec(self.num_properties) self.props_funcs = {} #used if explicit = False self.cases = [] #used if explicit = True self.num_cases = int(num_cases) self.case_type = "LOAD_TESTING_CASE" if not case_type else case_type self.case_name = "LOAD_TESTING_CASE_NAME" if not case_name else case_name self.case_id = generate_case_id() if not case_id else case_id self.creator_id = generate_user_id() if not creator_id else creator_id self.owner_id = generate_user_id() if not owner_id else owner_id self.username = username if username else "LOAD_TESTER_CCUSER" self.user_id = generate_user_id() if not user_id else user_id self.external_id = external_id or 'LOAD_TESTER_EXTERNAL_ID' self.device_id = device_id if device_id else generate_device_id() self.cc_version = cc_version self.is_explicit = self.specfile["explicit"] self.form_xmlns = form_xmlns self.form_name = form_name self.verbosity = int(verbosity) if self.verbosity > 1: print 'Succesfully created CaseGenerator' print "CaseGenerator Options:\n" \ "\tNumber of Cases:%(num_cases)s\n" \ "\tNumber of Properties per case: %(num_properties)s\n" \ "\tHas user generated specfile?: %(has_user_specfile)s\n" \ "\tIs spec explicit?: %(is_explicit)s\n" \ "\tCaseBlock Version: %(cc_version)s\n" \ "\tOwner_id: %(owner_id)s\n" \ "\tCreator_id: %(creator_id)s\n" \ "\tExternal_id: %(external_id)s\n" \ "\tDevice_id: %(device_id)s\n" \ "\tCase Type: %(case_type)s\n" \ "\tCase Name: %(case_name)s\n" \ "\tCase ID: %(case_id)s\n" % self print "SPEC:" pprint.pprint(self.specfile, indent=2) print "SPEC IN JSON" print "\n" print json.dumps(self.specfile) print "\n"
def setUp(self): self.output = specmaker.getspec(4)