How to use get_resource method in localstack

Best Python code snippet using localstack_python

test_database.py

Source:test_database.py Github

copy

Full Screen

...26class FreeTestCase(TestCase):27 def test_create_text(self):28 with Database('demo.hforge.org', 19500, 20500) as database:29 with database.init_context():30 root = root = database.get_resource('/')31 # Create 1 resource32 container = root.make_resource('test-create-texts', Folder)33 resource = container.make_resource(None, Text)34 self.assertEqual(str(resource.abspath), '/test-create-texts/0')35 metadata = resource.metadata36 self.assertEqual(metadata.format, 'text')37 database.save_changes()38 # Check if resource exists39 resource = root.get_resource('/test-create-texts/0')40 self.assertEqual(resource.name, '0')41 search = database.search(abspath='/test-create-texts/0')42 self.assertEqual(len(search), 1)43 # Del resource44 root.del_resource('/test-create-texts/0')45 database.save_changes()46 # Check if has been removed47 resource = root.get_resource('/test-create-texts/0', soft=True)48 self.assertEqual(resource, None)49 search = database.search(abspath='/test-create-texts/1')50 self.assertEqual(len(search), 0)51 def test_create_user(self):52 with Database('demo.hforge.org', 19500, 20500) as database:53 with database.init_context():54 root = database.get_resource('/')55 # Create a new user56 email = 'test-create-user@hforge.org'57 password = 'password'58 user = root.make_user(email, password)59 self.assertEqual(user.name, '1')60 user.set_value('groups', ['/config/groups/admins'])61 database.save_changes()62 # Try to get user63 user = root.get_resource('/users/1', soft=True)64 self.assertEqual(user.name, '1')65 self.assertEqual(user.get_value('email'), 'test-create-user@hforge.org')66 self.assertEqual(user.authenticate(password), True)67 self.assertEqual(user.authenticate('badpassword'), False)68 # Cannot create 2 users with the same email address69 user = root.make_user(email, password)70 self.assertEqual(user, None)71 def test_create_two_resources_at_root(self):72 with Database('demo.hforge.org', 19500, 20500) as database:73 with database.init_context():74 root = database.get_resource('/')75 f1 = root.make_resource(None, Folder)76 self.assertEqual(f1.name, '1')77 self.assertEqual(database.added, set(['1.metadata']))78 f2 = root.make_resource(None, Folder)79 self.assertEqual(f2.name, '2')80 def test_create_two_resources_in_folder(self):81 with Database('demo.hforge.org', 19500, 20500) as database:82 with database.init_context():83 root = database.get_resource('/')84 container = root.make_resource('test-two-resources', Folder)85 self.assertEqual(root.get_resource('test-two-resources').name, 'test-two-resources')86 f1 = container.make_resource(None, Folder)87 self.assertEqual(f1.name, '0')88 self.assertEqual(database.added, set(['test-two-resources.metadata', 'test-two-resources/0.metadata']))89 f2 = container.make_resource(None, Folder)90 self.assertEqual(f2.name, '1')91 self.assertEqual(database.added, set(['test-two-resources.metadata' , 'test-two-resources/0.metadata', 'test-two-resources/1.metadata']))92 def test_multilingual_search(self):93 with Database('demo.hforge.org', 19500, 20500) as database:94 with database.init_context():95 root = root = database.get_resource('/')96 container = root.make_resource('test-multilingual', Folder)97 # Create N resources98 for i in range(0, 20):99 kw = {'title': {'fr': u'Bonjour', 'en': u'Hello'}}100 container.make_resource(str(i), Text, **kw)101 database.save_changes()102 # Check if resource exists103 query = AndQuery(104 get_base_path_query('/test-multilingual'),105 PhraseQuery('format', 'text'))106 search = database.search(query)107 self.assertEqual(len(search), 20)108 # Check if resource exists109 query = AndQuery(110 PhraseQuery('format', 'text'),111 PhraseQuery('title', u'Hello'),112 get_base_path_query('/test-multilingual'),113 )114 search = database.search(query)115 self.assertEqual(len(search), 20)116 query = AndQuery(117 PhraseQuery('format', 'text'),118 PhraseQuery('title_en', u'Hello'),119 get_base_path_query('/test-multilingual'),120 )121 search = database.search(query)122 self.assertEqual(len(search), 20)123 query = AndQuery(124 PhraseQuery('format', 'text'),125 PhraseQuery('title_fr', u'Bonjour'),126 get_base_path_query('/test-multilingual'),127 )128 search = database.search(query)129 self.assertEqual(len(search), 20)130 query = AndQuery(131 PhraseQuery('format', 'text'),132 PhraseQuery('title_es', u'Hola'),133 get_base_path_query('/test-multilingual'),134 )135 search = database.search(query)136 self.assertEqual(len(search), 0)137 # Close database138 database.close()139 def test_move_file(self):140 with Database('demo.hforge.org', 19500, 20500) as database:141 with database.init_context():142 kw = {'title': {'fr': u'Bonjour', 'en': u'Hello'},143 'data': 'this is text'}144 root = database.get_resource('/')145 container = root.make_resource('test-move', Folder)146 resource = container.make_resource(None, Text, **kw)147 self.assertEqual(str(resource.abspath), '/test-move/0')148 database.save_changes()149 # Move '/0' to '/1'150 root.move_resource('/test-move/0', '/test-move/1')151 self.assertEqual(root.get_resource('/test-move/0', soft=True), None)152 self.assertEqual(root.get_resource('/test-move/1').name, '1')153 # Move '/1' to '/1'154 root.move_resource('/test-move/1', '/test-move/1')155 self.assertEqual(root.get_resource('/test-move/1').name, '1')156 # Check text157 r1 = root.get_resource('/test-move/1')158 data = r1.get_value('data').to_str()159 self.assertEqual(data, 'this is text')160 database.close()161 def test_move_folder(self):162 with Database('demo.hforge.org', 19500, 20500) as database:163 with database.init_context():164 root = database.get_resource('/')165 kw = {'title': {'fr': u'Bonjour', 'en': u'Hello'}}166 container = root.make_resource('folder1', Folder, **kw)167 child = container.make_resource('child', Folder)168 child.make_resource('hello_child.txt', Text)169 container.make_resource('hello.txt', Text)170 self.assertEqual(171 database.added,172 set(['folder1.metadata', 'folder1/hello.txt.metadata',173 'folder1/child.metadata', 'folder1/child/hello_child.txt.metadata']))174 root.move_resource('folder1', 'folder2')175 self.assertEqual(root.get_resource('folder1', soft=True), None)176 self.assertEqual(root.get_resource('folder2').name, 'folder2')177 self.assertEqual(root.get_resource('folder2/hello.txt').abspath, '/folder2/hello.txt')178 self.assertEqual(179 database.added,180 set(['folder2.metadata', 'folder2/hello.txt.metadata',181 'folder2/child.metadata', 'folder2/child/hello_child.txt.metadata']))182 database.close()183 def test_set_bad_value(self):184 with Database('demo.hforge.org', 19500, 20500) as database:185 with database.init_context():186 root = database.get_resource('/')187 e = None188 try:189 root.set_value('mtime', time(10, 0))190 except Exception, e:191 pass192 self.assertNotEqual(e, None)193 def test_abort_transaction(self):194 with Database('demo.hforge.org', 19500, 20500) as database:195 with database.init_context():196 root = database.get_resource('/')197 kw = {'title': {'fr': u'Bonjour', 'en': u'Hello'},198 'data': 'this is text'}199 resource = root.make_resource(None, Text, **kw)200 self.assertEqual(str(resource.abspath), '/0')201 self.assertNotEqual(root.get_resource('/0'), None)202 database.save_changes()203 resource = root.make_resource(None, Text, **kw)204 self.assertEqual(str(resource.abspath), '/1')205 database.catalog.index_document({'abspath': '/2'})206 database.abort_changes()207 self.assertNotEqual(root.get_resource('/0'), None)208 self.assertEqual(root.get_resource('/1', soft=True), None)209 database.close()210 def test_close_transaction(self):211 """212 Test if flush is done when we close database213 """214 with Database('demo.hforge.org', 19500, 20500) as database:215 with database.init_context():216 root = database.get_resource('/')217 container = root.make_resource('folder-test-close-transaction', Folder)218 kw = {'title': {'fr': u'Bonjour', 'en': u'Hello'},219 'data': 'this is text'}220 resource = container.make_resource(None, Text, **kw)221 self.assertEqual(str(resource.abspath), '/folder-test-close-transaction/0')222 database.save_changes()223 query = AndQuery(224 get_base_path_query('/folder-test-close-transaction'),225 PhraseQuery('format', 'text'))226 search = database.search(query)227 self.assertEqual(len(search), 1)228 resource = root.make_resource(None, Text)229 database.close()230 with Database('demo.hforge.org', 19500, 20500) as database:231 with database.init_context():232 query = AndQuery(233 get_base_path_query('/folder-test-close-transaction'),234 PhraseQuery('format', 'text'))235 search = database.search(query)236 self.assertEqual(len(search), 1)237 self.assertEqual(root.get_resource('/folder-test-close-transaction/1', soft=True), None)238 def test_root(self):239 with Database('demo.hforge.org', 19500, 20500) as database:240 with database.init_context():241 root = database.get_resource('/')242 self.assertEqual(root.metadata.format, 'iKaaro')243 def test_create_folders(self):244 with Database('demo.hforge.org', 19500, 20500) as database:245 with database.init_context():246 root = database.get_resource('/')247 container = root.make_resource('folder-test-create-folders', Folder)248 container.make_resource('1', Text)249 container.make_resource('2', Text)250 container.make_resource('3', Text)251 names = sorted(container.get_names())252 self.assertEqual(names, ['1', '2', '3'])253 def test_remove_folder(self):254 with Database('demo.hforge.org', 19500, 20500) as database:255 with database.init_context() as context:256 root = database.get_resource('/')257 container = root.make_resource('folder-to-remove', Folder)258 container.make_resource('1', Text)259 container.make_resource('2', Text)260 container.make_resource('3', Text)261 context.database.save_changes()262 root.del_resource('folder-to-remove')263 self.assertEqual(264 database.removed,265 set(['folder-to-remove.metadata', 'folder-to-remove/1.metadata',266 'folder-to-remove/2.metadata', 'folder-to-remove/3.metadata']))267 self.assertEqual(root.get_resource('folder-to-remove', soft=True), None)268 self.assertEqual(root.get_resource('folder-to-remove/1', soft=True), None)269 self.assertEqual(root.get_resource('folder-to-remove/2', soft=True), None)270 self.assertEqual(root.get_resource('folder-to-remove/3', soft=True), None)271 def test_copy_folder(self):272 with Database('demo.hforge.org', 19500, 20500) as database:273 with database.init_context():274 root = database.get_resource('/')275 container = root.make_resource('folder-to-copy-1', Folder)276 container_child = container.make_resource('1', Folder)277 container_child.make_resource('subchild', Text)278 container.make_resource('2', Text)279 root.copy_resource('folder-to-copy-1', 'folder-to-copy-2')280 self.assertEqual(281 database.added,282 set([283 'folder-to-copy-1.metadata', 'folder-to-copy-1/1.metadata',284 'folder-to-copy-1/1/subchild.metadata', 'folder-to-copy-1/2.metadata',285 'folder-to-copy-2.metadata', 'folder-to-copy-2/1.metadata',286 'folder-to-copy-2/1/subchild.metadata', 'folder-to-copy-2/2.metadata',287 ]))288if __name__ == '__main__':...

