Example #1
0
 def test_get_current_usage_str_multi_id(self):
     limit = AwsLimit('limitname', self.mock_svc, 3, 1, 2)
     limit._add_current_usage(4, resource_id='foo4bar')
     limit._add_current_usage(3, resource_id='foo3bar')
     limit._add_current_usage(2, resource_id='foo2bar')
     assert limit.get_current_usage_str() == 'max: foo4bar=4 (foo2bar=2, ' \
         'foo3bar=3, foo4bar=4)'
Example #2
0
 def test_add_current_usage(self):
     limit = AwsLimit('limitname', self.mock_svc, 3, 1, 2)
     assert limit._current_usage == []
     limit._add_current_usage(2)
     assert len(limit.get_current_usage()) == 1
     assert limit._current_usage[0].get_value() == 2
     limit._add_current_usage(4)
     assert len(limit.get_current_usage()) == 2
     assert limit._current_usage[1].get_value() == 4
Example #3
0
 def test_str(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4)
     assert limit.get_current_usage_str() == '4'
Example #4
0
 def test_str_id(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4, resource_id='foobar')
     assert limit.get_current_usage_str() == 'foobar=4'
Example #5
0
 def test_get_current_usage_str_id(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4, resource_id='foobar')
     assert limit.get_current_usage_str() == 'foobar=4'
Example #6
0
 def test_get_current_usage_str(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4)
     assert limit.get_current_usage_str() == '4'
Example #7
0
 def test_str_multi(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4)
     limit._add_current_usage(3)
     limit._add_current_usage(2)
     assert limit.get_current_usage_str() == 'max: 4 (2, 3, 4)'
Example #8
0
 def test_get_current_usage_str_multi(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4)
     limit._add_current_usage(3)
     limit._add_current_usage(2)
     assert limit.get_current_usage_str() == 'max: 4 (2, 3, 4)'
Example #9
0
 def test_get_current_usage_str_multi_id(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     limit._add_current_usage(4, resource_id='foo4bar')
     limit._add_current_usage(3, resource_id='foo3bar')
     limit._add_current_usage(2, resource_id='foo2bar')
     assert limit.get_current_usage_str() == 'max: foo4bar=4 (foo2bar=2, ' \
         'foo3bar=3, foo4bar=4)'
Example #10
0
 def test_add_current_usage(self):
     limit = AwsLimit(
         'limitname',
         self.mock_svc,
         3,
         1,
         2
     )
     assert limit._current_usage == []
     limit._add_current_usage(2)
     assert len(limit.get_current_usage()) == 1
     assert limit._current_usage[0].get_value() == 2
     limit._add_current_usage(4)
     assert len(limit.get_current_usage()) == 2
     assert limit._current_usage[1].get_value() == 4