Best Python code snippet using autotest_python
test_utils.py
Source:test_utils.py
1# builtin2import os3import sys4############################################################5# utils / setup6############################################################7base_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')8sys.path.append(base_dir)9from lib import utils, file_load10############################################################11# tests12############################################################13def test_true(): assert True14def test_video_add_worker_and_roles():15 shoot_roles = file_load.load_shoot_roles()16 video = list(file_load.get_table().items())[0][1]17 assert video.get('Workers') is None18 video = utils.video_add_worker_and_roles(video, shoot_roles)19 assert isinstance(video['Workers'], dict)20def test_video_add_role_unscaled_percents():21 shoot_roles = file_load.load_shoot_roles()22 role_percents = file_load.load_role_percents()23 video = list(file_load.get_table().items())[0][1]24 video = utils.video_add_worker_and_roles(video, shoot_roles)25 assert video.get('role percents unscaled') is None26 video = utils.video_add_role_unscaled_percents(video, role_percents)27 assert 0 <= video['role percents unscaled']['QAPC'] <= 10028def test_video_create_scaling_factor():29 shoot_roles = file_load.load_shoot_roles()30 role_percents = file_load.load_role_percents()31 video = list(file_load.get_table().items())[0][1]32 video = utils.video_add_worker_and_roles(video, shoot_roles)33 video = utils.video_add_role_unscaled_percents(video, role_percents)34 assert video.get('scaling factor') is None35 video = utils.video_create_scaling_factor(video)36 assert 0 <= video.get('scaling factor') <= 137def test_video_scale_role_percents():38 shoot_roles = file_load.load_shoot_roles()39 role_percents = file_load.load_role_percents()40 video = list(file_load.get_table().items())[0][1]41 video = utils.video_add_worker_and_roles(video, shoot_roles)42 video = utils.video_add_role_unscaled_percents(video, role_percents)43 video = utils.video_create_scaling_factor(video)44 assert video.get('role percents') is None45 video = utils.video_scale_role_percents(video)46 assert 0 <= video['role percents']['QAPC'] <= 10047def test_scaling_factor_applies_properly():48 shoot_roles = file_load.load_shoot_roles()49 role_percents = file_load.load_role_percents()50 video = list(file_load.get_table().items())[0][1]51 video = utils.video_add_worker_and_roles(video, shoot_roles)52 video = utils.video_add_role_unscaled_percents(video, role_percents)53 video = utils.video_create_scaling_factor(video)54 video = utils.video_scale_role_percents(video)55 expected_scaled_percent = video['role percents unscaled']['QAPC'] * video['scaling factor']56 scaled_percent = video['role percents']['QAPC']57 assert expected_scaled_percent == scaled_percent58def test_video_get_total_earnings():59 shoot_roles = file_load.load_shoot_roles()60 role_percents = file_load.load_role_percents()61 video = list(file_load.get_table().items())[0][1]62 video = utils.video_add_worker_and_roles(video, shoot_roles)63 video = utils.video_add_role_unscaled_percents(video, role_percents)64 video = utils.video_create_scaling_factor(video)65 video = utils.video_scale_role_percents(video)66 assert video.get('total earnings') is None67 video = utils.video_get_total_earnings(video)68 assert video.get('total earnings') is not None69def test_video_get_worker_earnings():70 shoot_roles = file_load.load_shoot_roles()71 role_percents = file_load.load_role_percents()72 video = list(file_load.get_table().items())[0][1]73 video = utils.video_add_worker_and_roles(video, shoot_roles)74 video = utils.video_add_role_unscaled_percents(video, role_percents)75 video = utils.video_create_scaling_factor(video)76 video = utils.video_scale_role_percents(video)77 video = utils.video_get_total_earnings(video)78 assert video.get('earnings') is None79 video = utils.video_get_worker_earnings(video)80 assert isinstance(video.get('earnings'), dict)81def test_validate_earnings():82 shoot_roles = file_load.load_shoot_roles()83 role_percents = file_load.load_role_percents()84 video = list(file_load.get_table().items())[0][1]85 video = utils.video_add_worker_and_roles(video, shoot_roles)86 video = utils.video_add_role_unscaled_percents(video, role_percents)87 video = utils.video_create_scaling_factor(video)88 video = utils.video_scale_role_percents(video)89 video = utils.video_get_total_earnings(video)90 video = utils.video_get_worker_earnings(video)91 total_earnings = video['total earnings']92 sum_all_earnings = 093 for earning in video['earnings'].values():94 sum_all_earnings += earning95 assert round(total_earnings, 2) == round(sum_all_earnings, 2)96def test_all_videos():97 shoot_roles = file_load.load_shoot_roles()98 role_percents = file_load.load_role_percents()99 for video in file_load.get_table().values():100 video = utils.video_add_worker_and_roles(video, shoot_roles)101 video = utils.video_add_role_unscaled_percents(video, role_percents)102 video = utils.video_create_scaling_factor(video)103 video = utils.video_scale_role_percents(video)104 video = utils.video_get_total_earnings(video)105 video = utils.video_get_worker_earnings(video)106 total_earnings = video['total earnings']107 sum_all_earnings = 0108 for earning in video['earnings'].values():109 sum_all_earnings += earning110 assert round(total_earnings, 2) == round(sum_all_earnings, 2)111def test_video_add_image():112 video = list(file_load.get_table().items())[0][1]113 images = file_load.get_images()114 assert video.get('image') is None115 video = utils.video_add_images(video, images)...
test_file_load.py
Source:test_file_load.py
1# builtin2import os3import sys4import collections5############################################################6# setup7############################################################8base_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')9sys.path.append(base_dir)10from lib import file_load11############################################################12# tests13############################################################14def test_true(): assert True15def test_load_shoot_roles():16 data = file_load.load_shoot_roles()17 assert isinstance(data['Ali3n Club Fuck']['Workers'], dict)18def test_load_role_percents():19 data = file_load.load_role_percents()20 assert 0 <= data['Performer'] <= 10021 assert 0 <= data['QAPC'] <= 10022def test_load_workers():23 data = file_load.load_workers()24 assert isinstance(data, dict)25 assert bool(data)26def test_get_table():27 data = file_load.get_table()28 assert isinstance(data, collections.OrderedDict)29 assert bool(data)30def test_get_images():31 data = file_load.get_images()32 assert isinstance(data, dict)33 assert bool(data)34def test_get_first_video_from_table():35 video = list(file_load.get_table().items())[0][1]36 assert isinstance(video, dict)...
view_handlers.py
Source:view_handlers.py
1from lib import utils, file_load, worker_utils2def get_and_populate_shoot_table():3 shoot_roles = file_load.load_shoot_roles()4 role_percents = file_load.load_role_percents()5 images = file_load.get_images()6 table = file_load.get_table()7 for name, video in table.items():8 video = utils.video_add_worker_and_roles(video, shoot_roles)9 video = utils.video_add_role_unscaled_percents(video, role_percents)10 video = utils.video_create_scaling_factor(video)11 video = utils.video_scale_role_percents(video)12 video = utils.video_get_total_earnings(video)13 video = utils.video_get_worker_earnings(video)14 video = utils.video_add_images(video, images)15 table[name] = video16 return table17def get_all_workers():18 table = get_and_populate_shoot_table()19 workers = file_load.load_workers()20 workers = worker_utils.make_worker_video_list(workers, table)21 workers = worker_utils.make_worker_total_earnings(workers)22 return workers23def get_user_profile_info(worker):...
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!!