|
@@ -2,6 +2,7 @@
|
2
|
2
|
import io
|
3
|
3
|
from nose.tools import eq_
|
4
|
4
|
from nose.tools import ok_
|
|
5
|
+from tracim.lib.notifications import DummyNotifier
|
5
|
6
|
from tracim.lib.webdav.sql_dav_provider import Provider
|
6
|
7
|
from tracim.lib.webdav.sql_resources import Root
|
7
|
8
|
from tracim.model import Content
|
|
@@ -450,3 +451,55 @@ class TestWebDav(TestStandard):
|
450
|
451
|
content_w1f1d1.parent.label
|
451
|
452
|
)
|
452
|
453
|
)
|
|
454
|
+
|
|
455
|
+ def test_unit__update_content__ok(self):
|
|
456
|
+ provider = self._get_provider()
|
|
457
|
+ environ = self._get_environ(
|
|
458
|
+ provider,
|
|
459
|
+ 'bob@fsf.local',
|
|
460
|
+ )
|
|
461
|
+ result = provider.getResourceInst(
|
|
462
|
+ '/w1/w1f1/new_file.txt',
|
|
463
|
+ environ,
|
|
464
|
+ )
|
|
465
|
+
|
|
466
|
+ eq_(None, result, msg='Result should be None instead {0}'.format(
|
|
467
|
+ result
|
|
468
|
+ ))
|
|
469
|
+
|
|
470
|
+ result = self._put_new_text_file(
|
|
471
|
+ provider,
|
|
472
|
+ environ,
|
|
473
|
+ '/w1/w1f1/new_file.txt',
|
|
474
|
+ b'hello\n',
|
|
475
|
+ )
|
|
476
|
+
|
|
477
|
+ ok_(result, msg='Result should not be None instead {0}'.format(
|
|
478
|
+ result
|
|
479
|
+ ))
|
|
480
|
+ eq_(
|
|
481
|
+ b'hello\n',
|
|
482
|
+ result.content.file_content,
|
|
483
|
+ msg='fiel content should be "hello\n" but it is {0}'.format(
|
|
484
|
+ result.content.file_content
|
|
485
|
+ )
|
|
486
|
+ )
|
|
487
|
+
|
|
488
|
+ # ReInit DummyNotifier counter
|
|
489
|
+ DummyNotifier.send_count = 0
|
|
490
|
+
|
|
491
|
+ # Update file content
|
|
492
|
+ write_object = result.beginWrite(
|
|
493
|
+ contentType='application/octet-stream',
|
|
494
|
+ )
|
|
495
|
+ write_object.write(b'An other line')
|
|
496
|
+ write_object.close()
|
|
497
|
+ result.endWrite(withErrors=False)
|
|
498
|
+
|
|
499
|
+ eq_(
|
|
500
|
+ 0,
|
|
501
|
+ DummyNotifier.send_count,
|
|
502
|
+ msg='DummyNotifier should send 1 mail, not {}'.format(
|
|
503
|
+ DummyNotifier.send_count
|
|
504
|
+ ),
|
|
505
|
+ )
|