Exemplo n.º 1
0
    def test_handler_b64(self, content_mock):
        plain = u'Hello, world'
        encoded = base64.b64encode(plain.encode('utf8'))

        content_mock.return_value = plain
        out = FileLookup.handle(u'base64:file://tmp/test')
        self.assertEqual(encoded, out)
Exemplo n.º 2
0
    def test_handler_b64(self, content_mock):
        plain = u'Hello, world'
        encoded = base64.b64encode(plain.encode('utf8'))

        content_mock.return_value = plain
        out = FileLookup.handle(u'base64:file://tmp/test')
        self.assertEqual(encoded, out)
Exemplo n.º 3
0
    def test_handler_parameterized_b64(self, content_mock, codec_mock):
        result = mock.Mock()
        codec_mock.return_value = result

        out = FileLookup.handle(u'parameterized-b64:file://tmp/test')
        codec_mock.assert_called_once_with(content_mock.return_value, True)

        self.assertEqual(result, out)
Exemplo n.º 4
0
    def test_handler_parameterized_b64(self, content_mock, codec_mock):
        result = mock.Mock()
        codec_mock.return_value = result

        out = FileLookup.handle(u'parameterized-b64:file://tmp/test')
        codec_mock.assert_called_once_with(content_mock.return_value, True)

        self.assertEqual(result, out)
Exemplo n.º 5
0
 def test_unknown_codec(self, _):
     with self.assertRaises(KeyError):
         FileLookup.handle(u'bad:file://tmp/test')
Exemplo n.º 6
0
 def test_handler_plain(self, _):
     out = FileLookup.handle(u'plain:file://tmp/test')
     self.assertEqual(u'Hello, world', out)
Exemplo n.º 7
0
 def test_file_loaded(self, content_mock):
     FileLookup.handle(u'plain:file://tmp/test')
     content_mock.assert_called_with(u'file://tmp/test')
Exemplo n.º 8
0
 def test_unknown_codec(self, _):
     with self.assertRaises(KeyError):
         FileLookup.handle(u'bad:file://tmp/test')
Exemplo n.º 9
0
 def test_handler_plain(self, _):
     out = FileLookup.handle(u'plain:file://tmp/test')
     self.assertEqual(u'Hello, world', out)
Exemplo n.º 10
0
 def test_file_loaded(self, content_mock):
     FileLookup.handle(u'plain:file://tmp/test')
     content_mock.assert_called_with(u'file://tmp/test')