Beispiel #1
0
    def test_var_choices(self):
        class Context:
            def resolve(self, _):
                # pylint: disable=no-self-use
                return 'z'

        self.assertEqual(
            phase3.resolve_value(
                types.Value(types.Var('foo', choices=('x', 'z'))), Context()),
            'z')
        with self.assertRaises(phase2.InvalidChoice):
            phase3.resolve_value(
                types.Value(types.Var('foo', choices=('x', 'y'))), Context())
Beispiel #2
0
    def test_path(self):
        class Context:
            def repath(self, path):
                # pylint: disable=no-self-use
                return os.path.join('/root', path)

        self.assertEqual(
            phase3.resolve_value(types.Value('foo', is_path=True), Context()),
            '/root/foo')
Beispiel #3
0
    def test_call(self):
        this = self

        class Context:
            def call(self, call):
                # pylint: disable=no-self-use
                this.assertEqual(call.name, 'foo')
                return 'myResult'

        self.assertEqual(
            phase3.resolve_value(types.Value(types.Call('foo', ())),
                                 Context()), 'myResult')
Beispiel #4
0
    def test_var(self):
        this = self

        class Context:
            def resolve(self, var):
                # pylint: disable=no-self-use
                this.assertEqual(var.name, 'foo')
                return 'myResult'

        self.assertEqual(
            phase3.resolve_value(types.Value(types.Var('foo')), Context()),
            'myResult')
Beispiel #5
0
 def test_invalid_value(self):
     with self.assertRaises(TypeError):
         phase3.resolve_value(types.Value(object()), None)
Beispiel #6
0
 def test_string(self):
     self.assertEqual(phase3.resolve_value(types.Value('foo'), None), 'foo')
Beispiel #7
0
 def test_bool(self):
     self.assertEqual(phase3.resolve_value(types.Value(True), None), True)
     self.assertEqual(phase3.resolve_value(types.Value(False), None), False)
Beispiel #8
0
 def test_none(self):
     self.assertIs(phase3.resolve_value(types.Value(None), None), None)