Full Screen

Full Screen

app.py

Source:app.py Github

copy

Full Screen

...9 return MainWindow(self)10 @cached_property11 def icons(self):12 return {13 'blank': self.get_resource('icons/blank.png'),14 'blank16': self.get_resource('icons/blank16.png'),15 'copy': self.get_resource('icons/copy.png'),16 'delete': self.get_resource('icons/delete.png'),17 'load': self.get_resource('icons/load.png'),18 'load16': self.get_resource('icons/load16.png'),19 'paste': self.get_resource('icons/paste.png'),20 'plus': self.get_resource('icons/plus.png'),21 'save': self.get_resource('icons/disk.png'),22 'saveas': self.get_resource('icons/diskpencil.png'),23 'hand': self.get_resource('icons/hand.png'),24 'redo': self.get_resource('icons/redo.png'),25 'undo': self.get_resource('icons/undo.png')26 }27 @cached_property28 def default_location_images(self):29 return {30 'head': self.get_resource('default_location_images/head.jpg'),31 'upper_body': self.get_resource('default_location_images/upper_body.jpg'),32 'weak_hand': self.get_resource('default_location_images/weak_hand.jpg')33 }34 @cached_property35 def hand_illustrations(self):36 return {37 'neutral': self.get_resource('illustrations/neutral.jpg'),38 'slot2': self.get_resource('illustrations/slot2.jpg'),39 'slot3': self.get_resource('illustrations/slot3.jpg'),40 'slot4': self.get_resource('illustrations/slot4.jpg'),41 'slot5': self.get_resource('illustrations/slot5.jpg'),42 'slot6': self.get_resource('illustrations/slot6.jpg'),43 'slot7': self.get_resource('illustrations/slot7.jpg'),44 'slot10': self.get_resource('illustrations/slot10.jpg'),45 'slot11': self.get_resource('illustrations/slot11.jpg'),46 'slot12': self.get_resource('illustrations/slot12.jpg'),47 'slot13': self.get_resource('illustrations/slot13.jpg'),48 'slot14': self.get_resource('illustrations/slot14.jpg'),49 'slot15': self.get_resource('illustrations/slot15.jpg'),50 'slot17': self.get_resource('illustrations/slot17.jpg'),51 'slot18': self.get_resource('illustrations/slot18.jpg'),52 'slot19': self.get_resource('illustrations/slot19.jpg'),53 'slot20': self.get_resource('illustrations/slot20.jpg'),54 'slot22': self.get_resource('illustrations/slot22.jpg'),55 'slot23': self.get_resource('illustrations/slot23.jpg'),56 'slot24': self.get_resource('illustrations/slot24.jpg'),57 'slot25': self.get_resource('illustrations/slot25.jpg'),58 'slot27': self.get_resource('illustrations/slot27.jpg'),59 'slot28': self.get_resource('illustrations/slot28.jpg'),60 'slot29': self.get_resource('illustrations/slot29.jpg'),61 'slot30': self.get_resource('illustrations/slot30.jpg'),62 'slot32': self.get_resource('illustrations/slot32.jpg'),63 'slot33': self.get_resource('illustrations/slot33.jpg'),64 'slot34': self.get_resource('illustrations/slot34.jpg')65 }66 # @cached_property67 # def xslotimage(self):68 # return {69 # 'xslot': self.get_resource('xslotsample.png')70 # }71 @cached_property72 def predefined(self):73 return {74 'base': self.get_resource('predefined/base.png'),75 'no-match': self.get_resource('predefined/no-match.png'),76 'empty': self.get_resource('predefined/empty.png'),77 '1': self.get_resource('predefined/1.png'),78 'bent-1': self.get_resource('predefined/bent-1.png'),79 'crooked-1': self.get_resource('predefined/crooked-1.png'),80 '3': self.get_resource('predefined/3.png'),81 'clawed-3': self.get_resource('predefined/clawed-3.png'),82 'contracted-3': self.get_resource('predefined/contracted-3.png'),83 '4': self.get_resource('predefined/4.png'),84 'bent-4': self.get_resource('predefined/bent-4.png'),85 'clawed-4': self.get_resource('predefined/clawed-4.png'),86 'crooked-4': self.get_resource('predefined/crooked-4.png'),87 'slanted-4': self.get_resource('predefined/slanted-4.png'),88 '5': self.get_resource('predefined/5.png'),89 'bent-5': self.get_resource('predefined/bent-5.png'),90 'bent-midfinger-5': self.get_resource('predefined/bent-midfinger-5.png'),91 'clawed-extended-5': self.get_resource('predefined/clawed-extended-5.png'),92 'contracted-5': self.get_resource('predefined/contracted-5.png'),93 'relaxed-contracted-5': self.get_resource('predefined/relaxed-contracted-5.png'),94 'crooked-5': self.get_resource('predefined/crooked-5.png'),95 'crooked-slanted-5': self.get_resource('predefined/crooked-slanted-5.png'),96 'modified-5': self.get_resource('predefined/modified-5.png'),97 'slanted-5': self.get_resource('predefined/slanted-5.png'),98 99 '8': self.get_resource('predefined/8.png'),100 'covered-8': self.get_resource('predefined/covered-8.png'),101 'extended-8': self.get_resource('predefined/extended-8.png'),102 'open-8': self.get_resource('predefined/open-8.png'),103 'A': self.get_resource('predefined/A.png'),104 'closed-A-index': self.get_resource('predefined/closed-A-index.png'),105 'extended-A': self.get_resource('predefined/extended-A.png'),106 'A-index': self.get_resource('predefined/A-index.png'),107 'modified-A': self.get_resource('predefined/modified-A.png'),108 'open-A': self.get_resource('predefined/open-A.png'),109 'B1': self.get_resource('predefined/B1.png'),110 'bent-B': self.get_resource('predefined/bent-B.png'),111 'bent-extended-B': self.get_resource('predefined/bent-extended-B.png'),112 'clawed-extended-B': self.get_resource('predefined/clawed-extended-B.png'),113 'contracted-B': self.get_resource('predefined/contracted-B.png'),114 'extended-B': self.get_resource('predefined/extended-B.png'),115 'slanted-extended-B': self.get_resource('predefined/slanted-extended-B.png'),116 'B2': self.get_resource('predefined/B2.png'),117 'C': self.get_resource('predefined/C.png'),118 'clawed-C': self.get_resource('predefined/clawed-C.png'),119 'clawed-spread-C': self.get_resource('predefined/clawed-spread-C.png'),120 'contracted-C': self.get_resource('predefined/contracted-C.png'),121 'extended-C': self.get_resource('predefined/extended-C.png'),122 'flat-C': self.get_resource('predefined/flat-C.png'),123 'C-index': self.get_resource('predefined/C-index.png'),124 'double-C-index': self.get_resource('predefined/double-C-index.png'),125 'spread-C': self.get_resource('predefined/spread-C.png'),126 'D': self.get_resource('predefined/D.png'),127 'partially-bent-D': self.get_resource('predefined/partially-bent-D.png'),128 'closed-bent-D': self.get_resource('predefined/closed-bent-D.png'),129 'modified-D': self.get_resource('predefined/modified-D.png'),130 'E': self.get_resource('predefined/E.png'),131 'open-E': self.get_resource('predefined/open-E.png'),132 'F': self.get_resource('predefined/F.png'),133 'adducted-F': self.get_resource('predefined/adducted-F.png'),134 'clawed-F': self.get_resource('predefined/clawed-F.png'),135 'covered-F': self.get_resource('predefined/covered-F.png'),136 'flat-F': self.get_resource('predefined/flat-F.png'),137 'flat-clawed-F': self.get_resource('predefined/flat-clawed-F.png'),138 'flat-open-F': self.get_resource('predefined/flat-open-F.png'),139 'offset-F': self.get_resource('predefined/offset-F.png'),140 'open-F': self.get_resource('predefined/open-F.png'),141 'slanted-F': self.get_resource('predefined/slanted-F.png'),142 'G': self.get_resource('predefined/G.png'),143 'closed-modified-G': self.get_resource('predefined/closed-modified-G.png'),144 'closed-double-modified-G': self.get_resource('predefined/closed-double-modified-G.png'),145 'double-modified-G': self.get_resource('predefined/double-modified-G.png'),146 'modified-G': self.get_resource('predefined/modified-G.png'),147 'I': self.get_resource('predefined/I.png'),148 'bent-I': self.get_resource('predefined/bent-I.png'),149 'bent-combined-I+1': self.get_resource('predefined/bent-combined-I+1.png'),150 'clawed-I': self.get_resource('predefined/clawed-I.png'),151 'combined-I+1': self.get_resource('predefined/combined-I+1.png'),152 'combined-ILY': self.get_resource('predefined/combined-ILY.png'),153 'combined-I+A': self.get_resource('predefined/combined-I+A.png'),154 'flat-combined-I+1': self.get_resource('predefined/flat-combined-I+1.png'),155 'K': self.get_resource('predefined/K.png'),156 'extended-K': self.get_resource('predefined/extended-K.png'),157 'L': self.get_resource('predefined/L.png'),158 'bent-L': self.get_resource('predefined/bent-L.png'),159 'bent-thumb-L': self.get_resource('predefined/bent-thumb-L.png'),160 'clawed-extended-L': self.get_resource('predefined/clawed-extended-L.png'),161 'contracted-L': self.get_resource('predefined/contracted-L.png'),162 'double-contracted-L': self.get_resource('predefined/double-contracted-L.png'),163 'crooked-L': self.get_resource('predefined/crooked-L.png'),164 'M': self.get_resource('predefined/M.png'),165 'flat-M': self.get_resource('predefined/flat-M.png'),166 'middle-finger': self.get_resource('predefined/middle-finger.png'),167 'N': self.get_resource('predefined/N.png'),168 'O': self.get_resource('predefined/O.png'),169 'covered-O': self.get_resource('predefined/covered-O.png'),170 'flat-O': self.get_resource('predefined/flat-O.png'),171 'O-index': self.get_resource('predefined/O-index.png'),172 'modified-O': self.get_resource('predefined/modified-O.png'),173 'offset-O': self.get_resource('predefined/offset-O.png'),174 'open-O-index': self.get_resource('predefined/open-O-index.png'),175 'spread-open-O': self.get_resource('predefined/spread-open-O.png'),176 'R': self.get_resource('predefined/R.png'),177 'bent-R': self.get_resource('predefined/bent-R.png'),178 'extended-R': self.get_resource('predefined/extended-R.png'),179 'S': self.get_resource('predefined/S.png'),180 'T': self.get_resource('predefined/T.png'),181 'covered-T': self.get_resource('predefined/covered-T.png'),182 'U': self.get_resource('predefined/U.png'),183 'bent-U': self.get_resource('predefined/bent-U.png'),184 'bent-extended-U': self.get_resource('predefined/bent-extended-U.png'),185 'clawed-U': self.get_resource('predefined/clawed-U.png'),186 'contracted-U': self.get_resource('predefined/contracted-U.png'),187 'contracted-U-index': self.get_resource('predefined/contracted-U-index.png'),188 'crooked-U': self.get_resource('predefined/crooked-U.png'),189 'extended-U': self.get_resource('predefined/extended-U.png'),190 'V': self.get_resource('predefined/V.png'),191 'bent-V': self.get_resource('predefined/bent-V.png'),192 'bent-extended-V': self.get_resource('predefined/bent-extended-V.png'),193 'clawed-V': self.get_resource('predefined/clawed-V.png'),194 'clawed-extended-V': self.get_resource('predefined/clawed-extended-V.png'),195 'closed-V': self.get_resource('predefined/closed-V.png'),196 'crooked-V': self.get_resource('predefined/crooked-V.png'),197 'crooked-extended-V': self.get_resource('predefined/crooked-extended-V.png'),198 'slanted-V': self.get_resource('predefined/slanted-V.png'),199 'W': self.get_resource('predefined/W.png'),200 'clawed-W': self.get_resource('predefined/clawed-W.png'),201 'closed-W': self.get_resource('predefined/closed-W.png'),202 'covered-W': self.get_resource('predefined/covered-W.png'),203 'crooked-W': self.get_resource('predefined/crooked-W.png'),204 'X': self.get_resource('predefined/X.png'),205 'closed-X': self.get_resource('predefined/closed-X.png'),206 'Y': self.get_resource('predefined/Y.png'),207 'combined-Y&middle': self.get_resource('predefined/combined-Y&middle.png'),208 'combined-Y&U': self.get_resource('predefined/combined-Y&U.png'),209 # 'modified-Y': self.get_resource('predefined/modified-Y.png'), # TODO KV April deleted this file 20211115210 'open-palm': self.get_resource('predefined/open-palm.png')...

