# Path: terminaltables/width_and_alignment.py
# def align_and_pad_cell(string, align, inner_dimensions, padding, space=' '):
#     """Align a string horizontally and vertically. Also add additional padding in both dimensions.
# 
#     :param str string: Input string to operate on.
#     :param tuple align: Tuple that contains one of left/center/right and/or top/middle/bottom.
#     :param tuple inner_dimensions: Width and height ints to expand string to without padding.
#     :param iter padding: Number of space chars for left, right, top, and bottom (4 ints).
#     :param str space: Character to use as white space for resizing/padding (use single visible chars only).
# 
#     :return: Padded cell split into lines.
#     :rtype: list
#     """
#     if not hasattr(string, 'splitlines'):
#         string = str(string)
# 
#     # Handle trailing newlines or empty strings, str.splitlines() does not satisfy.
#     lines = string.splitlines() or ['']
#     if string.endswith('\n'):
#         lines.append('')
# 
#     # Vertically align and pad.
#     if 'bottom' in align:
#         lines = ([''] * (inner_dimensions[1] - len(lines) + padding[2])) + lines + ([''] * padding[3])
#     elif 'middle' in align:
#         delta = inner_dimensions[1] - len(lines)
#         lines = ([''] * (delta // 2 + delta % 2 + padding[2])) + lines + ([''] * (delta // 2 + padding[3]))
#     else:
#         lines = ([''] * padding[2]) + lines + ([''] * (inner_dimensions[1] - len(lines) + padding[3]))
# 
#     # Horizontally align and pad.
#     for i, line in enumerate(lines):
#         new_width = inner_dimensions[0] + len(line) - visible_width(line)
#         if 'right' in align:
#             lines[i] = line.rjust(padding[0] + new_width, space) + (space * padding[1])
#         elif 'center' in align:
#             lines[i] = (space * padding[0]) + line.center(new_width, space) + (space * padding[1])
#         else:
#             lines[i] = (space * padding[0]) + line.ljust(new_width + padding[1], space)
# 
#     return lines


import pytest
from colorama import Fore
from colorclass import Color
from termcolor import colored
from terminaltables.width_and_alignment import align_and_pad_cell
    ('a\nb\nc', 'bottom', ['.......', '.a.....', '.b.....', '.c.....', '.......']),
    ('test', 'bottom', ['.......', '.......', '.......', '.test..', '.......']),

    ('', 'middle', ['.......', '.......', '.......', '.......', '.......']),
    ('\n', 'middle', ['.......', '.......', '.......', '.......', '.......']),
    ('a\nb\nc', 'middle', ['.......', '.a.....', '.b.....', '.c.....', '.......']),
    ('test', 'middle', ['.......', '.......', '.test..', '.......', '.......']),

    (
        u'蓝色\nשלום\nمعرب',
        '',
        ['.......', u'.蓝色..', u'.\u05e9\u05dc\u05d5\u05dd..', u'.\u0645\u0639\u0631\u0628..', '.......']
    ),

    (
        '\n'.join((Color('{blue}Test{/blue}'), Fore.BLUE + 'Test' + Fore.RESET, colored('Test', 'blue'))),
        '',
        ['.......', '.\x1b[34mTest\x1b[39m..', '.\x1b[34mTest\x1b[39m..', '.\x1b[34mTest\x1b[0m..', '.......']
    ),

    # (Color('{blue}A\nB{/blue}'), '', '.......\n.\x1b[34mA\x1b[39m.....\n.\x1b[34mB\x1b[39m.....\n.......\n.......'),

])
def test_odd_width_height_pad_space(string, align, expected):
    """Test odd number width, height, padding, and dots for whitespaces.

    :param str string: String to test.
    :param str align: Alignment in any dimension but one at a time.
    :param list expected: Expected output string.
    """

