示例#1
0
    def test_get_file_data_not_binary(self):
        result = None
        with patch.object(pathlib.Path, 'is_file') as mock_exists:
            mock_exists.return_value = True

            with patch('builtins.open', unittest.mock.mock_open(read_data=file_data)) as open_file:
                result = AT.get_file_data("file", False)

        self.assertEqual(result, file_data)
def main():
    # read file data
    file_data = AT.get_file_data('./data/data2.txt', False)

    # encode data and serialize compressed data
    encoded_data = AT.Encoder(file_data).encode()
    AT.serialize_data('output/output.bin', encoded_data, True)

    # decode data and serialize original data
    decoded_data = AT.Decoder(encoded_data).decode()
    AT.serialize_data('output/output.txt', decoded_data, False)
示例#3
0
    def test_get_file_data_raises_exception(self):
        with self.assertRaises(FileNotFoundError) as context:
            AT.get_file_data("file", False)

        self.assertTrue('Filename specified (file) does not exist.' in str(context.exception))