小编Dam*_*oya的帖子

如何在 Django 中为石墨烯 graphql 编写测试

请任何人都可以帮助使用 django 测试石墨烯和 graphql

我尝试使用内置的 django 测试,但没有看到我使用的文件我使用了 pytest 但它在导入我的架构时抱怨 ModuleNotFoundError 我希望有人向我展示高级 python 的课程

class Query(ObjectType):
    calculate_price = Float(margin=Float(), exchangeRate=String(
    ), saleType=Argument(SaleType, required=True))

    def resolve_calculate_price(self, info, **kwargs):
        margin = kwargs.get('margin')
        exchangeRate = kwargs.get('exchangeRate')
        saleType = kwargs.get('saleType')

        request_from_coindesk = requests.get(
            url='https://api.coindesk.com/v1/bpi/currentprice.json')
        json_result_from_coindesk = json.dumps(request_from_coindesk.text)
        coindesk_result = json.loads(json_result_from_coindesk)
        result = json.loads(coindesk_result)

        rate_to_calculate = result["bpi"]["USD"]["rate_float"]

        if saleType == SaleType.sell:
            calculated_value = (margin/100) * rate_to_calculate
            new_rate = (rate_to_calculate - calculated_value) * 360
            print(18, new_rate)
            return new_rate
        elif saleType == SaleType.buy:
            calculated_value = (margin/100) * rate_to_calculate …
Run Code Online (Sandbox Code Playgroud)

python django graphql

1
推荐指数
1
解决办法
2179
查看次数

标签 统计

django ×1

graphql ×1

python ×1