How to use get_events method in localstack

Best Python code snippet using localstack_python

test_addon_snapshot.py

Source:test_addon_snapshot.py Github

copy

Full Screen

...30 node=self.node,31 external_account=self.external_account,32 )33 def test_run_for_all_addon(self):34 results = AddonSnapshot().get_events()35 names = [res['provider']['name'] for res in results]36 for addon in ADDONS_AVAILABLE:37 assert_in(addon.short_name, names)38 def test_one_user_one_node_one_addon(self):39 results = AddonSnapshot().get_events()40 github_res = [res for res in results if res['provider']['name'] == 'github'][0]41 assert_equal(github_res['users']['enabled'], 1)42 assert_equal(github_res['nodes']['total'], 1)43 def test_one_user_one_node_one_addon_one_node_linked(self):44 results = AddonSnapshot().get_events()45 github_res = [res for res in results if res['provider']['name'] == 'github'][0]46 assert_equal(github_res['users']['enabled'], 1)47 assert_equal(github_res['nodes']['total'], 1)48 def test_one_user_with_multiple_githubs(self):49 oauth_settings2 = GitHubAccountFactory(display_name='hmoco2')50 oauth_settings2.save()51 self.user.external_accounts.add(oauth_settings2)52 self.user.save()53 results = AddonSnapshot().get_events()54 github_res = [res for res in results if res['provider']['name'] == 'github'][0]55 assert_equal(github_res['users']['enabled'], 1)56 def test_one_user_with_multiple_addons(self):57 results = AddonSnapshot().get_events()58 github_res = [res for res in results if res['provider']['name'] == 'github'][0]59 googledrive_res = [res for res in results if res['provider']['name'] == 'googledrive'][0]60 assert_equal(github_res['users']['enabled'], 1)61 assert_equal(googledrive_res['users']['enabled'], 0)62 self.user.add_addon('googledrive')63 oauth_settings = GoogleDriveAccountFactory()64 oauth_settings.save()65 self.user.external_accounts.add(oauth_settings)66 self.user.save()67 results = AddonSnapshot().get_events()68 github_res = [res for res in results if res['provider']['name'] == 'github'][0]69 googledrive_res = [res for res in results if res['provider']['name'] == 'googledrive'][0]70 assert_equal(github_res['users']['enabled'], 1)71 assert_equal(googledrive_res['users']['enabled'], 1)72 def test_many_users_each_with_a_different_github(self):73 user = AuthUserFactory()74 user.add_addon('github')75 oauth_settings2 = GitHubAccountFactory(display_name='hmoco2')76 oauth_settings2.save()77 user.external_accounts.add(oauth_settings2)78 user.save()79 results = AddonSnapshot().get_events()80 github_res = [res for res in results if res['provider']['name'] == 'github'][0]81 assert_equal(github_res['users']['enabled'], 2)82 assert_equal(github_res['users']['authorized'], 1)83 assert_equal(github_res['users']['linked'], 1)84 def test_many_users_each_with_the_same_github_enabled(self):85 user = AuthUserFactory()86 user.add_addon('github')87 user.external_accounts.add(self.external_account)88 user.save()89 results = AddonSnapshot().get_events()90 github_res = [res for res in results if res['provider']['name'] == 'github'][0]91 assert_equal(github_res['users']['enabled'], 2)92 def test_github_enabled_not_linked_or_authorized(self):93 user = AuthUserFactory()94 user.add_addon('github')95 user.external_accounts.add(self.external_account)96 user.save()97 results = AddonSnapshot().get_events()98 github_res = [res for res in results if res['provider']['name'] == 'github'][0]99 assert_equal(github_res['users']['enabled'], 2)100 assert_equal(github_res['users']['authorized'], 1)101 assert_equal(github_res['users']['linked'], 1)102 def test_one_node_with_multiple_addons(self):103 results = AddonSnapshot().get_events()104 github_res = [res for res in results if res['provider']['name'] == 'github'][0]105 googledrive_res = [res for res in results if res['provider']['name'] == 'googledrive'][0]106 assert_equal(github_res['nodes']['total'], 1)107 assert_equal(googledrive_res['nodes']['total'], 0)108 self.user.add_addon('googledrive')109 user_addon = self.user.get_addon('googledrive')110 oauth_settings = GoogleDriveAccountFactory()111 oauth_settings.save()112 self.user.external_accounts.add(oauth_settings)113 self.user.save()114 self.node.add_addon('googledrive', Auth(self.user))115 node_addon = self.node.get_addon('googledrive')116 node_addon.user = self.user.fullname117 node_addon.user_settings = user_addon118 node_addon.external_account = oauth_settings119 node_addon.save()120 results = AddonSnapshot().get_events()121 github_res = [res for res in results if res['provider']['name'] == 'github'][0]122 googledrive_res = [res for res in results if res['provider']['name'] == 'googledrive'][0]123 assert_equal(github_res['nodes']['total'], 1)124 assert_equal(googledrive_res['nodes']['total'], 1)125 def test_many_nodes_with_one_addon(self):126 results = AddonSnapshot().get_events()127 github_res = [res for res in results if res['provider']['name'] == 'github'][0]128 assert_equal(github_res['nodes']['total'], 1)129 node = ProjectFactory(creator=self.user)130 node.add_addon('github', Auth(self.user))131 node_addon = node.get_addon('github')132 node_addon.user = self.user.fullname133 node_addon.repo = '8 (circle)'134 node_addon.user_settings = self.user_addon135 node_addon.external_account = self.external_account136 node_addon.save()137 node.save()138 results = AddonSnapshot().get_events()139 github_res = [res for res in results if res['provider']['name'] == 'github'][0]140 assert_equal(github_res['nodes']['total'], 2)141 def test_node_count_deleted_addon(self):142 results = AddonSnapshot().get_events()143 github_res = [res for res in results if res['provider']['name'] == 'github'][0]144 assert_equal(github_res['nodes']['deleted'], 0)145 node = ProjectFactory(creator=self.user)146 node.add_addon('github', Auth(self.user))147 node_addon = node.get_addon('github')148 node_addon.delete()149 results = AddonSnapshot().get_events()150 github_res = [res for res in results if res['provider']['name'] == 'github'][0]151 assert_equal(github_res['nodes']['deleted'], 1)152 def test_node_count_disconected_addon(self):153 results = AddonSnapshot().get_events()154 github_res = [res for res in results if res['provider']['name'] == 'github'][0]155 assert_equal(github_res['nodes']['disconnected'], 0)156 node = ProjectFactory(creator=self.user)157 node.add_addon('github', Auth(self.user))158 node_addon = node.get_addon('github')159 node_addon.external_account = None160 node_addon.save()161 results = AddonSnapshot().get_events()162 github_res = [res for res in results if res['provider']['name'] == 'github'][0]163 assert_equal(github_res['nodes']['disconnected'], 1)164 def test_all_users_have_wiki_osfstorage_enabled(self):165 all_user_count = OSFUser.objects.all().count()166 results = AddonSnapshot().get_events()167 osfstorage_res = [res for res in results if res['provider']['name'] == 'osfstorage'][0]168 wiki_res = [res for res in results if res['provider']['name'] == 'osfstorage'][0]169 assert_equal(osfstorage_res['users']['enabled'], all_user_count)170 assert_equal(wiki_res['users']['enabled'], all_user_count)171 def test_wiki_deleted_shows_as_deleted(self):172 node = ProjectFactory(creator=self.user)173 node.delete_addon('wiki', auth=Auth(self.user))174 results = AddonSnapshot().get_events()175 wiki_res = [res for res in results if res['provider']['name'] == 'wiki'][0]176 assert_equal(wiki_res['nodes']['deleted'], 1)177 def test_node_settings_has_no_owner_not_connected(self):178 self.node_addon.owner = None179 self.node_addon.save()180 results = AddonSnapshot().get_events()181 storage_res = [res for res in results if res['provider']['name'] == 'github'][0]...

