@@ -13,10 +13,12 @@ def remote():
13
13
├── data
14
14
│ ├── alice
15
15
│ ├── alpha
16
+ │ ├── subdir-file.txt
16
17
│ └── subdir
17
18
│ ├── 1
18
19
│ ├── 2
19
20
│ └── 3
21
+ ├── data1.txt
20
22
├── empty_dir
21
23
├── empty_file
22
24
└── foo
@@ -26,6 +28,7 @@ def remote():
26
28
s3 = remote .s3
27
29
28
30
s3 .create_bucket (Bucket = "bucket" )
31
+ s3 .put_object (Bucket = "bucket" , Key = "data1.txt" , Body = b"" )
29
32
s3 .put_object (Bucket = "bucket" , Key = "empty_dir/" )
30
33
s3 .put_object (Bucket = "bucket" , Key = "empty_file" , Body = b"" )
31
34
s3 .put_object (Bucket = "bucket" , Key = "foo" , Body = b"foo" )
@@ -34,6 +37,9 @@ def remote():
34
37
s3 .put_object (Bucket = "bucket" , Key = "data/subdir/1" , Body = b"1" )
35
38
s3 .put_object (Bucket = "bucket" , Key = "data/subdir/2" , Body = b"2" )
36
39
s3 .put_object (Bucket = "bucket" , Key = "data/subdir/3" , Body = b"3" )
40
+ s3 .put_object (
41
+ Bucket = "bucket" , Key = "data/subdir-file.txt" , Body = b"subdir"
42
+ )
37
43
38
44
yield remote
39
45
@@ -66,6 +72,7 @@ def test_exists(remote):
66
72
(True , "data/subdir/1" ),
67
73
(False , "data/al" ),
68
74
(False , "foo/" ),
75
+ (True , "data1.txt" ),
69
76
]
70
77
71
78
for expected , path in test_cases :
@@ -76,9 +83,11 @@ def test_walk_files(remote):
76
83
files = [
77
84
remote .path_info / "data/alice" ,
78
85
remote .path_info / "data/alpha" ,
86
+ remote .path_info / "data/subdir-file.txt" ,
79
87
remote .path_info / "data/subdir/1" ,
80
88
remote .path_info / "data/subdir/2" ,
81
89
remote .path_info / "data/subdir/3" ,
90
+ remote .path_info / "data1.txt" ,
82
91
remote .path_info / "empty_file" ,
83
92
remote .path_info / "foo" ,
84
93
]
@@ -109,3 +118,23 @@ def test_makedirs(remote):
109
118
assert not remote .exists (empty_dir )
110
119
remote .makedirs (empty_dir )
111
120
assert remote .exists (empty_dir )
121
+
122
+
123
+ def test_isfile (remote ):
124
+ test_cases = [
125
+ (False , "empty_dir/" ),
126
+ (True , "empty_file" ),
127
+ (True , "foo" ),
128
+ (True , "data/alice" ),
129
+ (True , "data/alpha" ),
130
+ (True , "data/subdir/1" ),
131
+ (True , "data/subdir/2" ),
132
+ (True , "data/subdir/3" ),
133
+ (False , "data/subdir/empty_dir/" ),
134
+ (False , "data/subdir/1/" ),
135
+ (False , "something-that-does-not-exist" ),
136
+ (False , "empty_dir" ),
137
+ ]
138
+
139
+ for expected , path in test_cases :
140
+ assert remote .isfile (remote .path_info / path ) == expected
0 commit comments