<s> from datetime import datetime , timedelta <EOL> import factory <EOL> from factory . django import DjangoModelFactory <EOL> from factory . fuzzy import FuzzyDecimal , FuzzyText <EOL> from ralph . assets . models . choices import AssetSource <EOL> from ralph . assets . tests . factories import ( <EOL> AssetHolderFactory , <EOL> BaseObjectFactory , <EOL> BudgetInfoFactory , <EOL> DataCenterAssetModelFactory , <EOL> ServiceEnvironmentFactory <EOL> ) <EOL> from ralph . data_center . models . networks import IPAddress <EOL> from ralph . data_center . models . physical import ( <EOL> Accessory , <EOL> ACCESSORY_DATA , <EOL> DataCenter , <EOL> DataCenterAsset , <EOL> Rack , <EOL> RackAccessory , <EOL> ServerRoom <EOL> ) <EOL> from ralph . data_center . models . virtual import Cluster , ClusterType , Database , VIP <EOL> date_now = datetime . now ( ) . date ( ) <EOL> class ClusterTypeFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Meta : <EOL> model = ClusterType <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class ClusterFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> type = factory . SubFactory ( ClusterTypeFactory ) <EOL> class Meta : <EOL> model = Cluster <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class DataCenterFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Meta : <EOL> model = DataCenter <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class ServerRoomFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] ) <EOL> data_center = factory . SubFactory ( DataCenterFactory ) <EOL> class Meta : <EOL> model = ServerRoom <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class AccessoryFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( ACCESSORY_DATA ) <EOL> class Meta : <EOL> model = Accessory <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class RackAccessoryFactory ( DjangoModelFactory ) : <EOL> class Meta : <EOL> model = RackAccessory <EOL> class RackFactory ( DjangoModelFactory ) : <EOL> name = factory . Sequence ( lambda n : '<STR_LIT>' . format ( n + <NUM_LIT:100> ) ) <EOL> class Meta : <EOL> model = Rack <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class DataCenterAssetFactory ( DjangoModelFactory ) : <EOL> force_depreciation = False <EOL> model = factory . SubFactory ( DataCenterAssetModelFactory ) <EOL> sn = factory . Faker ( '<STR_LIT>' ) <EOL> barcode = factory . Faker ( '<STR_LIT>' ) <EOL> hostname = factory . Sequence ( lambda n : '<STR_LIT>' . format ( n ) ) <EOL> order_no = factory . Sequence ( lambda n : '<STR_LIT>' + str ( n ) ) <EOL> budget_info = factory . SubFactory ( BudgetInfoFactory ) <EOL> invoice_date = date_now - timedelta ( days = <NUM_LIT:15> ) <EOL> invoice_no = factory . Sequence ( lambda n : '<STR_LIT>' + str ( n ) ) <EOL> property_of = factory . SubFactory ( AssetHolderFactory ) <EOL> provider = factory . Iterator ( [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] ) <EOL> source = factory . Iterator ( [ <EOL> AssetSource . shipment . id , AssetSource . salvaged . id <EOL> ] ) <EOL> price = FuzzyDecimal ( <NUM_LIT:10> , <NUM_LIT> ) <EOL> management_ip = factory . Faker ( '<STR_LIT>' ) <EOL> management_hostname = FuzzyText ( <EOL> prefix = '<STR_LIT>' , suffix = '<STR_LIT>' , length = <NUM_LIT> <EOL> ) <EOL> class Meta : <EOL> model = DataCenterAsset <EOL> class IPAddressFactory ( DjangoModelFactory ) : <EOL> base_object = factory . SubFactory ( BaseObjectFactory ) <EOL> class Meta : <EOL> model = IPAddress <EOL> class DatabaseFactory ( DjangoModelFactory ) : <EOL> service_env = factory . SubFactory ( ServiceEnvironmentFactory ) <EOL> class Meta : <EOL> model = Database <EOL> class VIPFactory ( DjangoModelFactory ) : <EOL> service_env = factory . SubFactory ( ServiceEnvironmentFactory ) <EOL> class Meta : <EOL> model = VIP </s>
