Package cubicweb :: Package devtools :: Module fill
[hide private]
[frames] | no frames]

Module fill

source code

This modules defines func / methods for creating test repositories
Classes [hide private]
  _ValueGenerator
generates integers / dates / strings / etc. to fill a DB table
  autoextend
  ValueGenerator
  RelationsQueriesGenerator
Functions [hide private]
 
custom_range(start, stop, step) source code
 
decompose_b26(index, ascii=False)
return a letter (base-26) decomposition of index
source code
 
get_max_length(eschema, attrname)
returns the maximum length allowed for 'attrname'
source code
 
_default_choice_func(etype, attrname)
default choice_func for insert_entity_queries
source code
 
insert_entity_queries(etype, schema, vreg, entity_num, choice_func=_default_choice_func)
returns a list of 'add entity' queries (couples query, args) :type etype: str :param etype: the entity's type
source code
 
make_entity(etype, schema, vreg, index=0, choice_func=_default_choice_func, form=False)
generates a random entity and returns it as a dict
source code
 
select(constraints, cursor, selectvar='O', objtype=None)
returns list of eids matching <constraints>
source code
 
make_relations_queries(schema, edict, cursor, ignored_relations=(), existingrels=None)
returns a list of generated RQL queries for relations :param schema: The instance schema
source code
 
composite_relation(rschema) source code
 
check_card_satisfied(card, remaining, subj, rschema, obj) source code
 
choose_eid(values, avoid) source code
 
make_tel(num_tel)
takes an integer, converts is as a string and inserts white spaces each 2 chars (french notation)
source code
 
numlen(number)
returns the number's length
source code
Variables [hide private]
  _GENERATED_VALUES = {}
Function Details [hide private]

insert_entity_queries(etype, schema, vreg, entity_num, choice_func=_default_choice_func)

source code 

returns a list of 'add entity' queries (couples query, args) :type etype: str :param etype: the entity's type

XXX FIXME: choice_func is here for historical reasons, it should
probably replaced by a nicer way to specify choices
Parameters:
  • schema (cubicweb.schema.Schema) - the instance schema
  • entity_num (int) - the number of entities to insert
  • choice_func (function) - a function that takes an entity type, an attrname and returns acceptable values for this attribute

make_entity(etype, schema, vreg, index=0, choice_func=_default_choice_func, form=False)

source code 

generates a random entity and returns it as a dict

by default, generate an entity to be inserted in the repository elif form, generate an form dictionnary to be given to a web controller

select(constraints, cursor, selectvar='O', objtype=None)

source code 

returns list of eids matching <constraints>

<selectvar> should be either 'O' or 'S' to match schema definitions

make_relations_queries(schema, edict, cursor, ignored_relations=(), existingrels=None)

source code 
returns a list of generated RQL queries for relations :param schema: The instance schema
Parameters:
  • e_dict - mapping between etypes and eids
  • ignored_relations - list of relations to ignore (i.e. don't try to generate insert queries for these relations)