Full Screen

Full Screen

test_vpnaas.py

Source:test_vpnaas.py Github

copy

Full Screen

...15 def verify_dummy_router(self, obj, dummy_router_tag):16 """ Verifies Dummy Router on VSD """17 LOG.info("Verifying the dummy router")18 dummy_router = (19 obj.os_data_struct.get_resource(dummy_router_tag).os_data20 )21 l3domain_ext_id = test_base.get_external_id(dummy_router['id'])22 vsd_l3dom = obj.TB.vsd_1.get_domain(23 filter=test_base.get_filter_str('externalID', l3domain_ext_id)24 )25 obj.os_data_struct.update_resource(dummy_router_tag, \26 vsd_data=vsd_l3dom)27 def verify_dummy_subnet(self, obj, dummy_subnet_tag, cidr):28 """ Verifies Dummy Subnet on VSD """29 dummy_subnet = (30 obj.os_data_struct.get_resource(dummy_subnet_tag).os_data31 )32 subnet_ext_id = test_base.get_external_id(dummy_subnet['id'])33 vsd_subnet = obj.TB.vsd_1.get_subnet(34 filter=test_base.get_filter_str('externalID', subnet_ext_id)35 )36 obj.assertEqual(dummy_subnet['cidr'], vsd_subnet.address)37 obj.assertEqual(cidr, vsd_subnet.address)38 obj.os_data_struct.update_resource(dummy_subnet_tag, \39 vsd_data=vsd_subnet)40 class _create_delete_vpnservice():41 def __init__(self):42 self.vpnaas_cli_test = VPNaaSCliTests()43 pass44 def verify_vpn_dummy_router(self, obj):45 """ Verifies Dummy Router/Subnet for vpnservice """46 # Verifying dummy router47 tag_router = obj.os_data_struct.get_resource('routertag').user_data48 os_router = obj.os_data_struct.get_resource(tag_router['name']).os_data49 dummy_router_name = 'r_d_' + os_router['id']50 self.vpnaas_cli_test.verify_dummy_router(obj, dummy_router_name)51 # Getting Public net info52 tag_public = obj.os_data_struct.get_resource('publicnettag').user_data53 os_public = obj.os_data_struct.get_resource(tag_public['name']).os_data54 public_cidr = os_public['cidr']55 # Verifying dummy subnet56 tag_subnet = obj.os_data_struct.get_resource('subnettag').user_data57 os_subnet = obj.os_data_struct.get_resource(tag_subnet['name']).os_data58 dummy_subnet_name = 's_d_' + os_subnet['id']59 self.vpnaas_cli_test.verify_dummy_subnet(obj, \60 dummy_subnet_name, public_cidr)61 class _create_duplicate_vpnservice():62 def __init__(self):63 self.vpnaas_cli_test = VPNaaSCliTests()64 pass65 def verify_vpn_dummy_router(self, obj):66 """ Verifies Dummy Router/Subnet for vpnservice """67 # Verifying dummy router68 tag_router = obj.os_data_struct.get_resource('routertag').user_data69 os_router = obj.os_data_struct.get_resource(tag_router['name']).os_data70 dummy_router_name = 'r_d_' + os_router['id']71 self.vpnaas_cli_test.verify_dummy_router(obj, dummy_router_name)72 # Getting Public net info73 tag_public = obj.os_data_struct.get_resource('publicnettag').user_data74 os_public = obj.os_data_struct.get_resource(tag_public['name']).os_data75 public_cidr = os_public['cidr']76 # Verifying dummy subnet77 tag_subnet = obj.os_data_struct.get_resource('subnettag').user_data78 os_subnet = obj.os_data_struct.get_resource(tag_subnet['name']).os_data79 dummy_subnet_name = 's_d_' + os_subnet['id']80 self.vpnaas_cli_test.verify_dummy_subnet(obj, \81 dummy_subnet_name, public_cidr)82 class _create_delete_ipsecsiteconnection():83 def __init__(self):84 self.vpnaas_cli_test = VPNaaSCliTests()85 pass86 def verify_ipsec_vminterface(self, obj):87 """ Verifies VM interface for ipsecsiteconnection """88 # Verifying vm interface for vpn189 tag_subnet1 = obj.os_data_struct.get_resource('dummysubnet1').user_data90 vsd_subnet1 = (91 obj.os_data_struct.get_resource(tag_subnet1['name']).vsd_data92 )93 vpnservice_ip1 = (94 vsd_subnet1.vm_interfaces.fetch()[0][0].ip_address95 )96 tag_vpnservice1 = obj.os_data_struct.get_resource('vpnservice1').user_data97 vpnservice1 = (98 obj.os_data_struct.get_resource(tag_vpnservice1['name']).os_data99 )100 os_vpnservice_ip1 = vpnservice1['external_v4_ip']101 obj.assertEqual(vpnservice_ip1, os_vpnservice_ip1)102 # Verifying vm interface for vpn2103 tag_subnet2 = obj.os_data_struct.get_resource('dummysubnet2').user_data104 vsd_subnet2 = (105 obj.os_data_struct.get_resource(tag_subnet2['name']).vsd_data106 )107 vpnservice_ip2 = (108 vsd_subnet2.vm_interfaces.fetch()[0][0].ip_address109 )110 tag_vpnservice2 = obj.os_data_struct.get_resource('vpnservice2').user_data111 vpnservice2 = (112 obj.os_data_struct.get_resource(tag_vpnservice2['name']).os_data113 )114 os_vpnservice_ip2 = vpnservice2['external_v4_ip']115 obj.assertEqual(vpnservice_ip2, os_vpnservice_ip2)116 def verify_vpn_dummy_router(self, obj):117 """ Verifies Dummy Routers/Subnets for vpnservices """118 # Verifying dummy router1119 tag_router1 = obj.os_data_struct.get_resource('routertag1').user_data120 os_router1 = obj.os_data_struct.get_resource(tag_router1['name']).os_data121 dummy_router_name1 = 'r_d_' + os_router1['id']122 self.vpnaas_cli_test.verify_dummy_router(obj, dummy_router_name1)123 # Verifying dummy router2124 tag_router2 = obj.os_data_struct.get_resource('routertag2').user_data125 os_router2 = obj.os_data_struct.get_resource(tag_router2['name']).os_data126 dummy_router_name2 = 'r_d_' + os_router2['id']127 self.vpnaas_cli_test.verify_dummy_router(obj, dummy_router_name2)128 # Getting public Cidr129 tag_public = obj.os_data_struct.get_resource('publicnettag').user_data130 os_public = obj.os_data_struct.get_resource(tag_public['name']).os_data131 public_cidr = os_public['cidr']132 # Verifying dummy subnet1133 tag_subnet1 = obj.os_data_struct.get_resource('subnettag1').user_data134 os_subnet1 = obj.os_data_struct.get_resource(tag_subnet1['name']).os_data135 dummy_subnet_name1 = 's_d_' + os_subnet1['id']136 self.vpnaas_cli_test.verify_dummy_subnet(obj, \137 dummy_subnet_name1, public_cidr)138 # Verifying dummy subnet2139 tag_subnet2 = obj.os_data_struct.get_resource('subnettag2').user_data140 os_subnet2 = obj.os_data_struct.get_resource(tag_subnet2['name']).os_data141 dummy_subnet_name2 = 's_d_' + os_subnet2['id']142 self.vpnaas_cli_test.verify_dummy_subnet(obj, \143 dummy_subnet_name2, public_cidr)144class VPNaaSTest():145 def __init__(self):146 pass147 def verify_dummy_router(self, obj, dummyrouter, dummyroutertag):148 """ Verifies Dummy Router on VSD """149 LOG.info("Verifying the dummy router")150 # Getting externalID for dummy router151 l3domain_ext_id = test_base.get_external_id(dummyrouter['id'])152 vsd_l3dom = obj.TB.vsd_1.get_domain(153 filter=test_base.get_filter_str('externalID', l3domain_ext_id)154 )155 # Adding vsd info to os_data_struct156 obj.os_data_struct.update_resource(dummyroutertag, \157 vsd_data=vsd_l3dom)158 def verify_dummy_subnet(self, obj, dummysubnet, dummysubnettag, cidr):159 """ Verifies Dummy Subnet on VSD """160 LOG.info("Verifying the dummy subnet")161 # Getting externalID for dummy subnet162 subnet_ext_id = test_base.get_external_id(dummysubnet['id'])163 vsd_subnet = obj.TB.vsd_1.get_subnet(164 filter=test_base.get_filter_str('externalID', subnet_ext_id)165 )166 # Adding vsd info to os_data_struct167 obj.os_data_struct.update_resource(dummysubnettag, \168 vsd_data=vsd_subnet)169 obj.assertEqual(dummysubnet['cidr'].split("/")[0], \170 vsd_subnet.address)171 obj.assertEqual(cidr, vsd_subnet.address)172 class _ipsecsiteconnection_create_delete():173 def __init__(self):174 self.vpnaas_test = VPNaaSTest()175 pass176 def verify_ipsec_vminterface(self, obj):177 """ Verifies VM interface for ipsecsiteconnection """178 # Getting subnet for dummy subnet 179 vsd_subnet = (180 obj.os_data_struct.get_resource('dummysubnet').vsd_data181 )182 # Getting vm interface in dummy subnet183 vpnservice_ip = (184 vsd_subnet.vm_interfaces.fetch()[0][0].ip_address185 )186 vpnservice = (187 obj.os_data_struct.get_resource('vpnservice').os_data188 )189 # Comparing vpnservice ip with dummy vminterface ip190 os_vpnservice_ip = vpnservice['external_v4_ip']191 obj.assertEqual(vpnservice_ip, os_vpnservice_ip)192 def verify_vpn_dummy_router(self, obj):193 """ Verifies Dummy Router/Subnet for vpnservice """194 # verify dummy router195 os_dummyrouter = (196 obj.os_data_struct.get_resource('dummyrouter').os_data197 )198 self.vpnaas_test.verify_dummy_router(\199 obj, os_dummyrouter, 'dummyrouter')200 # verify dummy subnet201 os_dummysubnet = (202 obj.os_data_struct.get_resource('dummysubnet').os_data203 )204 pubsub_id = (205 obj.os_data_struct.get_resource('router1').\206 os_data['external_gateway_info']\207 ['external_fixed_ips'][0]['subnet_id']208 )209 pubsubextid = test_base.get_external_id(pubsub_id)210 # Comparing the dummy subnet cidr with public subnet cidr211 vsd_pubsubnet = obj.TB.vsd_1.get_subnet(212 filter = \213 test_base.get_filter_str('externalID', pubsubextid)214 )215 self.vpnaas_test.verify_dummy_subnet(\216 obj, os_dummysubnet, 'dummysubnet', vsd_pubsubnet.address)217 class _vpnservice_create_delete():218 def __init__(self):219 self.vpnaas_test = VPNaaSTest()220 pass221 def verify_vpn_dummy_router(self, obj):222 """ Verifies Dummy Router/Subnet for vpnservice """223 # verify dummy router224 os_dummyrouter = (225 obj.os_data_struct.get_resource('dummyrouter').os_data226 )227 self.vpnaas_test.verify_dummy_router(\228 obj, os_dummyrouter, 'dummyrouter')229 # verify dummy subnet230 os_dummysubnet = (231 obj.os_data_struct.get_resource('dummysubnet').os_data232 )233 pubsub_id = (234 obj.os_data_struct.get_resource('router1').\235 os_data['external_gateway_info']\236 ['external_fixed_ips'][0]['subnet_id']237 )238 pubsubextid = test_base.get_external_id(pubsub_id)239 # Comparing the dummy subnet cidr with public subnet cidr240 vsd_pubsubnet = obj.TB.vsd_1.get_subnet(241 filter = \242 test_base.get_filter_str('externalID', pubsubextid)243 )244 self.vpnaas_test.verify_dummy_subnet(\...

