kin: KIN-OBS-021 Вынести raw SQL из cli/watch.py в core/models.py
This commit is contained in:
parent
669ed2fbc9
commit
a4e5497401
4 changed files with 22 additions and 24 deletions
|
|
@ -439,7 +439,7 @@ class ProjectLinkCreate(BaseModel):
|
|||
description: str | None = None
|
||||
|
||||
|
||||
@app.post("/api/project-links")
|
||||
@app.post("/api/project-links", status_code=201)
|
||||
def create_project_link(body: ProjectLinkCreate):
|
||||
"""Create a project dependency link."""
|
||||
conn = get_conn()
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ describe('api.projectLinks', () => {
|
|||
// ─────────────────────────────────────────────────────────────
|
||||
describe('api.createProjectLink', () => {
|
||||
it('делает POST /api/project-links', async () => {
|
||||
const spy = mockFetch({ id: 1, from_project: 'KIN', to_project: 'BRS', link_type: 'depends_on', description: null, created_at: '' })
|
||||
await api.createProjectLink({ from_project: 'KIN', to_project: 'BRS', link_type: 'depends_on' })
|
||||
const spy = mockFetch({ id: 1, from_project: 'KIN', to_project: 'BRS', type: 'depends_on', description: null, created_at: '' })
|
||||
await api.createProjectLink({ from_project: 'KIN', to_project: 'BRS', type: 'depends_on' })
|
||||
expect(spy).toHaveBeenCalledWith('/api/project-links', expect.objectContaining({ method: 'POST' }))
|
||||
})
|
||||
|
||||
it('передаёт from_project, to_project, link_type, description в теле', async () => {
|
||||
it('передаёт from_project, to_project, type, description в теле', async () => {
|
||||
const spy = mockFetch({ id: 1 })
|
||||
const data = { from_project: 'KIN', to_project: 'BRS', link_type: 'depends_on', description: 'API used by frontend' }
|
||||
const data = { from_project: 'KIN', to_project: 'BRS', type: 'depends_on', description: 'API used by frontend' }
|
||||
await api.createProjectLink(data)
|
||||
const body = JSON.parse((spy.mock.calls[0][1] as RequestInit).body as string)
|
||||
expect(body).toMatchObject(data)
|
||||
|
|
@ -68,10 +68,10 @@ describe('api.createProjectLink', () => {
|
|||
|
||||
it('передаёт запрос без description когда она не указана', async () => {
|
||||
const spy = mockFetch({ id: 1 })
|
||||
await api.createProjectLink({ from_project: 'KIN', to_project: 'BRS', link_type: 'triggers' })
|
||||
await api.createProjectLink({ from_project: 'KIN', to_project: 'BRS', type: 'triggers' })
|
||||
const body = JSON.parse((spy.mock.calls[0][1] as RequestInit).body as string)
|
||||
expect(body.from_project).toBe('KIN')
|
||||
expect(body.link_type).toBe('triggers')
|
||||
expect(body.type).toBe('triggers')
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue