news 2026/9/16 11:14:05

YourIntegration

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
YourIntegration

YourIntegration

【免费下载链接】recipesApplication for managing recipes, planning meals, building shopping lists and much much more!项目地址: https://gitcode.com/GitHub_Trending/re/recipes

a little blurb about how it works or anything users should know about how the data needs to be formatted.

同时建议把新集成补充到文档顶部的集成能力总表(`| Integration | Import | Export | Images |` 四列表格)中,如实标记导入/导出/图片支持状态;也可以等集成充分测试后再更新表格。 ## 步骤五:注册 Vue 前端 在 [vue3/src/utils/integration_utils.ts](https://link.gitcode.com/i/8c4c7cb372665b288c2cba544ec6920f) 中找到 `export const INTEGRATIONS: Array<Integration>`,在长列表中新增一行: ```ts {id: 'YOURINTEGRATION', name: "Your Integration", import: true, export: false, helpUrl: 'https://docs.tandoor.dev/features/import_export/#yourintegration'},

其中:

  • id必须与 forms.py 中的全大写类型常量一致;
  • import/export为布尔值,true表示该集成会出现在导入(或导出)菜单中,按你的集成实际支持能力填写;
  • helpUrl指向文档锚点(形如.../import_export/#yourintegration),对应步骤四中创建的章节。

仓库现有条目(如CHEFTAPCOOKLANGPESTLE)可作参照。修改之后需要用yarn重新构建前端,确保生成的 HTML 文件同步更新。

为集成编写测试

Tandoor 使用 Pytest 进行测试。测试文件放在cookbook/tests/other/目录下,新建test_yourintegration.py即可——文件名必须以test_开头,这是 pytest 发现测试的约定。用于解析的样例数据文件则放在 cookbook/tests/other/test_data/ 下,建议建立你自己的子目录(如your_integration/);在测试中引用样例文件时,路径要从cookbook/起写全(仓库现有的 Cooklang 样例位于cookbook/tests/other/test_data/Cooklang/,测试中即以cookbook/tests/other/test_data/Cooklang/xxx.cook形式引用,见 cookbook/tests/other/test_cooklang_integration.py)。

生成带 request 的集成对象

集成类是Integration的子类,构造时必须传入requestexport_type两个参数。export_type只要是一个字符串即可(官方示例惯例使用"export"),而request需要借助 Django 的RequestFactory与项目自带的u1_s1fixture 构造。官方给出的测试模板如下:

from io import BytesIO from django.contrib import auth from django.test import RequestFactory from django_scopes import scope from cookbook.integration.cooklang import YourIntegrationClass def test_yourintegration(u1_s1): user = auth.get_user(u1_s1) space = user.userspace_set.first().space request = RequestFactory() request.user = user request.space = space with scope(space=space): integration_object = YourIntegrationClass(request, "export") with open("cookbook/tests/other/test_data/your_integration/recipe_file.txt", "rb") as file: recipe_bytes = file.read() recipe_name = file.name buffer = BytesIO(recipe_bytes) buffer.name = recipe_name recipe_object = integration_object.get_recipe_from_file(buffer) # all of your test function logic inside this with clause

说明:

  • u1_s1是项目预置的 pytest fixture,作为测试函数参数传入后,可用auth.get_user(u1_s1)取出测试用户,再通过user.userspace_set.first().space拿到测试空间;
  • RequestFactory()构造出的 request 需要手动挂上userspace属性,这正是Integration.__init__和导入逻辑所依赖的;
  • 整个逻辑必须包裹在with scope(space=space):中,因为项目使用django-scopes做空间级数据隔离,模型操作离开该作用域会抛错。

测试函数名同样必须以test_开头才会被执行——这也是在测试文件里定义辅助函数时的关键约定(非test_前缀的函数不会被当作测试运行)。拿到recipe_object后,即可针对它的namestepskeywords、各步骤的ingredients等断言解析结果。

真实测试样例

仓库的 cookbook/tests/other/test_cooklang_integration.py 是这套测试范式的完整实践:它先定义一个request_generator(u1_s1)辅助函数复用 request 构造逻辑,再在test_cooklang_integration中读取.cook样例、调用get_recipe_from_file,随后逐项断言元数据(namedescriptionservingskeywordsworking_time等)、每个步骤的指令文本以及每个步骤关联的配料三元组(food, amount, unit)

space, request = request_generator(u1_s1) with scope(space=space): cooklang_integration = Cooklang(request, "export") with open("cookbook/tests/other/test_data/Cooklang/Butter Swirl Shortbread Cookies.cook", "rb") as file: recipe_bytes = file.read() recipe_name = file.name buffer = BytesIO(recipe_bytes) buffer.name = recipe_name recipe = cooklang_integration.get_recipe_from_file(buffer) # 断言元数据、步骤文本、步骤配料 ...

【免费下载链接】recipesApplication for managing recipes, planning meals, building shopping lists and much much more!项目地址: https://gitcode.com/GitHub_Trending/re/recipes

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/16 11:13:06

大众点评小程序mtgsig1.2签名机制解析与应用

1. 大众点评小程序mtgsig1.2技术解析大众点评作为国内领先的生活服务平台&#xff0c;其小程序采用了mtgsig1.2签名机制来保障接口通信安全。这个签名算法主要用于验证请求的合法性和防止未经授权的访问。在实际开发中&#xff0c;理解这个签名机制对于进行合法合规的接口调试和…

作者头像 李华
网站建设 2026/9/16 11:12:30

前端热搜深度解读:面试、部署、性能与AI工具链

今天早上打开热搜榜&#xff0c;前端相关词又占了一整排。2026前端面试题、前端八股文、内存泄漏怎么排查、Docker部署前端、微前端、前端AI……这些关键词单拎出来都眼熟&#xff0c;放在同一天里同时出现&#xff0c;其实就是当下前端开发者的真实生存图鉴&#xff1a;一部分…

作者头像 李华
网站建设 2026/9/16 11:12:00

功率三极管为何仍是工业可靠性的基石

1. 为什么今天还要聊功率三极管&#xff1f;——一个被低估的“老将”正在 quietly 承担着90%的工业底盘任务你打开任何一本电子技术入门教材&#xff0c;MOSFET那几页永远闪闪发亮&#xff1a;开关速度快、驱动简单、导通电阻低、热稳定性好……配上一张高频DC-DC变换器的漂亮…

作者头像 李华
网站建设 2026/9/16 11:10:46

侧信道攻击防御技术:从原理到工程实践

1. 侧信道攻击防御技术概述在加密系统安全领域&#xff0c;侧信道攻击&#xff08;Side-channel Attack&#xff09;已经成为传统密码分析的致命补充。与直接破解算法不同&#xff0c;这类攻击通过采集加密设备运行时的物理特征——如执行时间、功耗波动、电磁辐射甚至声音信号…

作者头像 李华