Example #1
0
 def test_get_limits_again(self):
     """test that existing limits dict is returned on subsequent calls"""
     mock_limits = Mock()
     cls = _WorkspacesService(21, 43)
     cls.limits = mock_limits
     res = cls.get_limits()
     assert res == mock_limits
Example #2
0
 def test_init(self):
     """test __init__()"""
     cls = _WorkspacesService(21, 43)
     assert cls.service_name == 'Workspaces'
     assert cls.api_name == 'workspaces'
     assert cls.conn is None
     assert cls.warning_threshold == 21
     assert cls.critical_threshold == 43
Example #3
0
 def test_get_limits(self):
     cls = _WorkspacesService(21, 43)
     cls.limits = {}
     res = cls.get_limits()
     assert sorted(res.keys()) == sorted([
         # TODO fill in limits here
         'SomeLimitNameHere',
     ])
     for name, limit in res.items():
         assert limit.service == cls
         assert limit.def_warning_threshold == 21
         assert limit.def_critical_threshold == 43
Example #4
0
 def test_find_usage(self):
     # put boto3 responses in response_fixtures.py, then do something like:
     # response = result_fixtures.EBS.test_find_usage_ebs
     mock_conn = Mock()
     # TODO: DI
     mock_conn.some_method.return_value =  {
         'Workspaces': [
             {
                 'WorkspaceId': 'string',
                 'DirectoryId': 'string',
                 'UserName': '******',
                 'IpAddress': 'string',
                 'State': 'PENDING'|'AVAILABLE'|'IMPAIRED'|'UNHEALTHY'|'REBOOTING'|'STARTING'|'REBUILDING'|'MAINTENANCE'|'TERMINATING'|'TERMINATED'|'SUSPENDED'|'UPDATING'|'STOPPING'|'STOPPED'|'ERROR',
                 'BundleId': 'string',
                 'SubnetId': 'string',
                 'ErrorMessage': 'string',
                 'ErrorCode': 'string',
                 'ComputerName': 'string',
                 'VolumeEncryptionKey': 'string',
                 'UserVolumeEncryptionEnabled': True|False,
                 'RootVolumeEncryptionEnabled': True|False,
                 'WorkspaceProperties': {
                     'RunningMode': 'AUTO_STOP'|'ALWAYS_ON',
                     'RunningModeAutoStopTimeoutInMinutes': 123,
                     'RootVolumeSizeGib': 123,
                     'UserVolumeSizeGib': 123,
                     'ComputeTypeName': 'VALUE'|'STANDARD'|'PERFORMANCE'|'POWER'|'GRAPHICS'
                 },
                 'ModificationStates': [
                     {
                         'Resource': 'ROOT_VOLUME'|'USER_VOLUME'|'COMPUTE_TYPE',
                         'State': 'UPDATE_INITIATED'|'UPDATE_IN_PROGRESS'
                     },
                 ]
             },
         ],
         'NextToken': 'string'
     }
     with patch('%s.connect' % pb) as mock_connect:
         cls = _WorkspacesService(21, 43)
         cls.conn = mock_conn
         assert cls._have_usage is False
         cls.find_usage()
     assert mock_connect.mock_calls == [call()]
     assert cls._have_usage is True
     assert mock_conn.mock_calls == [call.some_method()]
Example #5
0
 def test_required_iam_permissions(self):
     cls = _WorkspacesService(21, 43)
     assert cls.required_iam_permissions() == [
         # TODO - permissions here
     ]