diff --git a/test/test_prodpricing.py b/test/test_prodpricing.py new file mode 100644 index 0000000..77f3b6f --- /dev/null +++ b/test/test_prodpricing.py @@ -0,0 +1,21 @@ +from testenv import runtest +from platformbiz.pricing import calc_prod_price + +async def test(sor): + prodid = 'a--akNeu1Ia-NOZAJAadf' + spec_config = [ + { + "spec_name":"input_tokens", + "count":12832 + }, + { + "spec_name":"output_tokens", + "count":786323 + } + ] + price = calc_prod_price(sor, prodid, spec_config) + print(f'{prodid=}, {spec_config=}, {price=}') + +if __name__ == '__main__': + runtest(test) + diff --git a/test/testenv.py b/test/testenv.py new file mode 100644 index 0000000..b26e370 --- /dev/null +++ b/test/testenv.py @@ -0,0 +1,23 @@ +import os +import asyncio +from appPublic.jsonConfig import getConfig +from sqlor.dbpools import DBPools +from appbase.init import load_appbase +from accounting.init import load_accounting +from platformbiz.init import load_platformbiz + +async def main(asyncfunc): + home = os.environ['HOME'] + p = f'{home}/py/sage' + config = getCofig(p, {'workdir':p}) + db = DBPools(config.databases) + load_appbase() + load_accounting() + load_platformbiz() + async with db.sqlorContext('sage') as sor: + await asyncfunc(sor) + +def runtest(asyncfunc): + asyncio.new_event_loop().run_until_complete(main(asyncfunc)) + +