How to use get_field method in autotest

Best Python code snippet using autotest_python

functions.py

Source:functions.py Github

copy

Full Screen

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,...

Full Screen

Full Screen

test_models.py

Source:test_models.py Github

copy

Full Screen

...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...

Full Screen

Full Screen

sql_model.py

Source:sql_model.py Github

copy

Full Screen

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:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful