How to use test_multiple method in toolium

Best Python code snippet using toolium_python

task_test.py

Source:task_test.py Github

copy

Full Screen

1from datetime import datetime, timedelta2from freezegun import freeze_time3from tenant_schemas_celery.task import TenantTask4from tenant_schemas_celery.app import CeleryApp5from tenant_schemas_celery.test_utils import create_client6from django.conf import settings7def test_task_get_tenant_for_schema_should_cache_results_local_setting(transactional_db):8 class DummyTask(TenantTask):9 tenant_cache_seconds = 110 def run(self, *args, **kwargs):11 pass12 task = DummyTask()13 fresh_tenant = create_client(14 name="test_local", schema_name="test_local", domain_url="test_local.test.com"15 )16 cached_tenant = task.get_tenant_for_schema("test_local")17 # Check for equality, but the objects should be different. The one from cache was fetched separately.18 assert cached_tenant == fresh_tenant19 assert cached_tenant is not fresh_tenant20 cache_hit_tenant = task.get_tenant_for_schema("test_local")21 # A cache hit. The same instance should be returned.22 assert cache_hit_tenant == cached_tenant23 assert cache_hit_tenant is cached_tenant24 with freeze_time(25 datetime.utcnow() + 2 * timedelta(seconds=DummyTask.tenant_cache_seconds)26 ):27 cache_miss_tenant = task.get_tenant_for_schema("test_local")28 # A cache miss. Equality is required, but they are not they same objects.29 assert cache_miss_tenant == cached_tenant30 assert cache_miss_tenant is not cached_tenant31def test_task_get_tenant_for_schema_should_cache_results_global_setting(transactional_db):32 # Celery is not able to pick up settings without this33 app = CeleryApp('testapp')34 app.config_from_object('django.conf:settings', namespace="CELERY")35 # TASK_TENANT_CACHE_SECONDS global setting set to 10s36 class DummyTask(TenantTask):37 def run(self, *args, **kwargs):38 pass39 task = DummyTask()40 fresh_tenant = create_client(41 name="test_global", schema_name="test_global", domain_url="test_global.test.com"42 )43 cached_tenant = task.get_tenant_for_schema("test_global")44 # Check for equality, but the objects should be different. The one from cache was fetched separately.45 assert cached_tenant == fresh_tenant46 assert cached_tenant is not fresh_tenant47 cache_hit_tenant = task.get_tenant_for_schema("test_global")48 # A cache hit. The same instance should be returned.49 assert cache_hit_tenant == cached_tenant50 assert cache_hit_tenant is cached_tenant51 with freeze_time(52 datetime.utcnow() + 2 * timedelta(seconds=int(settings.CELERY_TASK_TENANT_CACHE_SECONDS))53 ):54 cache_miss_tenant = task.get_tenant_for_schema("test_global")55 # A cache miss. Equality is required, but they are not they same objects.56 assert cache_miss_tenant == cached_tenant57 assert cache_miss_tenant is not cached_tenant58def test_multiple_tasks_get_tenant_for_schema_should_cache_results_global_setting(transactional_db):59 # Celery is not able to pick up settings without this60 app = CeleryApp('testapp')61 app.config_from_object('django.conf:settings', namespace="CELERY")62 # TASK_TENANT_CACHE_SECONDS global setting set to 10s63 class DummyTask(TenantTask):64 def run(self, *args, **kwargs):65 pass66 class DummyTask2(TenantTask):67 def run(self, *args, **kwargs):68 pass69 task = DummyTask()70 task2 = DummyTask2()71 fresh_tenant = create_client(72 name="test_multiple", schema_name="test_multiple", domain_url="test_multiple.test.com"73 )74 cached_tenant = task.get_tenant_for_schema("test_multiple")75 # Check for equality, but the objects should be different. The one from cache was fetched separately.76 assert cached_tenant == fresh_tenant77 assert cached_tenant is not fresh_tenant78 cache_hit_tenant = task.get_tenant_for_schema("test_multiple")79 cache_hit_tenant2 = task2.get_tenant_for_schema("test_multiple")80 # A cache hit. The same instance should be returned.81 assert cache_hit_tenant == cached_tenant82 assert cache_hit_tenant is cached_tenant83 # A cache hit for same tenant, different task84 assert cache_hit_tenant2 == cached_tenant85 assert cache_hit_tenant2 is cached_tenant86 with freeze_time(87 datetime.utcnow() + 2 * timedelta(seconds=int(settings.CELERY_TASK_TENANT_CACHE_SECONDS))88 ):89 cache_miss_tenant = task.get_tenant_for_schema("test_multiple")90 cache_miss_tenant2 = task2.get_tenant_for_schema("test_multiple")91 # A cache miss. Equality is required, but they are not they same objects.92 assert cache_miss_tenant == cached_tenant93 assert cache_miss_tenant is not cached_tenant94 # Cache miss for same tenant, different task95 assert cache_miss_tenant2 == cached_tenant96 assert cache_miss_tenant2 is not cached_tenant97def test_get_tenant_databases_custom_settings(celery_conf):98 """Tests the behavior when using custom settings in Django/Celery"""99 # When no configuration, should fallback to default behavior100 assert hasattr(celery_conf, "task_tenant_databases") is False101 assert TenantTask.get_tenant_databases() == ("default", )102 # Custom setting via settings.py or celery conf103 celery_conf["CELERY_TASK_TENANT_DATABASES"] = ("otherdb1", "otherdb2")104 assert TenantTask.get_tenant_databases() == ("otherdb1", "otherdb2")105 class CustomTask(TenantTask):106 tenant_databases = ("customdb",)107 # Should prioritize the task class's preference over Celery app config...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1import champion2from champion_functions import MILLIS34import multiprocessing56import tkinter as tk7master = tk.Tk()8tk.Label(master, text="Team data").grid(row=0)9tk.Label(master, text="Iterations").grid(row=1)10tk.Label(master, text="Results").grid(row=2)11tk.Label(master, text='Status').grid(row=3)1213team_json = tk.Entry(master)14iterations = tk.Entry(master)15blue_results = tk.Entry(master)16red_results = tk.Entry(master)17bugged_out_results = tk.Entry(master)18draw_results = tk.Entry(master)19status = tk.Entry(master)2021team_json.grid(row=0, column=1)22iterations.grid(row=1, column=1)23blue_results.grid(row=2, column=1)24red_results.grid(row=2, column=2)25bugged_out_results.grid(row=2, column=3)26draw_results.grid(row=2, column=4)27status.grid(row=3, column=1)2829#team_data = team_json.get()30#iterations_data = iterations.get()3132def set_status(val):33 status.delete(0, tk.END)34 status.insert(0, val)35set_status('idle')3637def run():3839 #global test_multiple40 set_status('running')4142 team_data = team_json.get()43 iterations_data = int(iterations.get())4445 jobs = []46 47 if(team_data):48 for i in range(1, iterations_data + 2):49 if(status.get() == 'idle'): break50 51 try:52 champion.run(champion.champion, team_data)53 except:54 champion.test_multiple['bugged out'] += 155 56575859 blue_results.delete(0, tk.END)60 blue_results.insert(0, 'blue: ' + str(champion.test_multiple['blue']))61 red_results.delete(0, tk.END)62 red_results.insert(0, 'red: ' + str(champion.test_multiple['red']))63 bugged_out_results.delete(0, tk.END)64 bugged_out_results.insert(0, 'bugged rounds: ' + str(champion.test_multiple['bugged out']))65 draw_results.delete(0, tk.END)66 draw_results.insert(0, 'draws: ' + str(champion.test_multiple['draw']))67 master.update()6869 with open('log.txt', "w") as out:70 if(MILLIS() < 75000):71 if(champion.log[-1] == 'BLUE TEAM WON'): champion.test_multiple['blue'] += 172 if(champion.log[-1] == 'RED TEAM WON'): champion.test_multiple['red'] += 173 elif(MILLIS() < 200000): champion.test_multiple['draw'] += 174 for line in champion.log:75 out.write(str(line))76 out.write('\n')77 out.close()787980 champion.test_multiple = {'blue': 0, 'red': 0, 'bugged out': 0, 'draw': 0}81 set_status('idle')82 master.update()83848586 #set_stop(False)87 8889start_simulations = tk.Button(master, text='Run simulations', command= lambda: run()) 90start_simulations.grid(row=4, column=1, sticky=tk.W, pady=4)9192stop_simulations = tk.Button(master, text='Stop', command= lambda: set_status('idle'))93stop_simulations.grid(row=4, column=2, sticky=tk.W, pady=4)9495quit_simulations = tk.Button(master, text='Quit', command= lambda: master.quit())96quit_simulations.grid(row=4, column=3, sticky=tk.W, pady=4)97 ...

Full Screen

Full Screen

test_basic.py

Source:test_basic.py Github

copy

Full Screen

...7 result = testdir.runpytest()8 result.stdout.fnmatch_lines("""9 *test_single: A simple test10 """)11def test_multiple(testdir):12 testdir.makepyfile("""13 def test_multiple(test_info):14 test_info("First one")15 test_info("Second one")16 """)17 result = testdir.runpytest()18 result.stdout.fnmatch_lines("""19 test_multiple: First one20 test_multiple: Second one21 """)22def test_many_tests(testdir):23 testdir.makepyfile("""24 def test_many_tests1(test_info):25 test_info("First one")26 test_info("Second one")27 def test_many_tests2(test_info):...

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