# Path: terminaltables/width_and_alignment.py
# def align_and_pad_cell(string, align, inner_dimensions, padding, space=' '):
#     """Align a string horizontally and vertically. Also add additional padding in both dimensions.
# 
#     :param str string: Input string to operate on.
#     :param tuple align: Tuple that contains one of left/center/right and/or top/middle/bottom.
#     :param tuple inner_dimensions: Width and height ints to expand string to without padding.
#     :param iter padding: Number of space chars for left, right, top, and bottom (4 ints).
#     :param str space: Character to use as white space for resizing/padding (use single visible chars only).
# 
#     :return: Padded cell split into lines.
#     :rtype: list
#     """
#     if not hasattr(string, 'splitlines'):
#         string = str(string)
# 
#     # Handle trailing newlines or empty strings, str.splitlines() does not satisfy.
#     lines = string.splitlines() or ['']
#     if string.endswith('\n'):
#         lines.append('')
# 
#     # Vertically align and pad.
#     if 'bottom' in align:
#         lines = ([''] * (inner_dimensions[1] - len(lines) + padding[2])) + lines + ([''] * padding[3])
#     elif 'middle' in align:
#         delta = inner_dimensions[1] - len(lines)
#         lines = ([''] * (delta // 2 + delta % 2 + padding[2])) + lines + ([''] * (delta // 2 + padding[3]))
#     else:
#         lines = ([''] * padding[2]) + lines + ([''] * (inner_dimensions[1] - len(lines) + padding[3]))
# 
#     # Horizontally align and pad.
#     for i, line in enumerate(lines):
#         new_width = inner_dimensions[0] + len(line) - visible_width(line)
#         if 'right' in align:
#             lines[i] = line.rjust(padding[0] + new_width, space) + (space * padding[1])
#         elif 'center' in align:
#             lines[i] = (space * padding[0]) + line.center(new_width, space) + (space * padding[1])
#         else:
#             lines[i] = (space * padding[0]) + line.ljust(new_width + padding[1], space)
# 
#     return lines


# Path: tests/test_width_and_alignment/test_align_and_pad_cell.py
import pytest
from colorama import Fore
from colorclass import Color
from termcolor import colored
from terminaltables.width_and_alignment import align_and_pad_cell

    ('a\nb\nc', 'bottom', ['.......', '.a.....', '.b.....', '.c.....', '.......']),
    ('test', 'bottom', ['.......', '.......', '.......', '.test..', '.......']),

    ('', 'middle', ['.......', '.......', '.......', '.......', '.......']),
    ('\n', 'middle', ['.......', '.......', '.......', '.......', '.......']),
    ('a\nb\nc', 'middle', ['.......', '.a.....', '.b.....', '.c.....', '.......']),
    ('test', 'middle', ['.......', '.......', '.test..', '.......', '.......']),

    (
        u'蓝色\nשלום\nمعرب',
        '',
        ['.......', u'.蓝色..', u'.\u05e9\u05dc\u05d5\u05dd..', u'.\u0645\u0639\u0631\u0628..', '.......']
    ),

    (
        '\n'.join((Color('{blue}Test{/blue}'), Fore.BLUE + 'Test' + Fore.RESET, colored('Test', 'blue'))),
        '',
        ['.......', '.\x1b[34mTest\x1b[39m..', '.\x1b[34mTest\x1b[39m..', '.\x1b[34mTest\x1b[0m..', '.......']
    ),

    # (Color('{blue}A\nB{/blue}'), '', '.......\n.\x1b[34mA\x1b[39m.....\n.\x1b[34mB\x1b[39m.....\n.......\n.......'),

])
def test_odd_width_height_pad_space(string, align, expected):
    """Test odd number width, height, padding, and dots for whitespaces.

    :param str string: String to test.
    :param str align: Alignment in any dimension but one at a time.
    :param list expected: Expected output string.
    """

    actual = align_and_pad_cell(string, (align,), (5, 3), (1, 1, 1, 1), '.')