test_pagure_flask_api_fork_update.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2019 - Copyright Red Hat Inc
  4. Authors:
  5. Pierre-Yves Chibon <pingou@pingoured.fr>
  6. """
  7. from __future__ import unicode_literals, absolute_import
  8. import arrow
  9. import copy
  10. import datetime
  11. import unittest
  12. import shutil
  13. import sys
  14. import time
  15. import os
  16. import flask
  17. import json
  18. import munch
  19. from mock import patch, MagicMock
  20. from sqlalchemy.exc import SQLAlchemyError
  21. sys.path.insert(
  22. 0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
  23. )
  24. import pagure.lib.query
  25. import tests
  26. class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest):
  27. """ Tests for the flask API of pagure for updating a PR """
  28. maxDiff = None
  29. @patch("pagure.lib.git.update_git", MagicMock(return_value=True))
  30. @patch("pagure.lib.notify.send_email", MagicMock(return_value=True))
  31. def setUp(self):
  32. """ Set up the environnment, ran before every tests. """
  33. super(PagureFlaskApiForkUpdatetests, self).setUp()
  34. tests.create_projects(self.session)
  35. tests.add_content_git_repo(
  36. os.path.join(self.path, "repos", "test.git")
  37. )
  38. # Fork
  39. project = pagure.lib.query.get_authorized_project(self.session, "test")
  40. task = pagure.lib.query.fork_project(
  41. session=self.session, user="pingou", repo=project
  42. )
  43. self.session.commit()
  44. self.assertEqual(
  45. task.get(),
  46. {
  47. "endpoint": "ui_ns.view_repo",
  48. "repo": "test",
  49. "namespace": None,
  50. "username": "pingou",
  51. },
  52. )
  53. tests.add_readme_git_repo(
  54. os.path.join(self.path, "repos", "forks", "pingou", "test.git")
  55. )
  56. project = pagure.lib.query.get_authorized_project(self.session, "test")
  57. fork = pagure.lib.query.get_authorized_project(
  58. self.session, "test", user="pingou"
  59. )
  60. tests.create_tokens(self.session)
  61. tests.create_tokens_acl(self.session)
  62. req = pagure.lib.query.new_pull_request(
  63. session=self.session,
  64. repo_from=fork,
  65. branch_from="master",
  66. repo_to=project,
  67. branch_to="master",
  68. title="test pull-request",
  69. user="pingou",
  70. )
  71. self.session.commit()
  72. self.assertEqual(req.id, 1)
  73. self.assertEqual(req.title, "test pull-request")
  74. # Assert the PR is open
  75. self.session = pagure.lib.query.create_session(self.dbpath)
  76. project = pagure.lib.query.get_authorized_project(self.session, "test")
  77. self.assertEqual(len(project.requests), 1)
  78. self.assertEqual(project.requests[0].status, "Open")
  79. # Check how the PR renders in the API and the UI
  80. output = self.app.get("/api/0/test/pull-request/1")
  81. self.assertEqual(output.status_code, 200)
  82. output = self.app.get("/test/pull-request/1")
  83. self.assertEqual(output.status_code, 200)
  84. def test_api_pull_request_update_invalid_project_namespace(self):
  85. """ Test api_pull_request_update method when the project doesn't exist.
  86. """
  87. headers = {"Authorization": "token aaabbbcccddd"}
  88. # Valid token, wrong project
  89. output = self.app.post(
  90. "/api/0/somenamespace/test3/pull-request/1", headers=headers
  91. )
  92. self.assertEqual(output.status_code, 401)
  93. data = json.loads(output.get_data(as_text=True))
  94. self.assertDictEqual(
  95. data,
  96. {
  97. "error": "Invalid or expired token. Please visit "
  98. "http://localhost.localdomain/settings#nav-api-tab to get or renew your "
  99. "API token.",
  100. "error_code": "EINVALIDTOK",
  101. },
  102. )
  103. def test_api_pull_request_update_invalid_project(self):
  104. """ Test api_pull_request_update method when the project doesn't exist.
  105. """
  106. headers = {"Authorization": "token aaabbbcccddd"}
  107. # Invalid project
  108. output = self.app.post("/api/0/foo/pull-request/1", headers=headers)
  109. self.assertEqual(output.status_code, 404)
  110. data = json.loads(output.get_data(as_text=True))
  111. self.assertDictEqual(
  112. data, {"error": "Project not found", "error_code": "ENOPROJECT"}
  113. )
  114. def test_api_pull_request_update_invalid_project_token(self):
  115. """ Test api_pull_request_update method when the token doesn't correspond
  116. to the project.
  117. """
  118. headers = {"Authorization": "token aaabbbcccddd"}
  119. # Valid token, wrong project
  120. output = self.app.post("/api/0/test2/pull-request/1", headers=headers)
  121. self.assertEqual(output.status_code, 401)
  122. data = json.loads(output.get_data(as_text=True))
  123. self.assertEqual(sorted(data.keys()), ["error", "error_code"])
  124. self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"])
  125. self.assertEqual(
  126. pagure.api.APIERROR.EINVALIDTOK.name, data["error_code"]
  127. )
  128. def test_api_pull_request_update_invalid_pr(self):
  129. """ Test api_assign_pull_request method when asking for an invalid PR
  130. """
  131. headers = {"Authorization": "token aaabbbcccddd"}
  132. # Invalid PR id
  133. output = self.app.post("/api/0/test/pull-request/404", headers=headers)
  134. self.assertEqual(output.status_code, 404)
  135. data = json.loads(output.get_data(as_text=True))
  136. self.assertDictEqual(
  137. data, {"error": "Pull-Request not found", "error_code": "ENOREQ"}
  138. )
  139. def test_api_pull_request_update_no_input(self):
  140. """ Test api_assign_pull_request method when no input is specified
  141. """
  142. headers = {"Authorization": "token aaabbbcccddd"}
  143. # No input
  144. output = self.app.post("/api/0/test/pull-request/1", headers=headers)
  145. self.assertEqual(output.status_code, 400)
  146. data = json.loads(output.get_data(as_text=True))
  147. self.assertDictEqual(
  148. data,
  149. {
  150. "error": "Invalid or incomplete input submitted",
  151. "error_code": "EINVALIDREQ",
  152. "errors": {"title": ["This field is required."]},
  153. },
  154. )
  155. def test_api_pull_request_update_insufficient_input(self):
  156. """ Test api_assign_pull_request method when no input is specified
  157. """
  158. headers = {"Authorization": "token aaabbbcccddd"}
  159. data = {"initial_comment": "will not work"}
  160. # Missing the required title field
  161. output = self.app.post(
  162. "/api/0/test/pull-request/1", data=data, headers=headers
  163. )
  164. self.assertEqual(output.status_code, 400)
  165. data = json.loads(output.get_data(as_text=True))
  166. self.assertDictEqual(
  167. data,
  168. {
  169. "error": "Invalid or incomplete input submitted",
  170. "error_code": "EINVALIDREQ",
  171. "errors": {"title": ["This field is required."]},
  172. },
  173. )
  174. def test_api_pull_request_update_edited(self):
  175. """ Test api_assign_pull_request method when with valid input
  176. """
  177. headers = {"Authorization": "token aaabbbcccddd"}
  178. data = {
  179. "title": "edited test PR",
  180. "initial_comment": "Edited initial comment",
  181. }
  182. # Valid request
  183. output = self.app.post(
  184. "/api/0/test/pull-request/1", data=data, headers=headers
  185. )
  186. self.assertEqual(output.status_code, 200)
  187. data = json.loads(output.get_data(as_text=True))
  188. # Hard-code all the values that will change from a test to another
  189. # because either random or time-based
  190. data["date_created"] = "1551276260"
  191. data["last_updated"] = "1551276261"
  192. data["updated_on"] = "1551276260"
  193. data["commit_start"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  194. data["commit_stop"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  195. data["project"]["date_created"] = "1551276259"
  196. data["project"]["date_modified"] = "1551276259"
  197. data["repo_from"]["date_created"] = "1551276259"
  198. data["repo_from"]["date_modified"] = "1551276259"
  199. data["repo_from"]["parent"]["date_created"] = "1551276259"
  200. data["repo_from"]["parent"]["date_modified"] = "1551276259"
  201. data["uid"] = "a2bddecc8ea548e88c22a0df77670092"
  202. self.assertDictEqual(
  203. data,
  204. {
  205. "assignee": None,
  206. "branch": "master",
  207. "branch_from": "master",
  208. "cached_merge_status": "unknown",
  209. "closed_at": None,
  210. "closed_by": None,
  211. "comments": [],
  212. "commit_start": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  213. "commit_stop": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  214. "date_created": "1551276260",
  215. "id": 1,
  216. "initial_comment": "Edited initial comment",
  217. "last_updated": "1551276261",
  218. "project": {
  219. "access_groups": {
  220. "admin": [],
  221. "collaborator": [],
  222. "commit": [],
  223. "ticket": [],
  224. },
  225. "access_users": {
  226. "admin": [],
  227. "collaborator": [],
  228. "commit": [],
  229. "owner": ["pingou"],
  230. "ticket": [],
  231. },
  232. "close_status": [
  233. "Invalid",
  234. "Insufficient data",
  235. "Fixed",
  236. "Duplicate",
  237. ],
  238. "custom_keys": [],
  239. "date_created": "1551276259",
  240. "date_modified": "1551276259",
  241. "description": "test project #1",
  242. "fullname": "test",
  243. "id": 1,
  244. "milestones": {},
  245. "name": "test",
  246. "namespace": None,
  247. "parent": None,
  248. "priorities": {},
  249. "tags": [],
  250. "url_path": "test",
  251. "user": {
  252. "fullname": "PY C",
  253. "name": "pingou",
  254. "url_path": "user/pingou",
  255. },
  256. },
  257. "remote_git": None,
  258. "repo_from": {
  259. "access_groups": {
  260. "admin": [],
  261. "collaborator": [],
  262. "commit": [],
  263. "ticket": [],
  264. },
  265. "access_users": {
  266. "admin": [],
  267. "collaborator": [],
  268. "commit": [],
  269. "owner": ["pingou"],
  270. "ticket": [],
  271. },
  272. "close_status": [],
  273. "custom_keys": [],
  274. "date_created": "1551276259",
  275. "date_modified": "1551276259",
  276. "description": "test project #1",
  277. "fullname": "forks/pingou/test",
  278. "id": 4,
  279. "milestones": {},
  280. "name": "test",
  281. "namespace": None,
  282. "parent": {
  283. "access_groups": {
  284. "admin": [],
  285. "collaborator": [],
  286. "commit": [],
  287. "ticket": [],
  288. },
  289. "access_users": {
  290. "admin": [],
  291. "collaborator": [],
  292. "commit": [],
  293. "owner": ["pingou"],
  294. "ticket": [],
  295. },
  296. "close_status": [
  297. "Invalid",
  298. "Insufficient data",
  299. "Fixed",
  300. "Duplicate",
  301. ],
  302. "custom_keys": [],
  303. "date_created": "1551276259",
  304. "date_modified": "1551276259",
  305. "description": "test project #1",
  306. "fullname": "test",
  307. "id": 1,
  308. "milestones": {},
  309. "name": "test",
  310. "namespace": None,
  311. "parent": None,
  312. "priorities": {},
  313. "tags": [],
  314. "url_path": "test",
  315. "user": {
  316. "fullname": "PY C",
  317. "name": "pingou",
  318. "url_path": "user/pingou",
  319. },
  320. },
  321. "priorities": {},
  322. "tags": [],
  323. "url_path": "fork/pingou/test",
  324. "user": {
  325. "fullname": "PY C",
  326. "name": "pingou",
  327. "url_path": "user/pingou",
  328. },
  329. },
  330. "status": "Open",
  331. "tags": [],
  332. "threshold_reached": None,
  333. "title": "edited test PR",
  334. "uid": "a2bddecc8ea548e88c22a0df77670092",
  335. "updated_on": "1551276260",
  336. "user": {
  337. "fullname": "PY C",
  338. "name": "pingou",
  339. "url_path": "user/pingou",
  340. },
  341. },
  342. )
  343. def test_api_pull_request_update_edited_no_comment(self):
  344. """ Test api_assign_pull_request method when with valid input
  345. """
  346. headers = {"Authorization": "token aaabbbcccddd"}
  347. data = {"title": "edited test PR"}
  348. # Valid request
  349. output = self.app.post(
  350. "/api/0/test/pull-request/1", data=data, headers=headers
  351. )
  352. self.assertEqual(output.status_code, 200)
  353. data = json.loads(output.get_data(as_text=True))
  354. # Hard-code all the values that will change from a test to another
  355. # because either random or time-based
  356. data["date_created"] = "1551276260"
  357. data["last_updated"] = "1551276261"
  358. data["updated_on"] = "1551276260"
  359. data["commit_start"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  360. data["commit_stop"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  361. data["project"]["date_created"] = "1551276259"
  362. data["project"]["date_modified"] = "1551276259"
  363. data["repo_from"]["date_created"] = "1551276259"
  364. data["repo_from"]["date_modified"] = "1551276259"
  365. data["repo_from"]["parent"]["date_created"] = "1551276259"
  366. data["repo_from"]["parent"]["date_modified"] = "1551276259"
  367. data["uid"] = "a2bddecc8ea548e88c22a0df77670092"
  368. self.assertDictEqual(
  369. data,
  370. {
  371. "assignee": None,
  372. "branch": "master",
  373. "branch_from": "master",
  374. "cached_merge_status": "unknown",
  375. "closed_at": None,
  376. "closed_by": None,
  377. "comments": [],
  378. "commit_start": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  379. "commit_stop": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  380. "date_created": "1551276260",
  381. "id": 1,
  382. "initial_comment": "",
  383. "last_updated": "1551276261",
  384. "project": {
  385. "access_groups": {
  386. "admin": [],
  387. "collaborator": [],
  388. "commit": [],
  389. "ticket": [],
  390. },
  391. "access_users": {
  392. "admin": [],
  393. "collaborator": [],
  394. "commit": [],
  395. "owner": ["pingou"],
  396. "ticket": [],
  397. },
  398. "close_status": [
  399. "Invalid",
  400. "Insufficient data",
  401. "Fixed",
  402. "Duplicate",
  403. ],
  404. "custom_keys": [],
  405. "date_created": "1551276259",
  406. "date_modified": "1551276259",
  407. "description": "test project #1",
  408. "fullname": "test",
  409. "id": 1,
  410. "milestones": {},
  411. "name": "test",
  412. "namespace": None,
  413. "parent": None,
  414. "priorities": {},
  415. "tags": [],
  416. "url_path": "test",
  417. "user": {
  418. "fullname": "PY C",
  419. "name": "pingou",
  420. "url_path": "user/pingou",
  421. },
  422. },
  423. "remote_git": None,
  424. "repo_from": {
  425. "access_groups": {
  426. "admin": [],
  427. "collaborator": [],
  428. "commit": [],
  429. "ticket": [],
  430. },
  431. "access_users": {
  432. "admin": [],
  433. "collaborator": [],
  434. "commit": [],
  435. "owner": ["pingou"],
  436. "ticket": [],
  437. },
  438. "close_status": [],
  439. "custom_keys": [],
  440. "date_created": "1551276259",
  441. "date_modified": "1551276259",
  442. "description": "test project #1",
  443. "fullname": "forks/pingou/test",
  444. "id": 4,
  445. "milestones": {},
  446. "name": "test",
  447. "namespace": None,
  448. "parent": {
  449. "access_groups": {
  450. "admin": [],
  451. "collaborator": [],
  452. "commit": [],
  453. "ticket": [],
  454. },
  455. "access_users": {
  456. "admin": [],
  457. "collaborator": [],
  458. "commit": [],
  459. "owner": ["pingou"],
  460. "ticket": [],
  461. },
  462. "close_status": [
  463. "Invalid",
  464. "Insufficient data",
  465. "Fixed",
  466. "Duplicate",
  467. ],
  468. "custom_keys": [],
  469. "date_created": "1551276259",
  470. "date_modified": "1551276259",
  471. "description": "test project #1",
  472. "fullname": "test",
  473. "id": 1,
  474. "milestones": {},
  475. "name": "test",
  476. "namespace": None,
  477. "parent": None,
  478. "priorities": {},
  479. "tags": [],
  480. "url_path": "test",
  481. "user": {
  482. "fullname": "PY C",
  483. "name": "pingou",
  484. "url_path": "user/pingou",
  485. },
  486. },
  487. "priorities": {},
  488. "tags": [],
  489. "url_path": "fork/pingou/test",
  490. "user": {
  491. "fullname": "PY C",
  492. "name": "pingou",
  493. "url_path": "user/pingou",
  494. },
  495. },
  496. "status": "Open",
  497. "tags": [],
  498. "threshold_reached": None,
  499. "title": "edited test PR",
  500. "uid": "a2bddecc8ea548e88c22a0df77670092",
  501. "updated_on": "1551276260",
  502. "user": {
  503. "fullname": "PY C",
  504. "name": "pingou",
  505. "url_path": "user/pingou",
  506. },
  507. },
  508. )
  509. def test_api_pull_request_update_edited_linked(self):
  510. """ Test api_assign_pull_request method when with valid input
  511. """
  512. project = pagure.lib.query.get_authorized_project(self.session, "test")
  513. self.assertEqual(len(project.requests), 1)
  514. self.assertEqual(len(project.requests[0].related_issues), 0)
  515. self.assertEqual(len(project.issues), 0)
  516. # Create issues to link to
  517. msg = pagure.lib.query.new_issue(
  518. session=self.session,
  519. repo=project,
  520. title="tést íssüé",
  521. content="We should work on this",
  522. user="pingou",
  523. )
  524. self.session.commit()
  525. self.assertEqual(msg.title, "tést íssüé")
  526. headers = {"Authorization": "token aaabbbcccddd"}
  527. data = {
  528. "title": "edited test PR",
  529. "initial_comment": "Edited initial comment\n\n"
  530. "this PR fixes #2 \n\nThanks",
  531. }
  532. # Valid request
  533. output = self.app.post(
  534. "/api/0/test/pull-request/1", data=data, headers=headers
  535. )
  536. self.assertEqual(output.status_code, 200)
  537. data = json.loads(output.get_data(as_text=True))
  538. # Hard-code all the values that will change from a test to another
  539. # because either random or time-based
  540. data["date_created"] = "1551276260"
  541. data["last_updated"] = "1551276261"
  542. data["updated_on"] = "1551276260"
  543. data["commit_start"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  544. data["commit_stop"] = "5f5d609db65d447f77ba00e25afd17ba5053344b"
  545. data["project"]["date_created"] = "1551276259"
  546. data["project"]["date_modified"] = "1551276259"
  547. data["repo_from"]["date_created"] = "1551276259"
  548. data["repo_from"]["date_modified"] = "1551276259"
  549. data["repo_from"]["parent"]["date_created"] = "1551276259"
  550. data["repo_from"]["parent"]["date_modified"] = "1551276259"
  551. data["uid"] = "a2bddecc8ea548e88c22a0df77670092"
  552. self.assertDictEqual(
  553. data,
  554. {
  555. "assignee": None,
  556. "branch": "master",
  557. "branch_from": "master",
  558. "cached_merge_status": "unknown",
  559. "closed_at": None,
  560. "closed_by": None,
  561. "comments": [],
  562. "commit_start": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  563. "commit_stop": "5f5d609db65d447f77ba00e25afd17ba5053344b",
  564. "date_created": "1551276260",
  565. "id": 1,
  566. "initial_comment": "Edited initial comment\n\nthis PR "
  567. "fixes #2 \n\nThanks",
  568. "last_updated": "1551276261",
  569. "project": {
  570. "access_groups": {
  571. "admin": [],
  572. "collaborator": [],
  573. "commit": [],
  574. "ticket": [],
  575. },
  576. "access_users": {
  577. "admin": [],
  578. "collaborator": [],
  579. "commit": [],
  580. "owner": ["pingou"],
  581. "ticket": [],
  582. },
  583. "close_status": [
  584. "Invalid",
  585. "Insufficient data",
  586. "Fixed",
  587. "Duplicate",
  588. ],
  589. "custom_keys": [],
  590. "date_created": "1551276259",
  591. "date_modified": "1551276259",
  592. "description": "test project #1",
  593. "fullname": "test",
  594. "id": 1,
  595. "milestones": {},
  596. "name": "test",
  597. "namespace": None,
  598. "parent": None,
  599. "priorities": {},
  600. "tags": [],
  601. "url_path": "test",
  602. "user": {
  603. "fullname": "PY C",
  604. "name": "pingou",
  605. "url_path": "user/pingou",
  606. },
  607. },
  608. "remote_git": None,
  609. "repo_from": {
  610. "access_groups": {
  611. "admin": [],
  612. "collaborator": [],
  613. "commit": [],
  614. "ticket": [],
  615. },
  616. "access_users": {
  617. "admin": [],
  618. "collaborator": [],
  619. "commit": [],
  620. "owner": ["pingou"],
  621. "ticket": [],
  622. },
  623. "close_status": [],
  624. "custom_keys": [],
  625. "date_created": "1551276259",
  626. "date_modified": "1551276259",
  627. "description": "test project #1",
  628. "fullname": "forks/pingou/test",
  629. "id": 4,
  630. "milestones": {},
  631. "name": "test",
  632. "namespace": None,
  633. "parent": {
  634. "access_groups": {
  635. "admin": [],
  636. "collaborator": [],
  637. "commit": [],
  638. "ticket": [],
  639. },
  640. "access_users": {
  641. "admin": [],
  642. "collaborator": [],
  643. "commit": [],
  644. "owner": ["pingou"],
  645. "ticket": [],
  646. },
  647. "close_status": [
  648. "Invalid",
  649. "Insufficient data",
  650. "Fixed",
  651. "Duplicate",
  652. ],
  653. "custom_keys": [],
  654. "date_created": "1551276259",
  655. "date_modified": "1551276259",
  656. "description": "test project #1",
  657. "fullname": "test",
  658. "id": 1,
  659. "milestones": {},
  660. "name": "test",
  661. "namespace": None,
  662. "parent": None,
  663. "priorities": {},
  664. "tags": [],
  665. "url_path": "test",
  666. "user": {
  667. "fullname": "PY C",
  668. "name": "pingou",
  669. "url_path": "user/pingou",
  670. },
  671. },
  672. "priorities": {},
  673. "tags": [],
  674. "url_path": "fork/pingou/test",
  675. "user": {
  676. "fullname": "PY C",
  677. "name": "pingou",
  678. "url_path": "user/pingou",
  679. },
  680. },
  681. "status": "Open",
  682. "tags": [],
  683. "threshold_reached": None,
  684. "title": "edited test PR",
  685. "uid": "a2bddecc8ea548e88c22a0df77670092",
  686. "updated_on": "1551276260",
  687. "user": {
  688. "fullname": "PY C",
  689. "name": "pingou",
  690. "url_path": "user/pingou",
  691. },
  692. },
  693. )
  694. project = pagure.lib.query.get_authorized_project(self.session, "test")
  695. self.assertEqual(len(project.requests), 1)
  696. self.assertEqual(len(project.requests[0].related_issues), 1)
  697. self.assertEqual(len(project.issues), 1)
  698. self.assertEqual(len(project.issues[0].related_prs), 1)
  699. if __name__ == "__main__":
  700. unittest.main(verbosity=2)