<s> import factory <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from nodeconductor . cost_tracking import models <EOL> from nodeconductor . openstack import models as openstack_models <EOL> from nodeconductor . openstack . tests import factories as openstack_factories <EOL> from nodeconductor . structure . tests import factories as structure_factories <EOL> class PriceEstimateFactory ( factory . DjangoModelFactory ) : <EOL> class Meta ( object ) : <EOL> model = models . PriceEstimate <EOL> scope = factory . SubFactory ( structure_factories . ProjectFactory ) <EOL> total = factory . Iterator ( [ <NUM_LIT:10> , <NUM_LIT:100> , <NUM_LIT:1000> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> month = factory . Iterator ( range ( <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> year = factory . Iterator ( range ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> @ classmethod <EOL> def get_list_url ( self ) : <EOL> return '<STR_LIT>' + reverse ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def get_url ( self , price_estimate , action = None ) : <EOL> if price_estimate is None : <EOL> price_estimate = PriceEstimateFactory ( ) <EOL> url = '<STR_LIT>' + reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : price_estimate . uuid } ) <EOL> return url if action is None else url + action + '<STR_LIT:/>' <EOL> class AbstractPriceListItemFactory ( factory . DjangoModelFactory ) : <EOL> class Meta ( object ) : <EOL> model = models . AbstractPriceListItem <EOL> abstract = True <EOL> resource_content_type = factory . LazyAttribute ( <EOL> lambda _ : ContentType . objects . get_for_model ( openstack_models . Instance ) ) <EOL> key = factory . Sequence ( lambda n : '<STR_LIT>' % n ) <EOL> value = factory . Iterator ( [ <NUM_LIT:10> , <NUM_LIT:100> , <NUM_LIT:1000> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> item_type = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> units = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class PriceListItemFactory ( AbstractPriceListItemFactory ) : <EOL> class Meta ( object ) : <EOL> model = models . PriceListItem <EOL> service = factory . SubFactory ( openstack_factories . OpenStackServiceFactory ) <EOL> @ classmethod <EOL> def get_list_url ( self ) : <EOL> return '<STR_LIT>' + reverse ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def get_url ( self , price_list_item , action = None ) : <EOL> if price_list_item is None : <EOL> price_list_item = PriceListItemFactory ( ) <EOL> url = '<STR_LIT>' + reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : price_list_item . uuid } ) <EOL> return url if action is None else url + action + '<STR_LIT:/>' <EOL> class DefaultPriceListItemFactory ( AbstractPriceListItemFactory ) : <EOL> class Meta ( object ) : <EOL> model = models . DefaultPriceListItem <EOL> @ classmethod <EOL> def get_list_url ( self ) : <EOL> return '<STR_LIT>' + reverse ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def get_url ( self , default_price_list_item , action = None ) : <EOL> if default_price_list_item is None : <EOL> default_price_list_item = DefaultPriceListItemFactory ( ) <EOL> url = '<STR_LIT>' + reverse ( <EOL> '<STR_LIT>' , kwargs = { '<STR_LIT>' : default_price_list_item . uuid } ) <EOL> return url if action is None else url + action + '<STR_LIT:/>' </s>
