How to use setup_test method in localstack

Best Python code snippet using localstack_python

tests.py

Source:tests.py Github

copy

Full Screen

...30 shooting_manager.shooting_balls = [ShootingBall(shooting_ball_color)]31 return shooting_manager32class TestInsert(TestCase):33 def test_insert_ball_in_middle_path1(self):34 assert self.setup_test(RED, 1, [YELLOW, GREEN, BLUE], 1,35 [YELLOW, GREEN, RED, BLUE]) is True36 def test_insert_ball_in_head_path1(self):37 assert self.setup_test(RED, 1, [YELLOW, GREEN, BLUE], 2,38 [YELLOW, GREEN, BLUE, RED]) is True39 def test_insert_ball_in_tail_path1(self):40 assert self.setup_test(RED, 1, [YELLOW, GREEN, BLUE], 0,41 [YELLOW, RED, GREEN, BLUE]) is True42 def test_insert_ball_in_middle_path2(self):43 assert self.setup_test(RED, 2, [YELLOW, GREEN, BLUE], 1,44 [YELLOW, GREEN, RED, BLUE]) is True45 def test_insert_ball_in_head_path2(self):46 assert self.setup_test(RED, 2, [YELLOW, GREEN, BLUE], 2,47 [YELLOW, GREEN, BLUE, RED]) is True48 def test_insert_ball_in_tail_path2(self):49 assert self.setup_test(RED, 2, [YELLOW, GREEN, BLUE], 0,50 [YELLOW, RED, GREEN, BLUE]) is True51 def test_insert_ball_in_middle_path3(self):52 assert self.setup_test(RED, 3, [YELLOW, GREEN, BLUE], 1,53 [YELLOW, GREEN, RED, BLUE]) is True54 def test_insert_ball_in_head_path3(self):55 assert self.setup_test(RED, 3, [YELLOW, GREEN, BLUE], 2,56 [YELLOW, GREEN, BLUE, RED]) is True57 def test_insert_ball_in_tail_path3(self):58 assert self.setup_test(RED, 3, [YELLOW, GREEN, BLUE], 0,59 [YELLOW, RED, GREEN, BLUE]) is True60 @staticmethod61 def setup_test(shooting_ball_color, path_num, balls_colors,62 insert_index, expected_colors):63 shooting_ball = ShootingBall(shooting_ball_color)64 path = Path(path_num)65 ball_generator = setup_ball_generator(path, balls_colors)66 ball_generator.insert(insert_index, shooting_ball)67 balls_expected = setup_balls(path, expected_colors)68 return are_lists_equal(balls_expected, ball_generator.balls)69class TestCollectChain(TestCase):70 def test_collect_chain_from_tail(self):71 assert self.setup_test(1, [GREEN, GREEN, BLUE, BLUE], GREEN, 0,72 [0, 1]) is True73 def test_collect_chain_from_head(self):74 assert self.setup_test(1, [GREEN, GREEN, BLUE, BLUE], BLUE, 3,75 [2, 3]) is True76 def test_collect_chain_from_middle(self):77 assert self.setup_test(1, [GREEN, BLUE, BLUE, GREEN], BLUE, 1,78 [1, 2]) is True79 def test_no_chain(self):80 assert self.setup_test(1, [GREEN] * 4, BLUE, 2, []) is True81 def test_collect_chain_startFromDifferentColor(self):82 assert self.setup_test(1, [BLUE, GREEN, GREEN, GREEN], GREEN, 0,83 [1, 2, 3]) is True84 def test_collect_one_ball(self):85 assert self.setup_test(1, [BLUE, GREEN, RED, YELLOW], GREEN, 1,86 [1]) is True87 @staticmethod88 def setup_test(level, balls_colors, shooting_ball_color, start_index,89 expected_indexes):90 ball_generator = setup_ball_generator(Path(level), balls_colors)91 shooting_manager = setup_shooting_manager(ball_generator,92 shooting_ball_color)93 chain_actual = shooting_manager.collect_chain(ball_generator.balls[94 start_index],95 shooting_ball_color)96 chain_expected = [ball_generator.balls[i] for i in expected_indexes]97 return are_lists_equal(chain_expected, chain_actual)98class TestDestroy(TestCase):99 def test_destroy(self):100 ball_generator = setup_ball_generator(Path(1),101 [GREEN, BLUE, BLUE, RED])102 balls_expected = [ball_generator.balls[0], ball_generator.balls[3]]103 ball_generator.destroy([ball_generator.balls[1],104 ball_generator.balls[2]])105 assert are_lists_equal(balls_expected, ball_generator.balls) is True106class TestUpdateChain(TestCase):107 path = Path(1)108 def test_join_two_balls(self):109 ball_generator = self.setup_test([RED, BLUE, BLUE, RED], [1, 2])110 assert self.are_moved(ball_generator.balls) is True111 def test_join_many_balls(self):112 colors = [RED, BLUE, BLUE, RED] + [GREEN, YELLOW] * 5113 ball_generator = self.setup_test(colors, [1, 2])114 assert self.are_moved(ball_generator.balls) is True115 def test_stop_one_ball(self):116 ball_generator = self.setup_test([RED, BLUE, BLUE, GREEN], [1, 2])117 assert self.are_stopped(1, ball_generator.balls) is True118 def test_stop_many_balls(self):119 colors = [RED, BLUE, BLUE] + [GREEN, YELLOW] * 5120 ball_generator = self.setup_test(colors, [1, 2])121 assert self.are_stopped(1, ball_generator.balls) is True122 def setup_test(self, colors, destroy_indexes):123 ball_generator = setup_ball_generator(self.path, colors)124 ball_generator.destroy([ball_generator.balls[i] for i in125 destroy_indexes])126 ball_generator.update_chain()127 return ball_generator128 def are_moved(self, balls):129 for i in range(1, len(balls)):130 if balls[i].pos_in_path - balls[i - 1].pos_in_path != 2 * \131 BALL_RADIUS // self.path.step:132 return False133 return True134 @staticmethod135 def are_stopped(start_index, balls):136 for i in range(0, start_index):...

