Exemple #1
0
    def test_as_data_use_handler(self):
        self.handler.returns.as_data = 'spam'
        arg = Arg(self.param, 'eggs', self.handler, israw=False)
        data = arg.as_data()

        self.assertEqual(data, 'spam')
        self.assertEqual(self.stub.calls, [
            ('validate', ('eggs',), {}),
            ('as_data', ('eggs',), {}),
        ])
Exemple #2
0
    def test_as_data_use_coerced(self):
        handler = FakeHandler()
        other = Arg(Parameter(str, handler), 'spam', handler, israw=False)
        handler.returns.as_data = 'spam'
        arg = Arg(Parameter(str, self.handler), other, self.handler,
                  israw=False)
        data = arg.as_data(other)

        self.assertEqual(data, 'spam')
        self.assertEqual(self.stub.calls, [])
        self.assertEqual(handler.stub.calls, [
            ('validate', ('spam',), {}),
            ('as_data', ('spam',), {}),
        ])