File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,14 @@ def stat_account(conn, options):
45
45
policies .add (policy_name )
46
46
47
47
for policy in policies :
48
+ container_count_header = (POLICY_HEADER_PREFIX + policy +
49
+ '-container-count' )
50
+ if container_count_header in headers :
51
+ items .append (
52
+ ('Containers in policy "' + policy + '"' ,
53
+ prt_bytes (headers [container_count_header ],
54
+ options ['human' ]).lstrip ())
55
+ )
48
56
items .extend ((
49
57
('Objects in policy "' + policy + '"' ,
50
58
prt_bytes (
Original file line number Diff line number Diff line change @@ -124,6 +124,32 @@ def test_stat_account_policy_stat(self):
124
124
"""
125
125
self .assertOut (expected )
126
126
127
+ def test_stat_account_policy_stat_with_container_counts (self ):
128
+ # stub head_account
129
+ stub_headers = {
130
+ 'x-account-container-count' : 42 ,
131
+ 'x-account-object-count' : 1000000 ,
132
+ 'x-account-bytes-used' : 2 ** 30 ,
133
+ 'x-account-storage-policy-nada-container-count' : 10 ,
134
+ 'x-account-storage-policy-nada-object-count' : 1000000 ,
135
+ 'x-account-storage-policy-nada-bytes-used' : 2 ** 30 ,
136
+ }
137
+ self .conn .head_account .return_value = stub_headers
138
+
139
+ with self .output_manager as output_manager :
140
+ items , headers = h .stat_account (self .conn , self .options )
141
+ h .print_account_stats (items , headers , output_manager )
142
+ expected = """
143
+ Account: a
144
+ Containers: 42
145
+ Objects: 1000000
146
+ Bytes: 1073741824
147
+ Containers in policy "nada": 10
148
+ Objects in policy "nada": 1000000
149
+ Bytes in policy "nada": 1073741824
150
+ """
151
+ self .assertOut (expected )
152
+
127
153
def test_stat_container_human (self ):
128
154
self .options ['human' ] = True
129
155
# stub head container request
You can’t perform that action at this time.
0 commit comments