Full Screen

Full Screen

test_cephfs.py

Source:test_cephfs.py Github

copy

Full Screen

...10 cephfs.mount()11def teardown_module():12 global cephfs13 cephfs.shutdown()14def setup_test():15 d = cephfs.opendir(b"/")16 dent = cephfs.readdir(d)17 while dent:18 if (dent.d_name not in [b".", b".."]):19 if dent.is_dir():20 cephfs.rmdir(b"/" + dent.d_name)21 else:22 cephfs.unlink(b"/" + dent.d_name)23 dent = cephfs.readdir(d)24 cephfs.closedir(d)25 cephfs.chdir(b"/")26@with_setup(setup_test)27def test_conf_get():28 fsid = cephfs.conf_get("fsid")...

Full Screen

Full Screen

test_new_account_form.py

Source:test_new_account_form.py Github

copy

Full Screen

...9from clik.argparse import ArgumentParser10from safe.form.account import NewAccountForm11from safe.model import Account, Alias, Code, Policy, Question12from test import memory_db # noqa: I10013def setup_test(db, *argv):14 """15 Set up the database fixtures for test cases.16 This creates an account named ``foo`` and two policies, named ``alpha``17 and ``bravo``.18 :param db: Database session in which to create fixtures19 :type db: SQLAlchemy database session20 :param argv: Command-line arguments to pass through to the form21 :return: 2-tuple ``(form, valid)`` where ``form`` is a22 bound and validated :class:`safe.form.account.NewAccountForm`23 and ``valid`` is a :class:`bool` indicating whether the form is24 valid25 """26 db.add(Account(name='foo'))27 db.add(Policy(name='alpha'))28 db.add(Policy(name='bravo'))29 db.commit()30 parser = ArgumentParser()31 form = NewAccountForm()32 form.configure_parser(parser)33 valid = form.bind_and_validate(args=parser.parse_args(argv))34 return form, valid35@memory_db36def test_policy_validator(db):37 """Check that policy validator fails for invalid policy names."""38 form, valid = setup_test(db, '--name', 'foo', '--password-policy', 'golf')39 assert not valid40 assert len(form.password_policy.errors) == 141 assert form.password_policy.errors[0] == 'No policy with that name'42@pytest.mark.parametrize('value', ['not valid', 'bad:punct', '', 'a' * 30])43def test_slug_validator(value):44 """Check that slug validator fails for invalid slugs."""45 @memory_db46 def inner(db):47 _, valid = setup_test(db, '--name', value)48 assert not valid49 inner()50@memory_db51def test_name_exists(db):52 """Check that name validator fails for names that already exist."""53 form, valid = setup_test(db, '--name', 'foo')54 assert not valid55 assert len(form.name.errors) == 156 assert form.name.errors[0] == 'Account with that name/alias already exists'57@memory_db58def test_alias_already_supplied_as_name(db):59 """Check that alias validator fails when alias was supplied as name."""60 form, valid = setup_test(db, '--name', 'bar', '--alias', 'bar')61 assert not valid62 assert len(form.alias.errors) == 163 msg = 'Alias "bar" already supplied as name or other alias'64 assert form.alias.errors[0] == msg65@memory_db66def test_alias_already_supplied_as_alias(db):67 """Check that alias validator fails when alias was supplied as name."""68 form, valid = setup_test(69 db,70 '--name', 'bar',71 '--alias', 'baz',72 '--alias', 'baz',73 )74 assert not valid75 assert len(form.alias.errors) == 176 msg = 'Alias "baz" already supplied as name or other alias'77 assert form.alias.errors[0] == msg78@memory_db79def test_alias_exists(db):80 """Check that alias validator fails when alias already exists."""81 form, valid = setup_test(db, '--name', 'bar', '--alias', 'foo')82 assert not valid83 assert len(form.alias.errors) == 184 msg = 'Account with name/alias "foo" already exists'85 assert form.alias.errors[0] == msg86@memory_db87def test_empty(db):88 """Check account creation for empty form (except for required name)."""89 form, valid = setup_test(db, '--name', 'bar')90 assert valid91 account = form.create_account()92 db.commit()93 assert account.description is None94 assert account.email is None95 assert account.name == 'bar'96 assert account.question_policy_id is None97 assert account.password_policy_id is None98 assert account.username is None99 assert Alias.query.count() == 0100 assert Code.query.count() == 0101 assert Question.query.count() == 0102@memory_db103def test_happy_path(db):104 """Check account creation for fully-specified form."""105 form, valid = setup_test(106 db,107 '--name', 'bar',108 '--description', 'charlie delta',109 '--email', 'me@example.com',110 '--question-policy', 'alpha',111 '--password-policy', 'bravo',112 '--username', 'my_username',113 '--alias', 'echo',114 '--alias', 'foxtrot',115 '--code', 'golf',116 '--code', 'hotel',117 )118 assert valid119 account = form.create_account()...

Full Screen

Full Screen

test_rgwfs.py

Source:test_rgwfs.py Github

copy

Full Screen

...11 root_handler = rgwfs.mount()12def teardown_module():13 global rgwfs14 rgwfs.shutdown()15def setup_test():16 global root_dir_handler17 names = []18 try:19 root_dir_handler = rgwfs.opendir(root_handler, b"bucket", 0)20 except Exception:21 root_dir_handler = rgwfs.mkdir(root_handler, b"bucket", 0)22 def cb(name, offset):23 names.append(name)24 rgwfs.readdir(root_dir_handler, cb, 0, 0)25 for name in names:26 rgwfs.unlink(root_dir_handler, name, 0)27@with_setup(setup_test)28def test_version():29 rgwfs.version()...

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