예제 #1
0
    def test_get_binary(self):
        tf = tempfile.NamedTemporaryFile(mode='rb')
        with open(tf.name, 'wb') as f:
            f.write(b'blah')

        c = Connector('/')
        actual = c.get(name=tf.name).read()
        expected = b'blah'
        tf.close()
        self.assertEqual(actual, expected, 'should read a temp file')
예제 #2
0
    def test_get(self):
        tf = tempfile.NamedTemporaryFile()
        expected = b'blah'
        tf.file.write(expected)  # type: ignore
        tf.file.flush()  # type: ignore

        c = Connector(path='/')
        actual = c.get(name=tf.name).read()
        tf.close()
        self.assertEqual(actual, expected, 'should read a temp file')
예제 #3
0
 def test_get_bad_name_binary(self):
     c = Connector(binary=True)
     actual = c.get(name='non-existing-file').read()
     expected = b''
     self.assertEqual(actual, expected, 'should return an empty string')
예제 #4
0
 def test_get_bad_name(self):
     # @TODO I don't remember why we thought this was a good idea.
     # We should probably raise most Exceptions.
     c = Connector(binary=False)
     actual = c.get(name='non-existing-file').read()
     self.assertEqual(actual, '', 'should return an empty string')