@@ -321,6 +321,16 @@ def test_get_contents_no_such_file(self):
321
321
with assert_http_error (404 ):
322
322
self .api .read ('foo/q.ipynb' )
323
323
324
+ def test_get_404_hidden (self ):
325
+ if sys .platform == 'win32' :
326
+ self .skipTest ("Disabled copying hidden files on Windows" )
327
+ self .make_txt ('.hidden/visible.txt' , 'test string' )
328
+ self .make_txt ('.hidden.txt' , 'test string' )
329
+ with assert_http_error (404 ):
330
+ resp = self .api .read ('.hidden/visible.txt' )
331
+ with assert_http_error (404 ):
332
+ resp = self .api .read ('.hidden.txt' )
333
+
324
334
def test_get_text_file_contents (self ):
325
335
for d , name in self .dirs_nbs :
326
336
path = url_path_join (d , name + '.txt' )
@@ -443,6 +453,51 @@ def test_upload_txt(self):
443
453
self .assertEqual (model ['format' ], 'text' )
444
454
self .assertEqual (model ['content' ], body )
445
455
456
+ def test_upload_txt_hidden (self ):
457
+ if sys .platform == 'win32' :
458
+ self .skipTest ("Disabled copying hidden files on Windows" )
459
+ with assert_http_error (400 ):
460
+ body = 'ünicode téxt'
461
+ model = {
462
+ 'content' : body ,
463
+ 'format' : 'text' ,
464
+ 'type' : 'file' ,
465
+ }
466
+ path = '.hidden/Upload tést.txt'
467
+ resp = self .api .upload (path , body = json .dumps (model ))
468
+
469
+ with assert_http_error (400 ):
470
+ body = 'ünicode téxt'
471
+ model = {
472
+ 'content' : body ,
473
+ 'format' : 'text' ,
474
+ 'type' : 'file' ,
475
+ 'path' : '.hidden/test.txt'
476
+ }
477
+ path = 'Upload tést.txt'
478
+ resp = self .api .upload (path , body = json .dumps (model ))
479
+
480
+ with assert_http_error (400 ):
481
+ body = 'ünicode téxt'
482
+ model = {
483
+ 'content' : body ,
484
+ 'format' : 'text' ,
485
+ 'type' : 'file' ,
486
+ }
487
+ path = '.hidden.txt'
488
+ resp = self .api .upload (path , body = json .dumps (model ))
489
+
490
+ with assert_http_error (400 ):
491
+ body = 'ünicode téxt'
492
+ model = {
493
+ 'content' : body ,
494
+ 'format' : 'text' ,
495
+ 'type' : 'file' ,
496
+ 'path' : '.hidden.txt'
497
+ }
498
+ path = 'Upload tést.txt'
499
+ resp = self .api .upload (path , body = json .dumps (model ))
500
+
446
501
def test_upload_b64 (self ):
447
502
body = b'\xFF blob'
448
503
b64body = encodebytes (body ).decode ('ascii' )
@@ -497,10 +552,37 @@ def test_copy_path(self):
497
552
resp = self .api .copy ('foo/a.ipynb' , 'å b' )
498
553
self ._check_created (resp , 'å b/a-Copy1.ipynb' )
499
554
555
+ def test_copy_400_hidden (self ):
556
+ if sys .platform == 'win32' :
557
+ self .skipTest ("Disabled copying hidden files on Windows" )
558
+ self .make_txt ('new.txt' , 'test string' )
559
+ self .make_txt ('.hidden/new.txt' , 'test string' )
560
+ self .make_txt ('.hidden.txt' , 'test string' )
561
+ with assert_http_error (400 ):
562
+ resp = self .api .copy ('.hidden/old.txt' , 'new.txt' )
563
+ with assert_http_error (400 ):
564
+ resp = self .api .copy ('old.txt' , '.hidden/new.txt' )
565
+ with assert_http_error (400 ):
566
+ resp = self .api .copy ('.hidden.txt' , 'new.txt' )
567
+ with assert_http_error (400 ):
568
+ resp = self .api .copy ('old.txt' , '.hidden.txt' )
569
+
500
570
def test_copy_put_400 (self ):
501
571
with assert_http_error (400 ):
502
572
resp = self .api .copy_put ('å b/ç d.ipynb' , 'å b/cøpy.ipynb' )
503
573
574
+ def test_copy_put_400_hidden (self ):
575
+ if sys .platform == 'win32' :
576
+ self .skipTest ("Disabled copying hidden files on Windows" )
577
+ with assert_http_error (400 ):
578
+ resp = self .api .copy_put ('.hidden/old.txt' , 'new.txt' )
579
+ with assert_http_error (400 ):
580
+ resp = self .api .copy_put ('old.txt' , '.hidden/new.txt' )
581
+ with assert_http_error (400 ):
582
+ resp = self .api .copy_put ('.hidden.txt' , 'new.txt' )
583
+ with assert_http_error (400 ):
584
+ resp = self .api .copy_put ('old.txt' , '.hidden.txt' )
585
+
504
586
def test_copy_dir_400 (self ):
505
587
# can't copy directories
506
588
with assert_http_error (400 ):
@@ -543,6 +625,29 @@ def test_delete_non_empty_dir(self):
543
625
with assert_http_error (404 ):
544
626
self .api .list ('å b' )
545
627
628
+ def test_delete_hidden_dir (self ):
629
+ if sys .platform == 'win32' :
630
+ self .skipTest ("Disabled deleting hidden dirs on Windows" )
631
+ with assert_http_error (400 ):
632
+ # Test that non empty directory can be deleted
633
+ try :
634
+ self .api .delete ('.hidden' )
635
+ except requests .HTTPError as e :
636
+ assert e .response .status_code == 400
637
+ raise e
638
+
639
+ def test_delete_hidden_file (self ):
640
+ #Test deleting file in a hidden directory
641
+ if sys .platform == 'win32' :
642
+ self .skipTest ("Disabled deleting hidden dirs on Windows" )
643
+ with assert_http_error (400 ):
644
+ # Test that non empty directory can be deleted
645
+ self .api .delete ('.hidden/test.txt' )
646
+
647
+ #Test deleting a hidden file
648
+ with assert_http_error (400 ):
649
+ self .api .delete ('.hidden.txt' )
650
+
546
651
def test_rename (self ):
547
652
resp = self .api .rename ('foo/a.ipynb' , 'foo/z.ipynb' )
548
653
self .assertEqual (resp .headers ['Location' ].split ('/' )[- 1 ], 'z.ipynb' )
@@ -555,6 +660,21 @@ def test_rename(self):
555
660
self .assertIn ('z.ipynb' , nbnames )
556
661
self .assertNotIn ('a.ipynb' , nbnames )
557
662
663
+ def test_rename_400_hidden (self ):
664
+ if sys .platform == 'win32' :
665
+ self .skipTest ("Disabled copying hidden files on Windows" )
666
+ # self.make_txt('new.txt', 'test string')
667
+ # self.make_txt('.hidden/new.txt', 'test string')
668
+ # self.make_txt('.hidden.txt', 'test string')
669
+ with assert_http_error (400 ):
670
+ resp = self .api .rename ('.hidden/old.txt' , 'new.txt' )
671
+ with assert_http_error (400 ):
672
+ resp = self .api .rename ('old.txt' , '.hidden/new.txt' )
673
+ with assert_http_error (400 ):
674
+ resp = self .api .rename ('.hidden.txt' , 'new.txt' )
675
+ with assert_http_error (400 ):
676
+ resp = self .api .rename ('old.txt' , '.hidden.txt' )
677
+
558
678
def test_checkpoints_follow_file (self ):
559
679
560
680
# Read initial file state
0 commit comments