Exemplo n.º 1
0
    def test_validate_derived_extra_output(self):
        uo = usage.UsageOutputNames(x='goodbye', y='hello')

        with self.assertRaisesRegex(ValueError, 'SDK.*extra output.*peanut'):
            uo.validate_computed({'x': 'val',
                                  'y': 'val',
                                  'peanut': 'val'})
Exemplo n.º 2
0
    def test_validate_derived_missing_output(self):
        uo = usage.UsageOutputNames(x='goodbye', y='hello')

        with self.assertRaisesRegex(ValueError, 'SDK.*missing output.*y'):
            uo.validate_computed({'x': 'val'})
Exemplo n.º 3
0
    def test_validate_extra_output(self):
        uo = usage.UsageOutputNames(y='goodbye', a='hello', peanut='noeyes')

        with self.assertRaisesRegex(ValueError, 'Extra output.*peanut'):
            uo.validate(self.signature)
Exemplo n.º 4
0
    def test_validate_missing_output(self):
        uo = usage.UsageOutputNames(y='hello')

        with self.assertRaisesRegex(ValueError, 'Missing output.*a'):
            uo.validate(self.signature)
Exemplo n.º 5
0
 def test_invalid_init(self):
     with self.assertRaisesRegex(TypeError, 'key.*foo.*string, not.*bool'):
         usage.UsageOutputNames(foo=True)
Exemplo n.º 6
0
 def test_successful_init(self):
     obs = usage.UsageOutputNames(foo='bar')
     self.assertEqual(['foo'], list(obs.values.keys()))
     self.assertEqual(['bar'], list(obs.values.values()))
Exemplo n.º 7
0
 def test_validate_invalid_inputs(self):
     ua = usage.UsageAction(plugin_id='dummy_plugin',
                            action_id='concatenate_ints')
     with self.assertRaisesRegex(TypeError, 'instance of UsageInputs'):
         ua.validate({}, usage.UsageOutputNames())