Best Python code snippet using autotest_python
functions.py
Source:functions.py
1def get_field(lst, name):2 if name in lst:3 return 14 else:5 return 06def parse_options(options):7 options = [i.strip() for i in options.split(',')]8 9 disks = get_field(options, 'лиÑÑе диÑки')10 toning = get_field(options, 'ÑониÑовка')11 luke = get_field(options, 'лÑк')12 panoramic_roof = get_field(options, 'паноÑÐ°Ð¼Ð½Ð°Ñ ÐºÑÑÑа')13 kangaroo = get_field(options, 'кенгÑÑÑÑник')14 spoiler = get_field(options, 'ÑпойлеÑ')15 body_kit = get_field(options, 'обвеÑ')16 winch = get_field(options, 'лебÑдка')17 windscreens = get_field(options, 'веÑÑовики')18 railings = get_field(options, 'Ñейлинги')19 trunk = get_field(options, 'багажник')20 hitch = get_field(options, 'ÑаÑкоп')21 xenon = get_field(options, 'кÑенон')22 bixenone = get_field(options, 'бикÑенон')23 crystal_optics = get_field(options, 'Ñ
ÑÑÑÑалÑÐ½Ð°Ñ Ð¾Ð¿Ñика')24 lenticular_optics = get_field(options, 'Ð»Ð¸Ð½Ð·Ð¾Ð²Ð°Ð½Ð½Ð°Ñ Ð¾Ð¿Ñика')25 daytime_lights = get_field(options, 'дневнÑе Ñ
одовÑе огни')26 fog_lights = get_field(options, 'пÑоÑивоÑÑманки')27 lights_washer = get_field(options, 'омÑваÑÐµÐ»Ñ ÑаÑ')28 lights_corrector = get_field(options, 'коÑÑекÑÐ¾Ñ ÑаÑ')29 heated_mirrors = get_field(options, 'обогÑев зеÑкал')30 velours = get_field(options, 'велÑÑ')31 leather = get_field(options, 'кожа')32 wood = get_field(options, 'деÑево')33 alcantara = get_field(options, 'алÑканÑаÑа')34 combinated = get_field(options, 'комбиниÑованнÑй')35 curtains = get_field(options, 'ÑÑоÑки')36 audio_system = get_field(options, 'аÑдиоÑиÑÑема')37 built_in_phone = get_field(options, 'вÑÑÑоеннÑй ÑелеÑон')38 bluetooth = get_field(options, 'bluetooth')39 cd = get_field(options, 'CD')40 cd_changer = get_field(options, 'CD-ÑейнджеÑ')41 mp3 = get_field(options, 'MP3')42 usb = get_field(options, 'USB')43 dvd = get_field(options, 'DVD')44 dvd_changer = get_field(options, 'DVD-ÑейнджеÑ')45 subwoofer = get_field(options, 'ÑабвÑÑеÑ')46 power_steering = get_field(options, 'ÐУР')47 abs = get_field(options, 'ABS')48 srs = get_field(options, 'SRS')49 winter_mode = get_field(options, 'зимний Ñежим')50 sport_mode = get_field(options, 'ÑпоÑÑивнÑй Ñежим')51 turbo = get_field(options, 'ÑÑÑбонаддÑв')52 turbo_timer = get_field(options, 'ÑÑÑбоÑаймеÑ')53 alarm_system = get_field(options, 'ÑигнализаÑиÑ')54 autostart = get_field(options, 'авÑозапÑÑк')55 immobilizer = get_field(options, 'иммобилайзеÑ')56 keyless_access = get_field(options, 'беÑклÑÑевой доÑÑÑп')57 full_electropackage = get_field(options, 'полнÑй ÑлекÑÑопакеÑ')58 centro_lock = get_field(options, 'ÑенÑÑозамок')59 air_condition = get_field(options, 'кондиÑионеÑ')60 climate_control = get_field(options, 'климаÑ-конÑÑолÑ')61 cruise_control = get_field(options, 'кÑÑиз-конÑÑолÑ')62 on_board_computer = get_field(options, 'боÑÑовой компÑÑÑеÑ')63 gps = get_field(options, 'навигаÑÐ¸Ð¾Ð½Ð½Ð°Ñ ÑиÑÑема')64 multi_wheel = get_field(options, 'мÑлÑÑиÑÑлÑ')65 heated_wheel = get_field(options, 'подогÑев ÑÑлÑ')66 heated_sits = get_field(options, 'подогÑев Ñидений')67 heated_rear_sits = get_field(options, 'подогÑев задниÑ
Ñидений')68 seat_ventilation = get_field(options, 'венÑилÑÑÐ¸Ñ Ñидений')69 seat_memory = get_field(options, 'памÑÑÑ Ñидений')70 wheel_memory = get_field(options, 'памÑÑÑ ÑÑлÑ')71 parktrnics = get_field(options, 'паÑкÑÑоники')72 rear_view_camera = get_field(options, 'камеÑа заднего вида')73 light_sensor = get_field(options, 'даÑÑик ÑвеÑа')74 rain_sensor = get_field(options, 'даÑÑик дождÑ')75 tire_pressure_sensor = get_field(options, 'даÑÑик Ð´Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð² ÑинаÑ
')76 air_suspension = get_field(options, 'пневмоподвеÑка')77 changeable_clearance = get_field(options, 'изменÑемÑй клиÑенÑ')78 freshly_fitted = get_field(options, 'ÑвежепÑигнан')79 freshly_supplied = get_field(options, 'ÑвежедоÑÑавлен')80 tax_paid = get_field(options, 'налог ÑплаÑен')81 ti_performed = get_field(options, 'ÑеÑ
оÑмоÑÑ Ð¿Ñойден')82 investment_not_required = get_field(options, 'вложений не ÑÑебÑеÑ')83 a_dict = {84 'disks' : disks,85 'toning' : toning,86 'luke' : luke,87 'panoramic_roof' : panoramic_roof,88 'kangaroo' : kangaroo,89 'spoiler' : spoiler,90 'body_kit' : body_kit,91 'winch' : winch,92 'windscreens' : windscreens,93 'railings' : railings,94 'trunk' : trunk,95 'hitch' : hitch,96 'xenon' : xenon,...
test_models.py
Source:test_models.py
...8 #Set up non-modified objects used by all test methods9 Habitat_area.objects.create(name='Тайга', characteristic='биом, Ð´Ð»Ñ ÐºÐ¾ÑоÑого Ñ
аÑакÑеÑно пÑеобладание Ñ
войнÑÑ
леÑов.')10 def test_name_label(self):11 area=Habitat_area.objects.get(id=1)12 field_label = area._meta.get_field('name').verbose_name13 self.assertEquals(field_label,'name')14 def test_characteristic_label(self):15 area=Habitat_area.objects.get(id=1)16 field_label = area._meta.get_field('characteristic').verbose_name17 self.assertEquals(field_label,'characteristic')18 def test_name_max_length(self):19 area=Habitat_area.objects.get(id=1)20 max_length = area._meta.get_field('name').max_length21 self.assertEquals(max_length,45)22 def test_characteristic_max_length(self):23 area=Habitat_area.objects.get(id=1)24 max_length = area._meta.get_field('characteristic').max_length25 self.assertEquals(max_length,500)26class Feeding_rationModelTest(TestCase):27 @classmethod28 def setUpTestData(cls):29 #Set up non-modified objects used by all test methods30 Feeding_ration.objects.create(name='ÐалÑÑ', type='деÑÑкий')31 def test_name_label(self):32 ration=Feeding_ration.objects.get(id=1)33 field_label = ration._meta.get_field('name').verbose_name34 self.assertEquals(field_label,'name')35 def test_type_label(self):36 ration=Feeding_ration.objects.get(id=1)37 field_label = ration._meta.get_field('type').verbose_name38 self.assertEquals(field_label,'type')39 def test_name_max_length(self):40 ration=Feeding_ration.objects.get(id=1)41 max_length = ration._meta.get_field('name').max_length42 self.assertEquals(max_length,45)43 def test_type_max_length(self):44 ration=Feeding_ration.objects.get(id=1)45 max_length = ration._meta.get_field('type').max_length46 self.assertEquals(max_length,45)47class AnimalModelTest(TestCase):48 @classmethod49 def setUpTestData(cls):50 #Set up non-modified objects used by all test methods51 Animal.objects.create(name='ÐÑÑка', birthday='12.12.2019', gender='женÑкий',type='живоÑное')52 def test_name_label(self):53 animal=Animal.objects.get(id=1)54 field_label = animal._meta.get_field('name').verbose_name55 self.assertEquals(field_label,'name')56 def test_birthday_label(self):57 animal=Animal.objects.get(id=1)58 field_label = animal._meta.get_field('birthday').verbose_name59 self.assertEquals(field_label,'birthday')60 def test_gender_label(self):61 animal=Animal.objects.get(id=1)62 field_label = animal._meta.get_field('gender').verbose_name63 self.assertEquals(field_label,'gender')64 def test_type_label(self):65 animal=Animal.objects.get(id=1)66 field_label = animal._meta.get_field('type').verbose_name67 self.assertEquals(field_label,'type')68 def test_name_max_length(self):69 animal=Animal.objects.get(id=1)70 max_length = animal._meta.get_field('name').max_length71 self.assertEquals(max_length,40)72 def test_birthday_max_length(self):73 animal=Animal.objects.get(id=1)74 max_length = animal._meta.get_field('birthday').max_length75 self.assertEquals(max_length,20)76 def test_gender_max_length(self):77 animal=Animal.objects.get(id=1)78 max_length = animal._meta.get_field('gender').max_length79 self.assertEquals(max_length,20)80 def test_type_max_length(self):81 animal=Animal.objects.get(id=1)82 max_length = animal._meta.get_field('type').max_length83 self.assertEquals(max_length,40)84class ReptileModelTest(TestCase):85 @classmethod86 def setUpTestData(cls):87 #Set up non-modified objects used by all test methods88 Reptile.objects.create(hibernation_period='20/11/2000-30/12/2000',normal_temperature='26')89 def test_normal_temperature_label(self):90 reptile=Reptile.objects.get(id=1)91 field_label = reptile._meta.get_field('normal_temperature').verbose_name92 self.assertEquals(field_label,'normal temperature')93 def test_hibernation_period_label(self):94 reptile=Reptile.objects.get(id=1)95 field_label = reptile._meta.get_field('hibernation_period').verbose_name96 self.assertEquals(field_label,'hibernation period')97 def test_normal_temperature_max_length(self):98 reptile=Reptile.objects.get(id=1)99 max_length = reptile._meta.get_field('normal_temperature').max_length100 self.assertEquals(max_length,40)101 def test_hibernation_period_max_length(self):102 reptile=Reptile.objects.get(id=1)103 max_length = reptile._meta.get_field('hibernation_period').max_length104 self.assertEquals(max_length,45)105class BirdModelTest(TestCase):106 @classmethod107 def setUpTestData(cls):108 #Set up non-modified objects used by all test methods109 Bird.objects.create(wintering_place='ЯпониÑ', date_of_arrival='20/11/2001', flight_date='22/11/2001')110 def test_wintering_place_label(self):111 bird=Bird.objects.get(id=1)112 field_label = bird._meta.get_field('wintering_place').verbose_name113 self.assertEquals(field_label,'wintering place')114 def test_date_of_arrival_label(self):115 bird=Bird.objects.get(id=1)116 field_label = bird._meta.get_field('date_of_arrival').verbose_name117 self.assertEquals(field_label,'date of arrival')118 def test_flight_date_label(self):119 bird=Bird.objects.get(id=1)120 field_label = bird._meta.get_field('flight_date').verbose_name121 self.assertEquals(field_label,'flight date')122 def test_wintering_place_max_length(self):123 bird=Bird.objects.get(id=1)124 max_length = bird._meta.get_field('wintering_place').max_length125 self.assertEquals(max_length,40)126 def test_date_of_arrival_max_length(self):127 bird=Bird.objects.get(id=1)128 max_length = bird._meta.get_field('date_of_arrival').max_length129 self.assertEquals(max_length,20)130 def test_flight_date_max_length(self):131 bird=Bird.objects.get(id=1)132 max_length = bird._meta.get_field('flight_date').max_length133 self.assertEquals(max_length,20)134class UserModelTest(TestCase):135 @classmethod136 def setUpTestData(cls):137 #Set up non-modified objects used by all test methods138 User.objects.create(name='ÐÐ°Ð¹Ñ Ðиего ÐлÑбеÑÑовиÑ', phone='88888', position='СмоÑÑиÑелÑ', birthday='12.12.2000', marital_status='не замÑжем')139 def test_name_label(self):140 user=User.objects.get(id=1)141 field_label = user._meta.get_field('name').verbose_name142 self.assertEquals(field_label,'name')143 def test_phone_label(self):144 user=User.objects.get(id=1)145 field_label = user._meta.get_field('phone').verbose_name146 self.assertEquals(field_label,'phone')147 def test_position_label(self):148 user=User.objects.get(id=1)149 field_label = user._meta.get_field('position').verbose_name150 self.assertEquals(field_label,'position')151 def test_birthday_label(self):152 user=User.objects.get(id=1)153 field_label = user._meta.get_field('birthday').verbose_name154 self.assertEquals(field_label,'birthday')155 def test_marital_status_label(self):156 user=User.objects.get(id=1)157 field_label = user._meta.get_field('marital_status').verbose_name158 self.assertEquals(field_label,'marital status')159 def test_name_max_length(self):160 user=User.objects.get(id=1)161 max_length = user._meta.get_field('name').max_length162 self.assertEquals(max_length,45)163 def test_birthday_max_length(self):164 user=User.objects.get(id=1)165 max_length = user._meta.get_field('birthday').max_length166 self.assertEquals(max_length,45)167 def test_phone_max_length(self):168 user=User.objects.get(id=1)169 max_length = user._meta.get_field('phone').max_length170 self.assertEquals(max_length,40)171 def test_position_max_length(self):172 user=User.objects.get(id=1)173 max_length = user._meta.get_field('position').max_length174 self.assertEquals(max_length,45)175 def test_marital_status_max_length(self):176 user=User.objects.get(id=1)177 max_length = user._meta.get_field('marital_status').max_length...
sql_model.py
Source:sql_model.py
2from unidef.languages.common.type_model import DyType, FieldType, Traits3from unidef.models.config_model import ModelDefinition4from unidef.utils.name_convert import *5def get_real(ty: DyType) -> str:6 assert ty.get_field(Traits.Floating), True7 bits = ty.get_field(Traits.BitSize)8 if bits == 32:9 return "float"10 elif bits == 64:11 return "double precision"12 else:13 raise NotImplementedError()14def get_integer(ty: DyType) -> str:15 assert ty.get_field(Traits.Integer), True16 bits = ty.get_field(Traits.BitSize)17 if bits < 32:18 return "smallint"19 elif bits == 32:20 return "int"21 elif bits > 32:22 return "bigint"23 else:24 raise NotImplementedError()25def map_type_to_ddl(ty: DyType) -> str:26 assert ty is not None27 if ty.get_field(Traits.Floating):28 return get_real(ty)29 if ty.get_field(Traits.TsUnit):30 return "timestamp without time zone"31 if ty.get_field(Traits.Integer):32 return get_integer(ty)33 if ty.get_field(Traits.String) or ty.get_field(Traits.Null):34 return "text"35 if ty.get_field(Traits.Bool):36 return "bool"37 if ty.get_field(Traits.Struct):38 return "jsonb"39 if ty.get_field(Traits.Enum):40 if ty.get_field(Traits.SimpleEnum):41 return "text"42 else:43 return "jsonb"44 raise Exception("Cannot map {} to sql type".format(ty.get_field(Traits.TypeName)))45def get_field(field: FieldType) -> str:46 base = to_snake_case(field.field_name) + " " + map_type_to_ddl(field.field_type)47 if field.get_field(Traits.Primary):48 base += " primary key"49 if not field.get_field(Traits.Nullable):50 base += " not null"51 return base52def emit_schema_from_model(model: DyType) -> str:53 fields = ",\n".join(54 [get_field(field) for field in model.get_field(Traits.StructFields)]55 )56 return fields57def emit_field_names_from_model(model: DyType) -> str:58 fields = ",".join(59 [60 field.get_field(Traits.TypeName)61 for field in model.get_field(Traits.StructFields)62 ]63 )64 return fields65class SqlEmitter(Emitter):66 def accept(self, s: str) -> bool:67 return s == "sql"68 def emit_model(self, target: str, model: ModelDefinition) -> str:69 return emit_schema_from_model(model.get_parsed())70 def emit_type(self, target: str, ty: DyType) -> str:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!