Full Screen

Full Screen

test_proc.py

Source:test_proc.py Github

copy

Full Screen

1# Copyright (c) 2014 - 2016 townhallpinball.org2#3# Permission is hereby granted, free of charge, to any person obtaining a4# copy of this software and associated documentation files (the "Software"),5# to deal in the Software without restriction, including without limitation6# the rights to use, copy, modify, merge, publish, distribute, sublicense,7# and/or sell copies of the Software, and to permit persons to whom the8# Software is furnished to do so, subject to the following conditions:9#10# The above copyright notice and this permission notice shall be included in11# all copies or substantial portions of the Software.12#13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19# DEALINGS IN THE SOFTWARE.20from pin.lib import p, proc21import unittest22from mock import Mock, patch23from tests import fixtures24class TestPROC(unittest.TestCase):25 def setUp(self):26 fixtures.reset()27 @patch("pin.lib.proc.create_buffer")28 def test_init(self, *args):29 proc.init()30 @patch("pygame.PixelArray")31 def test_process(self, *args):32 p.dmd.render = Mock()33 proc.process()34 @patch("pygame.PixelArray")35 @patch("pin.lib.p.proc.api.get_events")36 def test_active_switch_event(self, get_events, *args):37 p.dmd.render = Mock()38 switch = p.switches["start_button"]39 get_events.return_value = [{40 "type": p.proc.SWITCH_CLOSED,41 "value": switch.number42 }]43 p.proc.api.get_events = get_events44 listener1 = Mock()45 listener2 = Mock()46 listener3 = Mock()47 listener4 = Mock()48 p.events.on("switch_start_button", listener1)49 p.events.on("switch_start_button_active", listener2)50 p.events.on("switch_active", listener3)51 p.events.on("switch", listener4)52 proc.process()53 p.events.dispatch()54 self.assertTrue(listener1.called)55 self.assertTrue(listener2.called)56 listener3.assert_called_with(switch)57 listener4.assert_called_with(switch, True)58 self.assertTrue(switch.active)59 @patch("pygame.PixelArray")60 @patch("pin.lib.p.proc.api.get_events")61 def test_inactive_switch_event(self, get_events, *args):62 p.dmd.render = Mock()63 switch = p.switches["start_button"]64 get_events.return_value = [{65 "type": p.proc.SWITCH_OPENED,66 "value": switch.number67 }]68 p.proc.api.get_events = get_events69 listener2 = Mock()70 listener3 = Mock()71 listener4 = Mock()72 p.events.on("switch_start_button_inactive", listener2)73 p.events.on("switch_inactive", listener3)74 p.events.on("switch", listener4)75 proc.process()76 p.events.dispatch()77 self.assertTrue(listener2.called)78 listener3.assert_called_with(switch)79 listener4.assert_called_with(switch, False)80 self.assertFalse(switch.active)81 @patch("pygame.PixelArray")82 @patch("pin.lib.p.proc.api.get_events")83 def test_active_opto_switch_event(self, get_events, *args):84 p.dmd.render = Mock()85 switch = p.switches["trough"]86 get_events.return_value = [{87 "type": p.proc.SWITCH_OPENED,88 "value": switch.number89 }]90 p.proc.api.get_events = get_events91 listener = Mock()92 p.events.on("switch_trough_active", listener)93 proc.process()94 p.events.dispatch()95 self.assertTrue(listener.called)96 self.assertTrue(switch.active)97 @patch("pygame.PixelArray")98 @patch("pin.lib.p.proc.api.get_events")99 def test_inactive_opto_switch_event(self, get_events, *args):100 p.dmd.render = Mock()101 switch = p.switches["trough"]102 get_events.return_value = [{103 "type": p.proc.SWITCH_CLOSED,104 "value": switch.number105 }]106 p.proc.api.get_events = get_events107 listener = Mock()108 p.events.on("switch_trough_inactive", listener)109 proc.process()110 p.events.dispatch()111 self.assertTrue(listener.called)112 self.assertFalse(switch.active)113 @patch("pygame.PixelArray")114 @patch("pin.lib.p.proc.api.get_events")115 @patch("pin.lib.proc.log")116 def test_invalid_event(self, log, get_events, *args):117 p.dmd.render = Mock()118 get_events.return_value = [{119 "type": 10,120 "value": 0121 }]122 p.proc.api.get_events = get_events123 proc.process()124 self.assertTrue(log.error.called)125 @patch("pygame.PixelArray")126 @patch("pin.lib.proc.virtual_dmd")127 def test_process_virtual(self, *args):128 p.dmd.render = Mock()129 p.options["virtual"] = True...

