Ejemplo n.º 1
0
 def test_deployment_type_optional(self):
     """Charm has valid deployment with empty type."""
     linter = Mock()
     charm = {
         'deployment': {
             'service': 'omit',
             'min-version': "1.15.0",
         }
     }
     validate_deployment(charm, linter)
     self.assertFalse(linter.err.called)
Ejemplo n.º 2
0
 def test_invalid_deployment(self):
     """Charm has invalid deployment."""
     linter = Mock()
     charm = {
         'deployment': [],
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('deployment: must be a dict of config'),
     ], any_order=True)
Ejemplo n.º 3
0
 def test_deployment(self):
     """Charm has valid deployment."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': 'stateful',
             'service': 'omit',
             'min-version': "1.15.0",
         }
     }
     validate_deployment(charm, linter)
     self.assertFalse(linter.err.called)
Ejemplo n.º 4
0
 def test_deployment_invalid_min_version(self):
     """Charm has the invalid deployment min-version."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': 'stateful',
             'service': 'omit',
             'min-version': 1.15,
         }
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call("deployment.deployment.min-version: 1.15 is not a string: {'min-version': ''}"),
     ], any_order=True)
Ejemplo n.º 5
0
 def test_deployment_unsupported_service(self):
     """Charm has the unsupported deployment service."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': 'stateful',
             'service': 'foo',
             'min-version': "1.15.0",
         }
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('deployment.deployment.service: "foo" is not one of loadbalancer, cluster, omit'),
     ], any_order=True)
Ejemplo n.º 6
0
 def test_deployment_unsupported_type(self):
     """Charm has the unsupported deployment type."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': 'foo',
             'service': 'omit',
             'min-version': "1.15.0",
         }
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('deployment.deployment.type: "foo" is not one of stateless, stateful, daemon'),
     ], any_order=True)
Ejemplo n.º 7
0
 def test_deployment_invalid_type(self):
     """Charm has the invalid deployment type."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': True,
             'service': 'omit',
             'min-version': "1.15.0",
         }
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call("deployment.deployment.type: True is not a string: {'type': ''}"),
     ], any_order=True)
Ejemplo n.º 8
0
 def test_deployment_unsupported_field(self):
     """Charm has the invalid deployment field."""
     linter = Mock()
     charm = {
         'deployment': {
             'type': 'stateful',
             'service': 'omit',
             'min-version': "1.15.0",
             'unknow-field': 'xxx',
         }
     }
     validate_deployment(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('deployment.deployment: Unrecognized keys in mapping: "{\'unknow-field\': \'xxx\'}"'),
     ], any_order=True)