How to use _add_record method in localstack

Best Python code snippet using localstack_python

hall_of_fame_test.py

Source:hall_of_fame_test.py Github

copy

Full Screen

...40 def test_heade_for_ANY_PERCENT(self):41 self._test_to_string_header(HallsOfFameHandler.ANY_PERCENT, '"any%" Hall of Fame')42 def test_heade_for_EQ_PERCENT(self):43 self._test_to_string_header(HallsOfFameHandler.EQ_PERCENT, '"eq%" Hall of Fame')44 def _add_record(self, **kwargs):45 if 'hall_of_fame_name' not in kwargs:46 kwargs['hall_of_fame_name'] = HallsOfFameHandler.ANY_PERCENT47 self._halls_of_fame_handler.add(**kwargs)48 def _test_hall_of_fame(self, expected_content, hall_of_fame_name=HallsOfFameHandler.ANY_PERCENT, limit=None):49 self._test_to_string_content(hall_of_fame_name, expected_content, limit)50 def test_when_no_records_are_added_then_hall_of_fame_is_empty(self):51 self._test_hall_of_fame(expected_content='Empty')52 def test_order_is_based_on_record_order(self):53 self._add_record(player_id=6, player_name='Player 8', record=SmallestTurnsNumberRecord(7))54 self._add_record(player_id=2, player_name='Player 3', record=SmallestTurnsNumberRecord(5))55 self._test_hall_of_fame(expected_content='1. Player 3 - 5 turns\n2. Player 8 - 7 turns')56 def test_when_two_records_with_same_value_are_added_then_order_is_based_on_addition_order(self):57 self._add_record(player_id=6, player_name='Player 8', record=SmallestTurnsNumberRecord(5))58 self._add_record(player_id=2, player_name='Player 3', record=SmallestTurnsNumberRecord(5))59 self._test_hall_of_fame('1. Player 8 - 5 turns\n2. Player 3 - 5 turns')60 def test_by_default_only_5_top_records_are_shown(self):61 for i in range(10, 0, -1):62 self._add_record(player_id=i, player_name=f'Player {i}', record=SmallestTurnsNumberRecord(i))63 self._test_hall_of_fame(64 '1. Player 1 - 1 turn\n'65 '2. Player 2 - 2 turns\n'66 '3. Player 3 - 3 turns\n'67 '4. Player 4 - 4 turns\n'68 '5. Player 5 - 5 turns')69 def test_limit_decides_how_many_top_records_are_shown(self):70 for i in range(10, 0, -1):71 self._add_record(player_id=i, player_name=f'Player {i}', record=SmallestTurnsNumberRecord(i))72 self._test_hall_of_fame(73 '1. Player 1 - 1 turn\n'74 '2. Player 2 - 2 turns\n'75 '3. Player 3 - 3 turns\n'76 '4. Player 4 - 4 turns\n'77 '5. Player 5 - 5 turns\n'78 '6. Player 6 - 6 turns\n'79 '7. Player 7 - 7 turns\n'80 '8. Player 8 - 8 turns\n'81 '9. Player 9 - 9 turns\n'82 '10. Player 10 - 10 turns',83 limit=15)84 def test_when_invalid_record_type_is_added_then_exception_is_raised(self):85 with self.assertRaises(TypeError):86 self._add_record(player_id=1, player_name='Player 1', record=LargestTurnsNumberRecord(7))87 def test_after_every_entry_addition_changed_handler_is_called(self):88 self._add_record(player_id=6, player_name='Player 8', record=SmallestTurnsNumberRecord(5))89 self._halls_fame_changed_handler.assert_called_once()90 self._halls_fame_changed_handler.reset_mock()91 self._add_record(player_id=7, player_name='Player 6', record=SmallestTurnsNumberRecord(8))92 self._halls_fame_changed_handler.assert_called_once()93 def test_when_hall_of_fame_is_unknown_for_addition_then_exception_is_raised(self):94 with self.assertRaises(ValueError):95 self._halls_of_fame_handler.add(96 player_id=1,97 player_name='Player 1',98 hall_of_fame_name='some hall of fame',99 record=SmallestTurnsNumberRecord(7))100 def test_when_hall_of_fame_is_unknown_for_to_string_then_exception_is_raised(self):101 with self.assertRaises(ValueError):102 self._halls_of_fame_handler.to_string(hall_of_fame_name='some hall of fame')103if __name__ == '__main__':...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

...17 userModel = get_user_model()18 user = userModel(username=username)19 user.save()20 return user21 def _add_record(self, user, tags_bits=[]):22 record = Record(user=user, transaction_type='EXP', amount=10)23 for bit in tags_bits:24 record.tags.set_bit(bit, True)25 record.save()26 return record27 def test_01_add_record(self):28 record = self._add_record(user=self.user, tags_bits=[1, 5])29 record.refresh_from_db()30 self.assertEqual(Record.objects.count(), 1)31 self.assertEqual(record.tags.mask, 34)32 def test_02_comma_separated_tags(self):33 record = self._add_record(user=self.user, tags_bits=[1, 5])34 self.assertEqual(record.comma_separated_tags_list(), 'cafe, fun')35 def test_03_redis_data_on_record_add(self):36 user = self._add_user(username='addrecord')37 self._add_record(user=self.user, tags_bits=[1, 5])38 self._add_record(user=self.user, tags_bits=[1])39 self.assertEqual(list(self.user.get_user_tags_order()), ['cafe', 'fun'])40 def test_04_redis_data_change_order(self):41 user = self._add_user(username='changerecord')42 self._add_record(user=user, tags_bits=[1, 5])43 self._add_record(user=user, tags_bits=[5])44 self.assertEqual(list(user.get_user_tags_order()), ['fun', 'cafe'])45 def test_05_redis_data_on_update_record(self):46 user = self._add_user(username='updaterecord')47 record = self._add_record(user=user, tags_bits=[1, 5])48 self._add_record(user=user, tags_bits=[5])49 self.assertEqual(list(user.get_user_tags_order()), ['fun', 'cafe'])50 record.tags.set_bit(1, False)51 record.tags.set_bit(0, True)52 record.save()53 self.assertEqual(list(user.get_user_tags_order()), ['fun', 'books'])54 def test_06_redis_data_on_delete(self):55 user = self._add_user(username='deleterecord')56 record = self._add_record(user=user, tags_bits=[1, 5])57 self._add_record(user=user, tags_bits=[1])58 self.assertEqual(list(user.get_user_tags_order()), ['cafe', 'fun'])59 record.delete()...

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