Full Screen

Full Screen

test_device_base.py

Source:test_device_base.py Github

copy

Full Screen

2from brick.device import base3class SingleClickHandlerTest(unittest.TestCase):4 def test_single(self):5 handler = base.SingleClickHandler(start=0)6 self.assertEqual(handler.get_events(False, ms=50), [])7 self.assertEqual(handler.get_events(False, ms=100), [])8 self.assertEqual(handler.get_events(True, ms=150), ['begin', 'single'])9 self.assertEqual(handler.get_events(True, ms=200), [])10 self.assertEqual(handler.get_events(False, ms=250), ['end'])11 self.assertEqual(handler.get_events(False, ms=300), [])12class LongClickHandlerTest(unittest.TestCase):13 def test_single(self):14 handler = base.LongClickHandler(long_click=1000, start=0)15 self.assertEqual(handler.get_events(False, ms=50), [])16 self.assertEqual(handler.get_events(False, ms=100), [])17 self.assertEqual(handler.get_events(True, ms=150), ['begin'])18 self.assertEqual(handler.get_events(True, ms=200), [])19 self.assertEqual(handler.get_events(False, ms=250), ['single', 'end'])20 self.assertEqual(handler.get_events(False, ms=300), [])21 def test_long(self):22 handler = base.LongClickHandler(long_click=1000, start=0)23 self.assertEqual(handler.get_events(False, ms=50), [])24 self.assertEqual(handler.get_events(True, ms=100), ['begin'])25 self.assertEqual(handler.get_events(True, ms=1100), [])26 self.assertEqual(handler.get_events(True, ms=1150), ['long'])27 self.assertEqual(handler.get_events(True, ms=1200), [])28 self.assertEqual(handler.get_events(False, ms=1500), ['end'])...

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