Best Python code snippet using selene_python
test_Dot11HierarchicalUpdate.py
Source:test_Dot11HierarchicalUpdate.py
...60 self.assertEqual(self.packet3.get_tail_size(), 5)61 62 def test_03_ChildModificationTest(self):63 "ProtocolPacket - get_packet hierarchical update test"64 self.packet1.load_body("**NewBody**")65 self.assertEqual(self.packet1.get_packet(), "Header1**NewBody**Tail1")66 self.assertEqual(self.packet2.get_packet(), "Header2Header1**NewBody**Tail1Tail2")67 self.assertEqual(self.packet3.get_packet(), "Header3Header2Header1**NewBody**Tail1Tail2Tail3") 68 69 def test_04_ChildModificationTest(self):70 "ProtocolPacket - size getters hierarchical update test"71 self.packet1.load_body("**NewBody**")72 #self.packet1 => "Header1**NewBody**Tail1"73 #self.packet2 => "Header2Header1**NewBody**Tail1Tail2"74 #self.packet3 => "Header3Header2Header1**NewBody**Tail1Tail2Tail3" 75 76 self.assertEqual(self.packet1.get_size(), 7+11+5 )77 self.assertEqual(self.packet1.get_header_size(), 7)78 self.assertEqual(self.packet1.get_body_size(), 11)79 self.assertEqual(self.packet1.get_tail_size(), 5)80 81 self.assertEqual(self.packet2.get_size(), 7+ (7+11+5) +5 ) 82 self.assertEqual(self.packet2.get_header_size(), 7)83 self.assertEqual(self.packet2.get_body_size(), 7+11+5)84 self.assertEqual(self.packet2.get_tail_size(), 5)85 86 self.assertEqual(self.packet3.get_size(), 7+ (7+ (7+11+5) +5) +5 ) 87 self.assertEqual(self.packet3.get_header_size(), 7)88 self.assertEqual(self.packet3.get_body_size(), 7+ (7+11+5) +5)89 self.assertEqual(self.packet3.get_tail_size(), 5)90 def test_05_ChildModificationTest(self):91 "ProtocolPacket - body packet hierarchical update test"92 self.packet1.load_body("**NewBody**")93 self.assertEqual(self.packet1.body.get_buffer_as_string(), "**NewBody**")94 self.assertEqual(self.packet2.body.get_buffer_as_string(), "Header1**NewBody**Tail1")95 self.assertEqual(self.packet3.body.get_buffer_as_string(), "Header2Header1**NewBody**Tail1Tail2") 96 def test_06_ChildModificationTest(self):97 "ProtocolPacket - get_body_as_string packet hierarchical update test"98 self.packet1.load_body("**NewBody**")99 self.assertEqual(self.packet1.get_body_as_string(), "**NewBody**")100 self.assertEqual(self.packet2.get_body_as_string(), "Header1**NewBody**Tail1")101 self.assertEqual(self.packet3.get_body_as_string(), "Header2Header1**NewBody**Tail1Tail2") 102 def test_07_ChildModificationTest(self):103 "ProtocolPacket - load_body child hierarchy update test"104 self.assertEqual(self.packet1.parent(), self.packet2)105 self.assertEqual(self.packet2.parent(), self.packet3)106 107 self.assertEqual(self.packet3.child(), self.packet2)108 self.assertEqual(self.packet2.child(), self.packet1)109 110 self.packet2.load_body("Header1**NewBody**Tail1")111 self.assertEqual(self.packet1.parent(), None)112 self.assertEqual(self.packet2.parent(), self.packet3)113 114 self.assertEqual(self.packet3.child(), self.packet2)115 self.assertEqual(self.packet2.child(), None)116 117 self.assertEqual(self.packet1.body.get_buffer_as_string(), "Body1")118 self.assertEqual(self.packet2.body.get_buffer_as_string(), "Header1**NewBody**Tail1")119 self.assertEqual(self.packet3.body.get_buffer_as_string(), "Header2Header1**NewBody**Tail1Tail2") 120 121suite = unittest.TestLoader().loadTestsFromTestCase(TestDot11HierarchicalUpdate)...
__init__.py
Source:__init__.py
1import os2import re3from clarify_brightcove_sync.brightcove_api_client import BrightcoveAPIClient4clarify_host = 'https://api.clarify.io'5def load_body(filename):6 text = None7 with open(os.path.join('.', 'tests', 'data', filename), encoding="utf-8") as f:8 text = f.read()9 return text if text else '{}'10def register_uris(httpretty, metadata_synced=False, bc_videos_auth_error=False, bc_videos_throttle=False,11 cfy_post_bundle_error=False):12 httpretty.HTTPretty.allow_net_connect = False13 responses = []14 if cfy_post_bundle_error:15 responses.append(httpretty.Response(body="{}", status=503, content_type='application/json'))16 else:17 responses.append(httpretty.Response(body=load_body('bundle_ref.json'), status=201,18 content_type='application/json'))19 httpretty.register_uri('POST', clarify_host + '/v1/bundles', responses=responses)20 httpretty.register_uri('GET', clarify_host + '/v1/bundles',21 body=load_body('bundles_1.json'), status=200,22 content_type='application/json')23 metadata_file = 'metadata_synced.json' if metadata_synced else 'metadata_empty.json'24 httpretty.register_uri('GET', re.compile(clarify_host + '/v1/bundles/(\w+)/metadata$'),25 body=load_body(metadata_file), status=200,26 content_type='application/json')27 httpretty.register_uri('PUT', re.compile(clarify_host + '/v1/bundles/(\w+)/metadata$'),28 body='{}', status=202,29 content_type='application/json')30 httpretty.register_uri('DELETE', re.compile(clarify_host + '/v1/bundles/(\w+)$'),31 body='', status=204,32 content_type='application/json')33 httpretty.register_uri('POST', 'https://oauth.brightcove.com/v3/access_token',34 body=load_body('bc_access_token.json'), status=200,35 content_type='application/json')36 httpretty.register_uri('GET', 'https://' + BrightcoveAPIClient.CMS_Server + '/v1/accounts//counts/videos',37 body=load_body('bc_counts_videos.json'), status=200,38 content_type='application/json')39 responses = []40 if bc_videos_auth_error:41 responses.append(httpretty.Response(body="{}", status=401, content_type='application/json'))42 if bc_videos_throttle:43 responses.append(httpretty.Response(body="{}", status=429, content_type='application/json'))44 responses.append(httpretty.Response(body=load_body('bc_videos.json'), status=200, content_type='application/json'))45 httpretty.register_uri('GET', 'https://' + BrightcoveAPIClient.CMS_Server + '/v1/accounts//videos',46 responses=responses)47 httpretty.register_uri('GET', re.compile('https://' + BrightcoveAPIClient.CMS_Server +48 '/v1/accounts//videos/(\w+)/sources$'),49 body=load_body('bc_video_sources.json'), status=200,...
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!!