Full Screen

Full Screen

mines.py

Source:mines.py Github

copy

Full Screen

...12 npcs=[get_npc('life_operator')],13)14DWARVEN_VILLAGE = Zone(15 'dwarven_village', 20, -140,16 resources=[get_resource('stone'), get_resource('coal_ore'),17 get_resource('iron_ore'), get_resource('gold_ore'),18 get_resource('lapis_ore'), get_resource('redstone_ore'),19 get_resource('emerald_ore'), get_resource('diamond_ore')],20 npcs=[get_npc('bubu'),21 get_npc('bulvar'),22 get_npc('gimley'),23 get_npc('hornum'),24 get_npc('sargwyn'),25 get_npc('tarwen')],26)27FAR = Zone(28 'far', -120, 70,29 resources=[get_resource('stone'), get_resource('gray_mithril'),30 get_resource('dark_mithril'), get_resource('light_mithril')],31)32FORGE = Zone(33 'forge', 0, -70,34 resources=[get_resource('stone'), get_resource('coal_ore'),35 get_resource('iron_ore'), get_resource('gold_ore'),36 get_resource('lapis_ore'), get_resource('redstone_ore'),37 get_resource('emerald_ore'), get_resource('diamond_ore')],38 npcs=[get_npc('jotraeline_greatforge')],39)40GOBLINS = Zone(41 'goblins', -110, 110,42 resources=[get_resource('stone')],43 mobs=[get_mob('goblin')],44)45ICE_WALLS = Zone(46 'ice_walls', 0, 100,47 resources=[get_resource('stone'), get_resource('gray_mithril'),48 get_resource('dark_mithril'), get_resource('light_mithril'),49 get_resource('gold_block')],50 mobs=[get_mob('ice_walker')],51)52MIST = Zone(53 'mist', 0, 40,54 mobs=[get_mob('ghost')],55)56PALACE = Zone(57 'palace', 120, 120,58 resources=[get_resource('stone')],59 npcs=[get_npc('brammor'), get_npc('emkam'), get_npc('emmor'),60 get_npc('erren'), get_npc('grandan'), get_npc('redos'),61 get_npc('thormyr')],62)63RAMPARTS = Zone(64 'ramparts', -25, -50,65 resources=[get_resource('stone'), get_resource('gray_mithril'),66 get_resource('dark_mithril'), get_resource('light_mithril')],67)68ROYAL = Zone(69 'royal', 140, 35,70 resources=[get_resource('stone'), get_resource('gray_mithril'),71 get_resource('dark_mithril'), get_resource('light_mithril'),72 get_resource('gold_block')],73)74SPRINGS = Zone(75 'springs', 60, -70,76 resources=[get_resource('stone'), get_resource('gray_mithril'),77 get_resource('dark_mithril'), get_resource('light_mithril')],78)79VEINS = Zone(80 'veins', 20, 0,81 resources=[get_resource('stone'), get_resource('gray_mithril'),82 get_resource('dark_mithril'), get_resource('light_mithril')],83)84UPPER = Zone(85 'upper', -125, -50, fishable=True,86 resources=[get_resource('stone'), get_resource('gray_mithril'),87 get_resource('dark_mithril'), get_resource('light_mithril')],88)8990MINES_JOINTS = [91 DWARVEN_ENTRENCE, DWARVEN_VILLAGE, FAR, FORGE, GOBLINS, ICE_WALLS, MIST,92 PALACE, RAMPARTS, ROYAL, SPRINGS, VEINS, UPPER,93]94MINES_CONNS = [95 (DWARVEN_ENTRENCE, DWARVEN_VILLAGE),96 (DWARVEN_VILLAGE, RAMPARTS),97 (DWARVEN_VILLAGE, ROYAL),98 (DWARVEN_VILLAGE, SPRINGS),99 (FAR, GOBLINS),100 (FAR, RAMPARTS),101 (FAR, UPPER), ...

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