How to use _factory method in localstack

Best Python code snippet using localstack_python

Factories.py

Source:Factories.py Github

copy

Full Screen

...4#5# Path to the _RunWrapper factories6_PATH = "isceobj.TopsProc."7## A factory to make _RunWrapper factories8def _factory(name, other_name=None):9 """create_run_wrapper = _factory(name)10 name is the module and class function name11 """12 other_name = other_name or name13 module = __import__(14 _PATH+name, fromlist=[""]15 )16 cls = getattr(module, other_name)17 def creater(other, *args, **kwargs):18 """_RunWrapper for object calling %s"""19 return _RunWrapper(other, cls)20 return creater21## Put in "_" to prevernt import on "from Factorties import *"22class _RunWrapper(object):23 """_RunWrapper(other, func)(*args, **kwargs)24 executes:25 func(other, *args, **kwargs)26 (like a method)27 """28 def __init__(self, other, func):29 self.method = func30 self.other = other31 return None32 def __call__(self, *args, **kwargs):33 return self.method(self.other, *args, **kwargs)34 pass35def createUnwrapper(other, do_unwrap = None, unwrapperName = None,36 unwrap = None):37 if not do_unwrap and not unwrap:38 #if not defined create an empty method that does nothing39 def runUnwrap(self):40 return None41 elif unwrapperName.lower() == 'snaphu':42 from .runUnwrapSnaphu import runUnwrap43 elif unwrapperName.lower() == 'snaphu_mcf':44 from .runUnwrapSnaphu import runUnwrapMcf as runUnwrap45 elif unwrapperName.lower() == 'icu':46 from .runUnwrapIcu import runUnwrap47 elif unwrapperName.lower() == 'grass':48 from .runUnwrapGrass import runUnwrap49 return _RunWrapper(other, runUnwrap)50def createUnwrap2Stage(other, do_unwrap_2stage = None, unwrapperName = None):51 if (not do_unwrap_2stage) or (unwrapperName.lower() == 'icu') or (unwrapperName.lower() == 'grass'):52 #if not defined create an empty method that does nothing53 def runUnwrap2Stage(*arg, **kwargs):54 return None55 else:56 try:57 import pulp58 from .runUnwrap2Stage import runUnwrap2Stage59 except ImportError:60 raise Exception('Please install PuLP Linear Programming API to run 2stage unwrap')61 return _RunWrapper(other, runUnwrap2Stage)62createPreprocessor = _factory("runPreprocessor")63createComputeBaseline = _factory("runComputeBaseline")64createVerifyDEM = _factory("runVerifyDEM")65createTopo = _factory("runTopo")66createSubsetOverlaps = _factory("runSubsetOverlaps")67createCoarseOffsets = _factory("runCoarseOffsets")68createCoarseResamp = _factory("runCoarseResamp")69createOverlapIfg = _factory("runOverlapIfg")70createPrepESD = _factory("runPrepESD")71createESD = _factory("runESD")72createRangeCoreg = _factory("runRangeCoreg")73createFineOffsets = _factory("runFineOffsets")74createFineResamp = _factory("runFineResamp")75createBurstIfg = _factory("runBurstIfg")76createMergeBursts = _factory("runMergeBursts")77createFilter = _factory("runFilter")78createGeocode = _factory("runGeocode")79#createMaskImages = _factory("runMaskImages")80#createCreateWbdMask = _factory("runCreateWbdMask")81###topsOffsetApp factories82createMergeSLCs = _factory("runMergeSLCs")83createDenseOffsets = _factory("runDenseOffsets")84createOffsetFilter = _factory("runOffsetFilter")85createOffsetGeocode = _factory("runOffsetGeocode")...

Full Screen

Full Screen

test_02_foreign_keys.py

Source:test_02_foreign_keys.py Github

copy

Full Screen

1from .utils import RandomEntityFactory, db2_factory = RandomEntityFactory()3def test_books_stores():4 book = _factory.new_book()5 store = _factory.new_store()6 book_store_link = _factory.new_book_store_link()7 book_store_link.store = store8 book_store_link.book = book9 db.session.add(book_store_link)10 db.session.commit()11def test_books_genres():12 book = _factory.new_book()13 genre = _factory.new_genre()14 book.genres.append(genre)15 db.session.add(book)16 db.session.commit()17def test_books_authors():18 book = _factory.new_book()19 author = _factory.new_author()20 book.authors.append(author)21 db.session.add(author)22 db.session.commit()23def test_books_awards():24 book = _factory.new_book()25 award = _factory.new_award()26 book_award_link = _factory.new_book_award_link()27 book_award_link.book = book28 book_award_link.award = award29 db.session.add(book_award_link)30 db.session.commit()31def test_books_tags():32 book = _factory.new_book()33 tag = _factory.new_tag()34 book.tags.append(tag)35 db.session.add(book)36 db.session.commit()37def test_books_translators():38 book = _factory.new_book()39 translator = _factory.new_translator()40 book.translators.append(translator)41 db.session.add(book)42 db.session.commit()43def test_books_series():44 book = _factory.new_book()45 series = _factory.new_series()46 book.series.append(series)47 db.session.add(book)48 db.session.commit()49def test_users_wishlist():50 book = _factory.new_book()51 user = _factory.new_user()52 user.wishlist.append(book)53 db.session.add(user)54 db.session.commit()55def test_users_favorites():56 book = _factory.new_book()57 user = _factory.new_user()58 user.favorites.append(book)59 db.session.add(user)60 db.session.commit()61def test_users_ratings():62 book = _factory.new_book()63 user = _factory.new_user()64 rating = _factory.new_rating()65 rating.book = book66 rating.user = user67 db.session.add(rating)68 db.session.commit()69def test_users_reviews():70 book = _factory.new_book()71 user = _factory.new_user()72 review = _factory.new_review()73 review.book = book74 review.user = user75 db.session.add(review)76 db.session.commit()77def tests_users_redactor_choice():78 book = _factory.new_book()79 user = _factory.new_user()80 redactor_choice = _factory.new_redactor_choice()81 redactor_choice.book = book82 redactor_choice.user = user83 db.session.add(redactor_choice)...

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