bugfix
This commit is contained in:
parent
95dc5fd1f8
commit
d75c8ab82f
21
test/test_prodpricing.py
Normal file
21
test/test_prodpricing.py
Normal file
@ -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)
|
||||||
|
|
23
test/testenv.py
Normal file
23
test/testenv.py
Normal file
@ -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))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user