1616import mock
1717from mock import call
1818
19+ from osc_lib .cli import format_columns
1920from osc_lib import exceptions
2021from osc_lib import utils
2122
@@ -31,16 +32,16 @@ class TestAggregate(compute_fakes.TestComputev2):
3132 'availability_zone' ,
3233 'hosts' ,
3334 'id' ,
34- 'metadata' ,
3535 'name' ,
36+ 'properties' ,
3637 )
3738
3839 data = (
3940 fake_ag .availability_zone ,
40- fake_ag .hosts ,
41+ format_columns . ListColumn ( fake_ag .hosts ) ,
4142 fake_ag .id ,
42- fake_ag .metadata ,
4343 fake_ag .name ,
44+ format_columns .DictColumn (fake_ag .metadata ),
4445 )
4546
4647 def setUp (self ):
@@ -75,7 +76,7 @@ def test_aggregate_add_host(self):
7576 self .aggregate_mock .add_host .assert_called_once_with (self .fake_ag ,
7677 parsed_args .host )
7778 self .assertEqual (self .columns , columns )
78- self .assertEqual (self .data , data )
79+ self .assertItemEqual (self .data , data )
7980
8081
8182class TestAggregateCreate (TestAggregate ):
@@ -99,7 +100,7 @@ def test_aggregate_create(self):
99100 self .aggregate_mock .create .assert_called_once_with (parsed_args .name ,
100101 None )
101102 self .assertEqual (self .columns , columns )
102- self .assertEqual (self .data , data )
103+ self .assertItemEqual (self .data , data )
103104
104105 def test_aggregate_create_with_zone (self ):
105106 arglist = [
@@ -116,7 +117,7 @@ def test_aggregate_create_with_zone(self):
116117 self .aggregate_mock .create .assert_called_once_with (parsed_args .name ,
117118 parsed_args .zone )
118119 self .assertEqual (self .columns , columns )
119- self .assertEqual (self .data , data )
120+ self .assertItemEqual (self .data , data )
120121
121122 def test_aggregate_create_with_property (self ):
122123 arglist = [
@@ -135,7 +136,7 @@ def test_aggregate_create_with_property(self):
135136 self .aggregate_mock .set_metadata .assert_called_once_with (
136137 self .fake_ag , parsed_args .property )
137138 self .assertEqual (self .columns , columns )
138- self .assertEqual (self .data , data )
139+ self .assertItemEqual (self .data , data )
139140
140141
141142class TestAggregateDelete (TestAggregate ):
@@ -234,8 +235,11 @@ class TestAggregateList(TestAggregate):
234235 TestAggregate .fake_ag .id ,
235236 TestAggregate .fake_ag .name ,
236237 TestAggregate .fake_ag .availability_zone ,
237- {key : value for key , value in TestAggregate .fake_ag .metadata .items ()
238- if key != 'availability_zone' },
238+ format_columns .DictColumn ({
239+ key : value
240+ for key , value in TestAggregate .fake_ag .metadata .items ()
241+ if key != 'availability_zone'
242+ }),
239243 ), )
240244
241245 def setUp (self ):
@@ -250,7 +254,7 @@ def test_aggregate_list(self):
250254 columns , data = self .cmd .take_action (parsed_args )
251255
252256 self .assertEqual (self .list_columns , columns )
253- self .assertEqual (self .list_data , tuple (data ))
257+ self .assertItemEqual (self .list_data , tuple (data ))
254258
255259 def test_aggregate_list_with_long (self ):
256260 arglist = [
@@ -263,7 +267,7 @@ def test_aggregate_list_with_long(self):
263267 columns , data = self .cmd .take_action (parsed_args )
264268
265269 self .assertEqual (self .list_columns_long , columns )
266- self .assertEqual (self .list_data_long , tuple (data ))
270+ self .assertListItemEqual (self .list_data_long , tuple (data ))
267271
268272
269273class TestAggregateRemoveHost (TestAggregate ):
@@ -290,7 +294,7 @@ def test_aggregate_add_host(self):
290294 self .aggregate_mock .remove_host .assert_called_once_with (
291295 self .fake_ag , parsed_args .host )
292296 self .assertEqual (self .columns , columns )
293- self .assertEqual (self .data , data )
297+ self .assertItemEqual (self .data , data )
294298
295299
296300class TestAggregateSet (TestAggregate ):
@@ -440,13 +444,14 @@ class TestAggregateShow(TestAggregate):
440444
441445 data = (
442446 TestAggregate .fake_ag .availability_zone ,
443- TestAggregate .fake_ag .hosts ,
447+ format_columns . ListColumn ( TestAggregate .fake_ag .hosts ) ,
444448 TestAggregate .fake_ag .id ,
445449 TestAggregate .fake_ag .name ,
446- utils .format_dict (
447- {key : value
448- for key , value in TestAggregate .fake_ag .metadata .items ()
449- if key != 'availability_zone' }),
450+ format_columns .DictColumn ({
451+ key : value
452+ for key , value in TestAggregate .fake_ag .metadata .items ()
453+ if key != 'availability_zone'
454+ }),
450455 )
451456
452457 def setUp (self ):
@@ -467,7 +472,7 @@ def test_aggregate_show(self):
467472 self .aggregate_mock .get .assert_called_once_with (parsed_args .aggregate )
468473
469474 self .assertEqual (self .columns , columns )
470- self .assertEqual (self .data , data )
475+ self .assertItemEqual (self .data , tuple ( data ) )
471476
472477
473478class TestAggregateUnset (TestAggregate ):
0 commit comments