test_contents.py 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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__ok_200__nominal_case(self) -> None:
  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': 'My New 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=200
  202. )
  203. content = res.json_body
  204. assert content['content_type'] == 'html-documents'
  205. assert content['content_id'] == 6
  206. assert content['is_archived'] is False
  207. assert content['is_deleted'] is False
  208. assert content['label'] == 'My New label'
  209. assert content['parent_id'] == 3
  210. assert content['show_in_ui'] is True
  211. assert content['slug'] == 'my-new-label'
  212. assert content['status'] == 'open'
  213. assert content['workspace_id'] == 2
  214. assert content['current_revision_id'] == 28
  215. # TODO - G.M - 2018-06-173 - check date format
  216. assert content['created']
  217. assert content['author']
  218. assert content['author']['user_id'] == 1
  219. assert content['author']['avatar_url'] is None
  220. assert content['author']['public_name'] == 'Global manager'
  221. # TODO - G.M - 2018-06-173 - check date format
  222. assert content['modified']
  223. assert content['last_modifier'] == content['author']
  224. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  225. res = self.testapp.get(
  226. '/api/v2/workspaces/2/html-documents/6',
  227. status=200
  228. )
  229. content = res.json_body
  230. assert content['content_type'] == 'html-documents'
  231. assert content['content_id'] == 6
  232. assert content['is_archived'] is False
  233. assert content['is_deleted'] is False
  234. assert content['label'] == 'My New label'
  235. assert content['parent_id'] == 3
  236. assert content['show_in_ui'] is True
  237. assert content['slug'] == 'my-new-label'
  238. assert content['status'] == 'open'
  239. assert content['workspace_id'] == 2
  240. assert content['current_revision_id'] == 28
  241. # TODO - G.M - 2018-06-173 - check date format
  242. assert content['created']
  243. assert content['author']
  244. assert content['author']['user_id'] == 1
  245. assert content['author']['avatar_url'] is None
  246. assert content['author']['public_name'] == 'Global manager'
  247. # TODO - G.M - 2018-06-173 - check date format
  248. assert content['modified']
  249. assert content['last_modifier'] == content['author']
  250. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  251. def test_api__get_html_document_revisions__ok_200__nominal_case(
  252. self
  253. ) -> None:
  254. """
  255. Get one html document of a content
  256. """
  257. self.testapp.authorization = (
  258. 'Basic',
  259. (
  260. 'admin@admin.admin',
  261. 'admin@admin.admin'
  262. )
  263. )
  264. res = self.testapp.get(
  265. '/api/v2/workspaces/2/html-documents/6/revisions',
  266. status=200
  267. )
  268. revisions = res.json_body
  269. assert len(revisions) == 3
  270. revision = revisions[0]
  271. assert revision['content_type'] == 'html-documents'
  272. assert revision['content_id'] == 6
  273. assert revision['is_archived'] is False
  274. assert revision['is_deleted'] is False
  275. assert revision['label'] == 'Tiramisu Recipes!!!'
  276. assert revision['parent_id'] == 3
  277. assert revision['show_in_ui'] is True
  278. assert revision['slug'] == 'tiramisu-recipes'
  279. assert revision['status'] == 'open'
  280. assert revision['workspace_id'] == 2
  281. assert revision['revision_id'] == 6
  282. assert revision['sub_content_types']
  283. # TODO - G.M - 2018-06-173 - Test with real comments
  284. assert revision['comment_ids'] == []
  285. # TODO - G.M - 2018-06-173 - check date format
  286. assert revision['created']
  287. assert revision['author']
  288. assert revision['author']['user_id'] == 1
  289. assert revision['author']['avatar_url'] is None
  290. assert revision['author']['public_name'] == 'Global manager'
  291. revision = revisions[1]
  292. assert revision['content_type'] == 'html-documents'
  293. assert revision['content_id'] == 6
  294. assert revision['is_archived'] is False
  295. assert revision['is_deleted'] is False
  296. assert revision['label'] == 'Tiramisu Recipes!!!'
  297. assert revision['parent_id'] == 3
  298. assert revision['show_in_ui'] is True
  299. assert revision['slug'] == 'tiramisu-recipes'
  300. assert revision['status'] == 'open'
  301. assert revision['workspace_id'] == 2
  302. assert revision['revision_id'] == 7
  303. assert revision['sub_content_types']
  304. # TODO - G.M - 2018-06-173 - Test with real comments
  305. assert revision['comment_ids'] == []
  306. # TODO - G.M - 2018-06-173 - check date format
  307. assert revision['created']
  308. assert revision['author']
  309. assert revision['author']['user_id'] == 1
  310. assert revision['author']['avatar_url'] is None
  311. assert revision['author']['public_name'] == 'Global manager'
  312. revision = revisions[2]
  313. assert revision['content_type'] == 'html-documents'
  314. assert revision['content_id'] == 6
  315. assert revision['is_archived'] is False
  316. assert revision['is_deleted'] is False
  317. assert revision['label'] == 'Tiramisu Recipe'
  318. assert revision['parent_id'] == 3
  319. assert revision['show_in_ui'] is True
  320. assert revision['slug'] == 'tiramisu-recipe'
  321. assert revision['status'] == 'open'
  322. assert revision['workspace_id'] == 2
  323. assert revision['revision_id'] == 27
  324. assert revision['sub_content_types']
  325. # TODO - G.M - 2018-06-173 - Test with real comments
  326. assert revision['comment_ids'] == []
  327. # TODO - G.M - 2018-06-173 - check date format
  328. assert revision['created']
  329. assert revision['author']
  330. assert revision['author']['user_id'] == 3
  331. assert revision['author']['avatar_url'] is None
  332. assert revision['author']['public_name'] == 'Bob i.'
  333. def test_api__set_html_document_status__ok_200__nominal_case(self) -> None:
  334. """
  335. Get one html document of a content
  336. """
  337. self.testapp.authorization = (
  338. 'Basic',
  339. (
  340. 'admin@admin.admin',
  341. 'admin@admin.admin'
  342. )
  343. )
  344. params = {
  345. 'status': 'closed-deprecated',
  346. }
  347. # before
  348. res = self.testapp.get(
  349. '/api/v2/workspaces/2/html-documents/6',
  350. status=200
  351. )
  352. content = res.json_body
  353. assert content['content_type'] == 'html-documents'
  354. assert content['content_id'] == 6
  355. assert content['status'] == 'open'
  356. # set status
  357. res = self.testapp.put_json(
  358. '/api/v2/workspaces/2/html-documents/6/status',
  359. params=params,
  360. status=204
  361. )
  362. # after
  363. res = self.testapp.get(
  364. '/api/v2/workspaces/2/html-documents/6',
  365. status=200
  366. )
  367. content = res.json_body
  368. assert content['content_type'] == 'html-documents'
  369. assert content['content_id'] == 6
  370. assert content['status'] == 'closed-deprecated'
  371. class TestThreads(FunctionalTest):
  372. """
  373. Tests for /api/v2/workspaces/{workspace_id}/threads/{content_id}
  374. endpoint
  375. """
  376. fixtures = [BaseFixture, ContentFixtures]
  377. def test_api__get_thread__err_400__wrong_content_type(self) -> None:
  378. """
  379. Get one html document of a content
  380. """
  381. self.testapp.authorization = (
  382. 'Basic',
  383. (
  384. 'admin@admin.admin',
  385. 'admin@admin.admin'
  386. )
  387. )
  388. res = self.testapp.get(
  389. '/api/v2/workspaces/2/threads/6',
  390. status=400
  391. )
  392. def test_api__get_thread__ok_200__nominal_case(self) -> None:
  393. """
  394. Get one html document of a content
  395. """
  396. self.testapp.authorization = (
  397. 'Basic',
  398. (
  399. 'admin@admin.admin',
  400. 'admin@admin.admin'
  401. )
  402. )
  403. res = self.testapp.get(
  404. '/api/v2/workspaces/2/threads/7',
  405. status=200
  406. ) # nopep8
  407. content = res.json_body
  408. assert content['content_type'] == 'thread'
  409. assert content['content_id'] == 7
  410. assert content['is_archived'] is False
  411. assert content['is_deleted'] is False
  412. assert content['label'] == 'Best Cakes?'
  413. assert content['parent_id'] == 3
  414. assert content['show_in_ui'] is True
  415. assert content['slug'] == 'best-cakes'
  416. assert content['status'] == 'open'
  417. assert content['workspace_id'] == 2
  418. assert content['current_revision_id'] == 26
  419. # TODO - G.M - 2018-06-173 - check date format
  420. assert content['created']
  421. assert content['author']
  422. assert content['author']['user_id'] == 1
  423. assert content['author']['avatar_url'] is None
  424. assert content['author']['public_name'] == 'Global manager'
  425. # TODO - G.M - 2018-06-173 - check date format
  426. assert content['modified']
  427. assert content['last_modifier'] != content['author']
  428. assert content['last_modifier']['user_id'] == 3
  429. assert content['last_modifier']['public_name'] == 'Bob i.'
  430. assert content['last_modifier']['avatar_url'] is None
  431. assert content['raw_content'] == 'What is the best cake?' # nopep8
  432. def test_api__get_thread__err_400__content_does_not_exist(self) -> None:
  433. """
  434. Get one thread (content 170 does not exist)
  435. """
  436. self.testapp.authorization = (
  437. 'Basic',
  438. (
  439. 'admin@admin.admin',
  440. 'admin@admin.admin'
  441. )
  442. )
  443. res = self.testapp.get(
  444. '/api/v2/workspaces/2/threads/170',
  445. status=400
  446. )
  447. def test_api__get_thread__err_400__content_not_in_workspace(self) -> None:
  448. """
  449. Get one thread(content 7 is in workspace 2)
  450. """
  451. self.testapp.authorization = (
  452. 'Basic',
  453. (
  454. 'admin@admin.admin',
  455. 'admin@admin.admin'
  456. )
  457. )
  458. res = self.testapp.get(
  459. '/api/v2/workspaces/1/threads/7',
  460. status=400
  461. )
  462. def test_api__get_thread__err_400__workspace_does_not_exist(self) -> None: # nopep8
  463. """
  464. Get one thread (Workspace 40 does not exist)
  465. """
  466. self.testapp.authorization = (
  467. 'Basic',
  468. (
  469. 'admin@admin.admin',
  470. 'admin@admin.admin'
  471. )
  472. )
  473. res = self.testapp.get(
  474. '/api/v2/workspaces/40/threads/7',
  475. status=400
  476. )
  477. def test_api__get_thread__err_400__workspace_id_is_not_int(self) -> None: # nopep8
  478. """
  479. Get one thread, workspace id is not int
  480. """
  481. self.testapp.authorization = (
  482. 'Basic',
  483. (
  484. 'admin@admin.admin',
  485. 'admin@admin.admin'
  486. )
  487. )
  488. res = self.testapp.get(
  489. '/api/v2/workspaces/coucou/threads/7',
  490. status=400
  491. )
  492. def test_api__get_thread__err_400_content_id_is_not_int(self) -> None: # nopep8
  493. """
  494. Get one thread, content id is not int
  495. """
  496. self.testapp.authorization = (
  497. 'Basic',
  498. (
  499. 'admin@admin.admin',
  500. 'admin@admin.admin'
  501. )
  502. )
  503. res = self.testapp.get(
  504. '/api/v2/workspaces/2/threads/coucou',
  505. status=400
  506. )
  507. def test_api__update_thread__ok_200__nominal_case(self) -> None:
  508. """
  509. Update(put) thread
  510. """
  511. self.testapp.authorization = (
  512. 'Basic',
  513. (
  514. 'admin@admin.admin',
  515. 'admin@admin.admin'
  516. )
  517. )
  518. params = {
  519. 'label': 'My New label',
  520. 'raw_content': '<p> Le nouveau contenu </p>',
  521. }
  522. res = self.testapp.put_json(
  523. '/api/v2/workspaces/2/threads/7',
  524. params=params,
  525. status=200
  526. )
  527. content = res.json_body
  528. assert content['content_type'] == 'thread'
  529. assert content['content_id'] == 7
  530. assert content['is_archived'] is False
  531. assert content['is_deleted'] is False
  532. assert content['label'] == 'My New label'
  533. assert content['parent_id'] == 3
  534. assert content['show_in_ui'] is True
  535. assert content['slug'] == 'my-new-label'
  536. assert content['status'] == 'open'
  537. assert content['workspace_id'] == 2
  538. assert content['current_revision_id'] == 28
  539. # TODO - G.M - 2018-06-173 - check date format
  540. assert content['created']
  541. assert content['author']
  542. assert content['author']['user_id'] == 1
  543. assert content['author']['avatar_url'] is None
  544. assert content['author']['public_name'] == 'Global manager'
  545. # TODO - G.M - 2018-06-173 - check date format
  546. assert content['modified']
  547. assert content['last_modifier'] == content['author']
  548. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  549. res = self.testapp.get(
  550. '/api/v2/workspaces/2/threads/7',
  551. status=200
  552. ) # nopep8
  553. content = res.json_body
  554. assert content['content_type'] == 'thread'
  555. assert content['content_id'] == 7
  556. assert content['is_archived'] is False
  557. assert content['is_deleted'] is False
  558. assert content['label'] == 'My New label'
  559. assert content['parent_id'] == 3
  560. assert content['show_in_ui'] is True
  561. assert content['slug'] == 'my-new-label'
  562. assert content['status'] == 'open'
  563. assert content['workspace_id'] == 2
  564. assert content['current_revision_id'] == 28
  565. # TODO - G.M - 2018-06-173 - check date format
  566. assert content['created']
  567. assert content['author']
  568. assert content['author']['user_id'] == 1
  569. assert content['author']['avatar_url'] is None
  570. assert content['author']['public_name'] == 'Global manager'
  571. # TODO - G.M - 2018-06-173 - check date format
  572. assert content['modified']
  573. assert content['last_modifier'] == content['author']
  574. assert content['raw_content'] == '<p> Le nouveau contenu </p>'
  575. def test_api__get_thread_revisions__ok_200__nominal_case(
  576. self
  577. ) -> None:
  578. """
  579. Get threads revisions
  580. """
  581. self.testapp.authorization = (
  582. 'Basic',
  583. (
  584. 'admin@admin.admin',
  585. 'admin@admin.admin'
  586. )
  587. )
  588. res = self.testapp.get(
  589. '/api/v2/workspaces/2/threads/7/revisions',
  590. status=200
  591. )
  592. revisions = res.json_body
  593. assert len(revisions) == 2
  594. revision = revisions[0]
  595. assert revision['content_type'] == 'thread'
  596. assert revision['content_id'] == 7
  597. assert revision['is_archived'] is False
  598. assert revision['is_deleted'] is False
  599. assert revision['label'] == 'Best Cake'
  600. assert revision['parent_id'] == 3
  601. assert revision['show_in_ui'] is True
  602. assert revision['slug'] == 'best-cake'
  603. assert revision['status'] == 'open'
  604. assert revision['workspace_id'] == 2
  605. assert revision['revision_id'] == 8
  606. assert revision['sub_content_types']
  607. assert revision['comment_ids'] == [18, 19, 20]
  608. # TODO - G.M - 2018-06-173 - check date format
  609. assert revision['created']
  610. assert revision['author']
  611. assert revision['author']['user_id'] == 1
  612. assert revision['author']['avatar_url'] is None
  613. assert revision['author']['public_name'] == 'Global manager'
  614. revision = revisions[1]
  615. assert revision['content_type'] == 'thread'
  616. assert revision['content_id'] == 7
  617. assert revision['is_archived'] is False
  618. assert revision['is_deleted'] is False
  619. assert revision['label'] == 'Best Cakes?'
  620. assert revision['parent_id'] == 3
  621. assert revision['show_in_ui'] is True
  622. assert revision['slug'] == 'best-cakes'
  623. assert revision['status'] == 'open'
  624. assert revision['workspace_id'] == 2
  625. assert revision['revision_id'] == 26
  626. assert revision['sub_content_types']
  627. assert revision['comment_ids'] == []
  628. # TODO - G.M - 2018-06-173 - check date format
  629. assert revision['created']
  630. assert revision['author']
  631. assert revision['author']['user_id'] == 3
  632. assert revision['author']['avatar_url'] is None
  633. assert revision['author']['public_name'] == 'Bob i.'
  634. def test_api__set_thread_status__ok_200__nominal_case(self) -> None:
  635. """
  636. Set thread status
  637. """
  638. self.testapp.authorization = (
  639. 'Basic',
  640. (
  641. 'admin@admin.admin',
  642. 'admin@admin.admin'
  643. )
  644. )
  645. params = {
  646. 'status': 'closed-deprecated',
  647. }
  648. # before
  649. res = self.testapp.get(
  650. '/api/v2/workspaces/2/threads/7',
  651. status=200
  652. ) # nopep8
  653. content = res.json_body
  654. assert content['content_type'] == 'thread'
  655. assert content['content_id'] == 7
  656. assert content['status'] == 'open'
  657. # set status
  658. res = self.testapp.put_json(
  659. '/api/v2/workspaces/2/threads/7/status',
  660. params=params,
  661. status=204
  662. )
  663. # after
  664. res = self.testapp.get(
  665. '/api/v2/workspaces/2/threads/7',
  666. status=200
  667. ) # nopep8
  668. content = res.json_body
  669. assert content['content_type'] == 'thread'
  670. assert content['content_id'] == 7
  671. assert content['status'] == 'closed-deprecated'