test_contents.py 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. # -*- coding: utf-8 -*-
  2. from tracim.tests import FunctionalTest
  3. from tracim.tests import set_html_document_slug_to_legacy
  4. from tracim.fixtures.content import Content as ContentFixtures
  5. from tracim.fixtures.users_and_groups import Base as BaseFixture
  6. class TestHtmlDocuments(FunctionalTest):
  7. """
  8. Tests for /api/v2/workspaces/{workspace_id}/html-documents/{content_id}
  9. endpoint
  10. """
  11. fixtures = [BaseFixture, ContentFixtures]
  12. def test_api__get_html_document__ok_200__legacy_slug(self) -> None:
  13. """
  14. Get one html document of a content
  15. """
  16. self.testapp.authorization = (
  17. 'Basic',
  18. (
  19. 'admin@admin.admin',
  20. 'admin@admin.admin'
  21. )
  22. )
  23. set_html_document_slug_to_legacy(self.session_factory)
  24. res = self.testapp.get(
  25. '/api/v2/workspaces/2/html-documents/6',
  26. status=200
  27. )
  28. content = res.json_body
  29. assert content['content_type'] == 'html-documents'
  30. assert content['content_id'] == 6
  31. assert content['is_archived'] is False
  32. assert content['is_deleted'] is False
  33. assert content['label'] == 'Tiramisu Recipe'
  34. assert content['parent_id'] == 3
  35. assert content['show_in_ui'] is True
  36. assert content['slug'] == 'tiramisu-recipe'
  37. assert content['status'] == 'open'
  38. assert content['workspace_id'] == 2
  39. assert content['current_revision_id'] == 27
  40. # TODO - G.M - 2018-06-173 - check date format
  41. assert content['created']
  42. assert content['author']
  43. assert content['author']['user_id'] == 1
  44. assert content['author']['avatar_url'] is None
  45. assert content['author']['public_name'] == 'Global manager'
  46. # TODO - G.M - 2018-06-173 - check date format
  47. assert content['modified']
  48. assert content['last_modifier'] != content['author']
  49. assert content['last_modifier']['user_id'] == 3
  50. assert content['last_modifier']['public_name'] == 'Bob i.'
  51. assert content['last_modifier']['avatar_url'] is None
  52. assert content['raw_content'] == '<p>To cook a great Tiramisu, you need many ingredients.</p>' # nopep8
  53. def test_api__get_html_document__ok_200__nominal_case(self) -> None:
  54. """
  55. Get one html document of a content
  56. """
  57. self.testapp.authorization = (
  58. 'Basic',
  59. (
  60. 'admin@admin.admin',
  61. 'admin@admin.admin'
  62. )
  63. )
  64. res = self.testapp.get(
  65. '/api/v2/workspaces/2/html-documents/6',
  66. status=200
  67. )
  68. content = res.json_body
  69. assert content['content_type'] == 'html-documents'
  70. assert content['content_id'] == 6
  71. assert content['is_archived'] is False
  72. assert content['is_deleted'] is False
  73. assert content['label'] == 'Tiramisu Recipe'
  74. assert content['parent_id'] == 3
  75. assert content['show_in_ui'] is True
  76. assert content['slug'] == 'tiramisu-recipe'
  77. assert content['status'] == 'open'
  78. assert content['workspace_id'] == 2
  79. assert content['current_revision_id'] == 27
  80. # TODO - G.M - 2018-06-173 - check date format
  81. assert content['created']
  82. assert content['author']
  83. assert content['author']['user_id'] == 1
  84. assert content['author']['avatar_url'] is None
  85. assert content['author']['public_name'] == 'Global manager'
  86. # TODO - G.M - 2018-06-173 - check date format
  87. assert content['modified']
  88. assert content['last_modifier'] != content['author']
  89. assert content['last_modifier']['user_id'] == 3
  90. assert content['last_modifier']['public_name'] == 'Bob i.'
  91. assert content['last_modifier']['avatar_url'] is None
  92. assert content['raw_content'] == '<p>To cook a great Tiramisu, you need many ingredients.</p>' # nopep8
  93. def test_api__get_html_document__err_400__wrong_content_type(self) -> None:
  94. """
  95. Get one html document of a content content 7 is not html_document
  96. """
  97. self.testapp.authorization = (
  98. 'Basic',
  99. (
  100. 'admin@admin.admin',
  101. 'admin@admin.admin'
  102. )
  103. )
  104. res = self.testapp.get(
  105. '/api/v2/workspaces/2/html-documents/7',
  106. status=400
  107. )
  108. def test_api__get_html_document__err_400__content_does_not_exist(self) -> None: # nopep8
  109. """
  110. Get one html document of a content (content 170 does not exist in db
  111. """
  112. self.testapp.authorization = (
  113. 'Basic',
  114. (
  115. 'admin@admin.admin',
  116. 'admin@admin.admin'
  117. )
  118. )
  119. res = self.testapp.get(
  120. '/api/v2/workspaces/2/html-documents/170',
  121. status=400
  122. )
  123. def test_api__get_html_document__err_400__content_not_in_workspace(self) -> None: # nopep8
  124. """
  125. Get one html document of a content (content 6 is in workspace 2)
  126. """
  127. self.testapp.authorization = (
  128. 'Basic',
  129. (
  130. 'admin@admin.admin',
  131. 'admin@admin.admin'
  132. )
  133. )
  134. res = self.testapp.get(
  135. '/api/v2/workspaces/1/html-documents/6',
  136. status=400
  137. )
  138. def test_api__get_html_document__err_400__workspace_does_not_exist(self) -> None: # nopep8
  139. """
  140. Get one html document of a content (Workspace 40 does not exist)
  141. """
  142. self.testapp.authorization = (
  143. 'Basic',
  144. (
  145. 'admin@admin.admin',
  146. 'admin@admin.admin'
  147. )
  148. )
  149. res = self.testapp.get(
  150. '/api/v2/workspaces/40/html-documents/6',
  151. status=400
  152. )
  153. def test_api__get_html_document__err_400__workspace_id_is_not_int(self) -> None: # nopep8
  154. """
  155. Get one html document of a content, workspace id is not int
  156. """
  157. self.testapp.authorization = (
  158. 'Basic',
  159. (
  160. 'admin@admin.admin',
  161. 'admin@admin.admin'
  162. )
  163. )
  164. res = self.testapp.get(
  165. '/api/v2/workspaces/coucou/html-documents/6',
  166. status=400
  167. )
  168. def test_api__get_html_document__err_400__content_id_is_not_int(self) -> None: # nopep8
  169. """
  170. Get one html document of a content, content_id is not int
  171. """
  172. self.testapp.authorization = (
  173. 'Basic',
  174. (
  175. 'admin@admin.admin',
  176. 'admin@admin.admin'
  177. )
  178. )
  179. res = self.testapp.get(
  180. '/api/v2/workspaces/2/html-documents/coucou',
  181. status=400
  182. )
  183. def test_api__update_html_document__err_400__empty_label(self) -> None: # nopep8
  184. """
  185. Update(put) one html document of a content
  186. """
  187. self.testapp.authorization = (
  188. 'Basic',
  189. (
  190. 'admin@admin.admin',
  191. 'admin@admin.admin'
  192. )
  193. )
  194. params = {
  195. 'label': '',
  196. 'raw_content': '<p> Le nouveau contenu </p>',
  197. }
  198. res = self.testapp.put_json(
  199. '/api/v2/workspaces/2/html-documents/6',
  200. params=params,
  201. status=400
  202. )
  203. def test_api__update_html_document__ok_200__nominal_case(self) -> None:
  204. """
  205. Update(put) one html document of a content
  206. """
  207. self.testapp.authorization = (
  208. 'Basic',
  209. (
  210. 'admin@admin.admin',
  211. 'admin@admin.admin'
  212. )
  213. )
  214. params = {
  215. 'label': 'My New label',
  216. 'raw_content': '<p> Le nouveau contenu </p>',
  217. }
  218. res = self.testapp.put_json(
  219. '/api/v2/workspaces/2/html-documents/6',
  220. params=params,
  221. status=200
  222. )
  223. content = res.json_body
  224. assert content['content_type'] == 'html-documents'
  225. assert content['content_id'] == 6
  226. assert content['is_archived'] is False
  227. assert content['is_deleted'] is False
  228. assert content['label'] == 'My New label'
  229. assert content['parent_id'] == 3
  230. assert content['show_in_ui'] is True
  231. assert content['slug'] == 'my-new-label'
  232. assert content['status'] == 'open'
  233. assert content['workspace_id'] == 2
  234. assert content['current_revision_id'] == 28
  235. # TODO - G.M - 2018-06-173 - check date format
  236. assert content['created']
  237. assert content['author']
  238. assert content['author']['user_id'] == 1
  239. assert content['author']['avatar_url'] is None
  240. assert content['author']['public_name'] == 'Global manager'
  241. # TODO - G.M - 2018-06-173 - check date format
  242. assert content['modified']
  243. assert content['last_modifier'] == content['author']
  244. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  245. res = self.testapp.get(
  246. '/api/v2/workspaces/2/html-documents/6',
  247. status=200
  248. )
  249. content = res.json_body
  250. assert content['content_type'] == 'html-documents'
  251. assert content['content_id'] == 6
  252. assert content['is_archived'] is False
  253. assert content['is_deleted'] is False
  254. assert content['label'] == 'My New label'
  255. assert content['parent_id'] == 3
  256. assert content['show_in_ui'] is True
  257. assert content['slug'] == 'my-new-label'
  258. assert content['status'] == 'open'
  259. assert content['workspace_id'] == 2
  260. assert content['current_revision_id'] == 28
  261. # TODO - G.M - 2018-06-173 - check date format
  262. assert content['created']
  263. assert content['author']
  264. assert content['author']['user_id'] == 1
  265. assert content['author']['avatar_url'] is None
  266. assert content['author']['public_name'] == 'Global manager'
  267. # TODO - G.M - 2018-06-173 - check date format
  268. assert content['modified']
  269. assert content['last_modifier'] == content['author']
  270. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  271. def test_api__get_html_document_revisions__ok_200__nominal_case(
  272. self
  273. ) -> None:
  274. """
  275. Get one html document of a content
  276. """
  277. self.testapp.authorization = (
  278. 'Basic',
  279. (
  280. 'admin@admin.admin',
  281. 'admin@admin.admin'
  282. )
  283. )
  284. res = self.testapp.get(
  285. '/api/v2/workspaces/2/html-documents/6/revisions',
  286. status=200
  287. )
  288. revisions = res.json_body
  289. assert len(revisions) == 3
  290. revision = revisions[0]
  291. assert revision['content_type'] == 'html-documents'
  292. assert revision['content_id'] == 6
  293. assert revision['is_archived'] is False
  294. assert revision['is_deleted'] is False
  295. assert revision['label'] == 'Tiramisu Recipes!!!'
  296. assert revision['parent_id'] == 3
  297. assert revision['show_in_ui'] is True
  298. assert revision['slug'] == 'tiramisu-recipes'
  299. assert revision['status'] == 'open'
  300. assert revision['workspace_id'] == 2
  301. assert revision['revision_id'] == 6
  302. assert revision['sub_content_types']
  303. # TODO - G.M - 2018-06-173 - Test with real comments
  304. assert revision['comment_ids'] == []
  305. # TODO - G.M - 2018-06-173 - check date format
  306. assert revision['created']
  307. assert revision['author']
  308. assert revision['author']['user_id'] == 1
  309. assert revision['author']['avatar_url'] is None
  310. assert revision['author']['public_name'] == 'Global manager'
  311. revision = revisions[1]
  312. assert revision['content_type'] == 'html-documents'
  313. assert revision['content_id'] == 6
  314. assert revision['is_archived'] is False
  315. assert revision['is_deleted'] is False
  316. assert revision['label'] == 'Tiramisu Recipes!!!'
  317. assert revision['parent_id'] == 3
  318. assert revision['show_in_ui'] is True
  319. assert revision['slug'] == 'tiramisu-recipes'
  320. assert revision['status'] == 'open'
  321. assert revision['workspace_id'] == 2
  322. assert revision['revision_id'] == 7
  323. assert revision['sub_content_types']
  324. # TODO - G.M - 2018-06-173 - Test with real comments
  325. assert revision['comment_ids'] == []
  326. # TODO - G.M - 2018-06-173 - check date format
  327. assert revision['created']
  328. assert revision['author']
  329. assert revision['author']['user_id'] == 1
  330. assert revision['author']['avatar_url'] is None
  331. assert revision['author']['public_name'] == 'Global manager'
  332. revision = revisions[2]
  333. assert revision['content_type'] == 'html-documents'
  334. assert revision['content_id'] == 6
  335. assert revision['is_archived'] is False
  336. assert revision['is_deleted'] is False
  337. assert revision['label'] == 'Tiramisu Recipe'
  338. assert revision['parent_id'] == 3
  339. assert revision['show_in_ui'] is True
  340. assert revision['slug'] == 'tiramisu-recipe'
  341. assert revision['status'] == 'open'
  342. assert revision['workspace_id'] == 2
  343. assert revision['revision_id'] == 27
  344. assert revision['sub_content_types']
  345. # TODO - G.M - 2018-06-173 - Test with real comments
  346. assert revision['comment_ids'] == []
  347. # TODO - G.M - 2018-06-173 - check date format
  348. assert revision['created']
  349. assert revision['author']
  350. assert revision['author']['user_id'] == 3
  351. assert revision['author']['avatar_url'] is None
  352. assert revision['author']['public_name'] == 'Bob i.'
  353. def test_api__set_html_document_status__ok_200__nominal_case(self) -> None:
  354. """
  355. Get one html document of a content
  356. """
  357. self.testapp.authorization = (
  358. 'Basic',
  359. (
  360. 'admin@admin.admin',
  361. 'admin@admin.admin'
  362. )
  363. )
  364. params = {
  365. 'status': 'closed-deprecated',
  366. }
  367. # before
  368. res = self.testapp.get(
  369. '/api/v2/workspaces/2/html-documents/6',
  370. status=200
  371. )
  372. content = res.json_body
  373. assert content['content_type'] == 'html-documents'
  374. assert content['content_id'] == 6
  375. assert content['status'] == 'open'
  376. # set status
  377. res = self.testapp.put_json(
  378. '/api/v2/workspaces/2/html-documents/6/status',
  379. params=params,
  380. status=204
  381. )
  382. # after
  383. res = self.testapp.get(
  384. '/api/v2/workspaces/2/html-documents/6',
  385. status=200
  386. )
  387. content = res.json_body
  388. assert content['content_type'] == 'html-documents'
  389. assert content['content_id'] == 6
  390. assert content['status'] == 'closed-deprecated'
  391. class TestThreads(FunctionalTest):
  392. """
  393. Tests for /api/v2/workspaces/{workspace_id}/threads/{content_id}
  394. endpoint
  395. """
  396. fixtures = [BaseFixture, ContentFixtures]
  397. def test_api__get_thread__err_400__wrong_content_type(self) -> None:
  398. """
  399. Get one html document of a content
  400. """
  401. self.testapp.authorization = (
  402. 'Basic',
  403. (
  404. 'admin@admin.admin',
  405. 'admin@admin.admin'
  406. )
  407. )
  408. res = self.testapp.get(
  409. '/api/v2/workspaces/2/threads/6',
  410. status=400
  411. )
  412. def test_api__get_thread__ok_200__nominal_case(self) -> None:
  413. """
  414. Get one html document of a content
  415. """
  416. self.testapp.authorization = (
  417. 'Basic',
  418. (
  419. 'admin@admin.admin',
  420. 'admin@admin.admin'
  421. )
  422. )
  423. res = self.testapp.get(
  424. '/api/v2/workspaces/2/threads/7',
  425. status=200
  426. ) # nopep8
  427. content = res.json_body
  428. assert content['content_type'] == 'thread'
  429. assert content['content_id'] == 7
  430. assert content['is_archived'] is False
  431. assert content['is_deleted'] is False
  432. assert content['label'] == 'Best Cakes?'
  433. assert content['parent_id'] == 3
  434. assert content['show_in_ui'] is True
  435. assert content['slug'] == 'best-cakes'
  436. assert content['status'] == 'open'
  437. assert content['workspace_id'] == 2
  438. assert content['current_revision_id'] == 26
  439. # TODO - G.M - 2018-06-173 - check date format
  440. assert content['created']
  441. assert content['author']
  442. assert content['author']['user_id'] == 1
  443. assert content['author']['avatar_url'] is None
  444. assert content['author']['public_name'] == 'Global manager'
  445. # TODO - G.M - 2018-06-173 - check date format
  446. assert content['modified']
  447. assert content['last_modifier'] != content['author']
  448. assert content['last_modifier']['user_id'] == 3
  449. assert content['last_modifier']['public_name'] == 'Bob i.'
  450. assert content['last_modifier']['avatar_url'] is None
  451. assert content['raw_content'] == 'What is the best cake?' # nopep8
  452. def test_api__get_thread__err_400__content_does_not_exist(self) -> None:
  453. """
  454. Get one thread (content 170 does not exist)
  455. """
  456. self.testapp.authorization = (
  457. 'Basic',
  458. (
  459. 'admin@admin.admin',
  460. 'admin@admin.admin'
  461. )
  462. )
  463. res = self.testapp.get(
  464. '/api/v2/workspaces/2/threads/170',
  465. status=400
  466. )
  467. def test_api__get_thread__err_400__content_not_in_workspace(self) -> None:
  468. """
  469. Get one thread(content 7 is in workspace 2)
  470. """
  471. self.testapp.authorization = (
  472. 'Basic',
  473. (
  474. 'admin@admin.admin',
  475. 'admin@admin.admin'
  476. )
  477. )
  478. res = self.testapp.get(
  479. '/api/v2/workspaces/1/threads/7',
  480. status=400
  481. )
  482. def test_api__get_thread__err_400__workspace_does_not_exist(self) -> None: # nopep8
  483. """
  484. Get one thread (Workspace 40 does not exist)
  485. """
  486. self.testapp.authorization = (
  487. 'Basic',
  488. (
  489. 'admin@admin.admin',
  490. 'admin@admin.admin'
  491. )
  492. )
  493. res = self.testapp.get(
  494. '/api/v2/workspaces/40/threads/7',
  495. status=400
  496. )
  497. def test_api__get_thread__err_400__workspace_id_is_not_int(self) -> None: # nopep8
  498. """
  499. Get one thread, workspace id is not int
  500. """
  501. self.testapp.authorization = (
  502. 'Basic',
  503. (
  504. 'admin@admin.admin',
  505. 'admin@admin.admin'
  506. )
  507. )
  508. res = self.testapp.get(
  509. '/api/v2/workspaces/coucou/threads/7',
  510. status=400
  511. )
  512. def test_api__get_thread__err_400_content_id_is_not_int(self) -> None: # nopep8
  513. """
  514. Get one thread, content id is not int
  515. """
  516. self.testapp.authorization = (
  517. 'Basic',
  518. (
  519. 'admin@admin.admin',
  520. 'admin@admin.admin'
  521. )
  522. )
  523. res = self.testapp.get(
  524. '/api/v2/workspaces/2/threads/coucou',
  525. status=400
  526. )
  527. def test_api__update_thread__ok_200__nominal_case(self) -> None:
  528. """
  529. Update(put) thread
  530. """
  531. self.testapp.authorization = (
  532. 'Basic',
  533. (
  534. 'admin@admin.admin',
  535. 'admin@admin.admin'
  536. )
  537. )
  538. params = {
  539. 'label': 'My New label',
  540. 'raw_content': '<p> Le nouveau contenu </p>',
  541. }
  542. res = self.testapp.put_json(
  543. '/api/v2/workspaces/2/threads/7',
  544. params=params,
  545. status=200
  546. )
  547. content = res.json_body
  548. assert content['content_type'] == 'thread'
  549. assert content['content_id'] == 7
  550. assert content['is_archived'] is False
  551. assert content['is_deleted'] is False
  552. assert content['label'] == 'My New label'
  553. assert content['parent_id'] == 3
  554. assert content['show_in_ui'] is True
  555. assert content['slug'] == 'my-new-label'
  556. assert content['status'] == 'open'
  557. assert content['workspace_id'] == 2
  558. assert content['current_revision_id'] == 28
  559. # TODO - G.M - 2018-06-173 - check date format
  560. assert content['created']
  561. assert content['author']
  562. assert content['author']['user_id'] == 1
  563. assert content['author']['avatar_url'] is None
  564. assert content['author']['public_name'] == 'Global manager'
  565. # TODO - G.M - 2018-06-173 - check date format
  566. assert content['modified']
  567. assert content['last_modifier'] == content['author']
  568. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  569. res = self.testapp.get(
  570. '/api/v2/workspaces/2/threads/7',
  571. status=200
  572. ) # nopep8
  573. content = res.json_body
  574. assert content['content_type'] == 'thread'
  575. assert content['content_id'] == 7
  576. assert content['is_archived'] is False
  577. assert content['is_deleted'] is False
  578. assert content['label'] == 'My New label'
  579. assert content['parent_id'] == 3
  580. assert content['show_in_ui'] is True
  581. assert content['slug'] == 'my-new-label'
  582. assert content['status'] == 'open'
  583. assert content['workspace_id'] == 2
  584. assert content['current_revision_id'] == 28
  585. # TODO - G.M - 2018-06-173 - check date format
  586. assert content['created']
  587. assert content['author']
  588. assert content['author']['user_id'] == 1
  589. assert content['author']['avatar_url'] is None
  590. assert content['author']['public_name'] == 'Global manager'
  591. # TODO - G.M - 2018-06-173 - check date format
  592. assert content['modified']
  593. assert content['last_modifier'] == content['author']
  594. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  595. def test_api__update_thread__err_400__empty_label(self) -> None:
  596. """
  597. Update(put) thread
  598. """
  599. self.testapp.authorization = (
  600. 'Basic',
  601. (
  602. 'admin@admin.admin',
  603. 'admin@admin.admin'
  604. )
  605. )
  606. params = {
  607. 'label': '',
  608. 'raw_content': '<p> Le nouveau contenu </p>',
  609. }
  610. res = self.testapp.put_json(
  611. '/api/v2/workspaces/2/threads/7',
  612. params=params,
  613. status=400
  614. )
  615. def test_api__get_thread_revisions__ok_200__nominal_case(
  616. self
  617. ) -> None:
  618. """
  619. Get threads revisions
  620. """
  621. self.testapp.authorization = (
  622. 'Basic',
  623. (
  624. 'admin@admin.admin',
  625. 'admin@admin.admin'
  626. )
  627. )
  628. res = self.testapp.get(
  629. '/api/v2/workspaces/2/threads/7/revisions',
  630. status=200
  631. )
  632. revisions = res.json_body
  633. assert len(revisions) == 2
  634. revision = revisions[0]
  635. assert revision['content_type'] == 'thread'
  636. assert revision['content_id'] == 7
  637. assert revision['is_archived'] is False
  638. assert revision['is_deleted'] is False
  639. assert revision['label'] == 'Best Cake'
  640. assert revision['parent_id'] == 3
  641. assert revision['show_in_ui'] is True
  642. assert revision['slug'] == 'best-cake'
  643. assert revision['status'] == 'open'
  644. assert revision['workspace_id'] == 2
  645. assert revision['revision_id'] == 8
  646. assert revision['sub_content_types']
  647. assert revision['comment_ids'] == [18, 19, 20]
  648. # TODO - G.M - 2018-06-173 - check date format
  649. assert revision['created']
  650. assert revision['author']
  651. assert revision['author']['user_id'] == 1
  652. assert revision['author']['avatar_url'] is None
  653. assert revision['author']['public_name'] == 'Global manager'
  654. revision = revisions[1]
  655. assert revision['content_type'] == 'thread'
  656. assert revision['content_id'] == 7
  657. assert revision['is_archived'] is False
  658. assert revision['is_deleted'] is False
  659. assert revision['label'] == 'Best Cakes?'
  660. assert revision['parent_id'] == 3
  661. assert revision['show_in_ui'] is True
  662. assert revision['slug'] == 'best-cakes'
  663. assert revision['status'] == 'open'
  664. assert revision['workspace_id'] == 2
  665. assert revision['revision_id'] == 26
  666. assert revision['sub_content_types']
  667. assert revision['comment_ids'] == []
  668. # TODO - G.M - 2018-06-173 - check date format
  669. assert revision['created']
  670. assert revision['author']
  671. assert revision['author']['user_id'] == 3
  672. assert revision['author']['avatar_url'] is None
  673. assert revision['author']['public_name'] == 'Bob i.'
  674. def test_api__set_thread_status__ok_200__nominal_case(self) -> None:
  675. """
  676. Set thread status
  677. """
  678. self.testapp.authorization = (
  679. 'Basic',
  680. (
  681. 'admin@admin.admin',
  682. 'admin@admin.admin'
  683. )
  684. )
  685. params = {
  686. 'status': 'closed-deprecated',
  687. }
  688. # before
  689. res = self.testapp.get(
  690. '/api/v2/workspaces/2/threads/7',
  691. status=200
  692. ) # nopep8
  693. content = res.json_body
  694. assert content['content_type'] == 'thread'
  695. assert content['content_id'] == 7
  696. assert content['status'] == 'open'
  697. # set status
  698. res = self.testapp.put_json(
  699. '/api/v2/workspaces/2/threads/7/status',
  700. params=params,
  701. status=204
  702. )
  703. # after
  704. res = self.testapp.get(
  705. '/api/v2/workspaces/2/threads/7',
  706. status=200
  707. ) # nopep8
  708. content = res.json_body
  709. assert content['content_type'] == 'thread'
  710. assert content['content_id'] == 7
  711. assert content['status'] == 'closed-deprecated'