def test_payloads_without_defs(self):
     """Charm has payloads key but no definitions."""
     linter = Mock()
     charm = {"payloads": {}}
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([call("payloads: must be a dictionary of payload definitions")], any_order=True)
 def test_payloads_unknown_keys(self):
     """Charm has payloads with illegal keys."""
     linter = Mock()
     charm = {"payloads": {"vm": {"type": "kvm", "unknown": "invalid key"}}}
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls(
         [call("payloads.vm: Unrecognized keys in mapping: " "\"{'unknown': 'invalid key'}\"")], any_order=True
     )
 def test_payloads_invalid_values(self):
     """Charm has payloads with invalid values."""
     linter = Mock()
     charm = {"payloads": {"buzz": {"type": "dockerdockerdocker"}}}
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls(
         [call('payloads.buzz.type: "dockerdockerdocker" is not one of ' "kvm, docker")], any_order=True
     )
 def test_payloads_without_defs(self):
     """Charm has payloads key but no definitions."""
     linter = Mock()
     charm = {'payloads': {}}
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('payloads: must be a dictionary of payload definitions'),
     ],
                                 any_order=True)
Beispiel #5
0
 def test_minimal_payloads_config(self):
     """Charm has the minimum allowed payloads configuration."""
     linter = Mock()
     charm = {
         'payloads': {
             'test': {
                 'type': 'docker',
             }
         }
     }
     validate_payloads(charm, linter)
     self.assertFalse(linter.err.called)
Beispiel #6
0
 def test_complete_payloads_config(self):
     """Charm has payloads using all types."""
     linter = Mock()
     charm = {
         'payloads': {
             'vm': {
                 'type': 'kvm',
             },
             'app-container': {
                 'type': 'docker',
             },
         }
     }
     validate_payloads(charm, linter)
     self.assertFalse(linter.err.called)
Beispiel #7
0
 def test_payloads_invalid_values(self):
     """Charm has payloads with invalid values."""
     linter = Mock()
     charm = {
         'payloads': {
             'buzz': {
                 'type': 'dockerdockerdocker',
             },
         }
     }
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('payloads.buzz.type: "dockerdockerdocker" is not one of '
              'kvm, docker'),
     ], any_order=True)
Beispiel #8
0
 def test_payloads_unknown_keys(self):
     """Charm has payloads with illegal keys."""
     linter = Mock()
     charm = {
         'payloads': {
             'vm': {
                 'type': 'kvm',
                 'unknown': 'invalid key',
             },
         }
     }
     validate_payloads(charm, linter)
     self.assertEqual(linter.err.call_count, 1)
     linter.err.assert_has_calls([
         call('payloads.vm: Unrecognized keys in mapping: '
              '"{\'unknown\': \'invalid key\'}"'),
     ], any_order=True)
 def test_payloads_proof_extensions(self):
     """Charm has payloads with proof extensions."""
     linter = Mock()
     charm = {
         'payloads': {
             'vm': {
                 'type': 'kvm',
                 'unknown': 'invalid key',
             },
         }
     }
     extensions = [{
         'name': 'unknown',
         'type': 'String',
     }]
     validate_payloads(charm, linter, extensions)
     self.assertEqual(linter.err.call_args_list, [])
 def test_payloads_proof_extensions(self):
     """Charm has payloads with proof extensions."""
     linter = Mock()
     charm = {
         'payloads': {
             'vm': {
                 'type': 'kvm',
                 'unknown': 'invalid key',
             },
         }
     }
     extensions = [
         {
             'name': 'unknown',
             'type': 'String',
         }
     ]
     validate_payloads(charm, linter, extensions)
     self.assertEqual(linter.err.call_args_list, [])
Beispiel #11
0
 def test_complete_payloads_config(self):
     """Charm has payloads using all types."""
     linter = Mock()
     charm = {"payloads": {"vm": {"type": "kvm"}, "app-container": {"type": "docker"}}}
     validate_payloads(charm, linter)
     self.assertFalse(linter.err.called)
Beispiel #12
0
 def test_minimal_payloads_config(self):
     """Charm has the minimum allowed payloads configuration."""
     linter = Mock()
     charm = {"payloads": {"test": {"type": "docker"}}}
     validate_payloads(charm, linter)
     self.assertFalse(linter.err.called)