|
@@ -1,9 +1,7 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
3
|
|
-from nose.tools import eq_, ok_
|
4
|
|
-from nose.tools import raises
|
5
|
|
-
|
6
|
3
|
import transaction
|
|
4
|
+import pytest
|
7
|
5
|
|
8
|
6
|
from tracim.config import CFG
|
9
|
7
|
from tracim.lib.core.content import compare_content_for_sorting_by_type_and_name
|
|
@@ -28,6 +26,7 @@ from tracim.models.data import ContentType
|
28
|
26
|
from tracim.models.data import UserRoleInWorkspace
|
29
|
27
|
from tracim.fixtures.users_and_groups import Test as FixtureTest
|
30
|
28
|
from tracim.tests import DefaultTest
|
|
29
|
+from tracim.tests import eq_
|
31
|
30
|
|
32
|
31
|
|
33
|
32
|
class TestContentApi(DefaultTest):
|
|
@@ -387,7 +386,6 @@ class TestContentApi(DefaultTest):
|
387
|
386
|
eq_(1, len(items2))
|
388
|
387
|
eq_(child_id, items2[0].content_id)
|
389
|
388
|
|
390
|
|
- @raises(ValueError)
|
391
|
389
|
def test_set_status_unknown_status(self):
|
392
|
390
|
uapi = UserApi(
|
393
|
391
|
session=self.session,
|
|
@@ -423,7 +421,8 @@ class TestContentApi(DefaultTest):
|
423
|
421
|
tm=transaction.manager,
|
424
|
422
|
content=c,
|
425
|
423
|
):
|
426
|
|
- api.set_status(c, 'unknown-status')
|
|
424
|
+ with pytest.raises(ValueError):
|
|
425
|
+ api.set_status(c, 'unknown-status')
|
427
|
426
|
|
428
|
427
|
def test_set_status_ok(self):
|
429
|
428
|
uapi = UserApi(
|
|
@@ -1210,7 +1209,6 @@ class TestContentApi(DefaultTest):
|
1210
|
1209
|
eq_('new content', updated.description)
|
1211
|
1210
|
eq_(ActionDescription.EDITION, updated.revision_type)
|
1212
|
1211
|
|
1213
|
|
- @raises(SameValueError)
|
1214
|
1212
|
def test_update_no_change(self):
|
1215
|
1213
|
uapi = UserApi(
|
1216
|
1214
|
session=self.session,
|
|
@@ -1280,11 +1278,12 @@ class TestContentApi(DefaultTest):
|
1280
|
1278
|
tm=transaction.manager,
|
1281
|
1279
|
content=content2,
|
1282
|
1280
|
):
|
1283
|
|
- api2.update_content(
|
1284
|
|
- item=content2,
|
1285
|
|
- new_label='same_content',
|
1286
|
|
- new_content='Same_content_here'
|
1287
|
|
- )
|
|
1281
|
+ with pytest.raises(SameValueError):
|
|
1282
|
+ api2.update_content(
|
|
1283
|
+ item=content2,
|
|
1284
|
+ new_label='same_content',
|
|
1285
|
+ new_content='Same_content_here'
|
|
1286
|
+ )
|
1288
|
1287
|
api2.save(content2)
|
1289
|
1288
|
transaction.commit()
|
1290
|
1289
|
|
|
@@ -1377,8 +1376,12 @@ class TestContentApi(DefaultTest):
|
1377
|
1376
|
tm=transaction.manager,
|
1378
|
1377
|
content=content2,
|
1379
|
1378
|
):
|
1380
|
|
- api2.update_file_data(content2, 'index.html', 'text/html',
|
1381
|
|
- b'<html>hello world</html>')
|
|
1379
|
+ api2.update_file_data(
|
|
1380
|
+ content2,
|
|
1381
|
+ 'index.html',
|
|
1382
|
+ 'text/html',
|
|
1383
|
+ b'<html>hello world</html>'
|
|
1384
|
+ )
|
1382
|
1385
|
api2.save(content2)
|
1383
|
1386
|
transaction.commit()
|
1384
|
1387
|
|
|
@@ -1398,7 +1401,6 @@ class TestContentApi(DefaultTest):
|
1398
|
1401
|
eq_(b'<html>hello world</html>', updated.depot_file.file.read())
|
1399
|
1402
|
eq_(ActionDescription.REVISION, updated.revision_type)
|
1400
|
1403
|
|
1401
|
|
- @raises(SameValueError)
|
1402
|
1404
|
def test_update_no_change(self):
|
1403
|
1405
|
uapi = UserApi(
|
1404
|
1406
|
session=self.session,
|
|
@@ -1471,12 +1473,13 @@ class TestContentApi(DefaultTest):
|
1471
|
1473
|
tm=transaction.manager,
|
1472
|
1474
|
content=content2,
|
1473
|
1475
|
):
|
1474
|
|
- api2.update_file_data(
|
1475
|
|
- page,
|
1476
|
|
- 'index.html',
|
1477
|
|
- 'text/html',
|
1478
|
|
- b'<html>Same Content Here</html>'
|
1479
|
|
- )
|
|
1476
|
+ with pytest.raises(SameValueError):
|
|
1477
|
+ api2.update_file_data(
|
|
1478
|
+ page,
|
|
1479
|
+ 'index.html',
|
|
1480
|
+ 'text/html',
|
|
1481
|
+ b'<html>Same Content Here</html>'
|
|
1482
|
+ )
|
1480
|
1483
|
api2.save(content2)
|
1481
|
1484
|
transaction.commit()
|
1482
|
1485
|
|
|
@@ -1985,11 +1988,11 @@ class TestContentApi(DefaultTest):
|
1985
|
1988
|
|
1986
|
1989
|
foo_result = api.search(['foo']).all()
|
1987
|
1990
|
eq_(1, len(foo_result))
|
1988
|
|
- ok_(page_1 in foo_result)
|
|
1991
|
+ assert page_1 in foo_result
|
1989
|
1992
|
|
1990
|
1993
|
bar_result = api.search(['bar']).all()
|
1991
|
1994
|
eq_(1, len(bar_result))
|
1992
|
|
- ok_(page_2 in bar_result)
|
|
1995
|
+ assert page_2 in bar_result
|
1993
|
1996
|
|
1994
|
1997
|
with new_revision(
|
1995
|
1998
|
session=self.session,
|
|
@@ -2007,11 +2010,11 @@ class TestContentApi(DefaultTest):
|
2007
|
2010
|
# Actually ContentApi.search don't filter it
|
2008
|
2011
|
foo_result = api.search(['foo']).all()
|
2009
|
2012
|
eq_(1, len(foo_result))
|
2010
|
|
- ok_(page_1 in foo_result)
|
|
2013
|
+ assert page_1 in foo_result
|
2011
|
2014
|
|
2012
|
2015
|
bar_result = api.search(['bar']).all()
|
2013
|
2016
|
eq_(1, len(bar_result))
|
2014
|
|
- ok_(page_2 in bar_result)
|
|
2017
|
+ assert page_2 in bar_result
|
2015
|
2018
|
|
2016
|
2019
|
# ContentApi offer exclude_unavailable method to do it
|
2017
|
2020
|
foo_result = api.search(['foo']).all()
|