def test_bad_inputs(self) -> None:

        test_cases = [
            "",
            "www.facebook.com",
            "aaaa",
        ]

        for x in test_cases:
            with self.assertRaises(ValueError):
                transform_file_path(x)
    def test_path_format(self) -> None:

        test_cases = [
            "https://s3.Region.amazonaws.com/bucket-name/key-name",
            "https://s3.us-west-2.amazonaws.com/fbpcs-github-e2e/lift/results/partner_expected_result.json",
            "https://s3.us-west-2.amazonaws.com/fbpcs-github-e2e/lift/results/Uppercase!(/partner_expected_result.json",
        ]
        expected_results = [
            "https://bucket-name.s3.Region.amazonaws.com/key-name",
            "https://fbpcs-github-e2e.s3.us-west-2.amazonaws.com/lift/results/partner_expected_result.json",
            "https://fbpcs-github-e2e.s3.us-west-2.amazonaws.com/lift/results/Uppercase!(/partner_expected_result.json",
        ]

        for x, y in zip(test_cases, expected_results):
            self.assertEqual(transform_file_path(x), y)
    def test_virtual_hosted_format(self) -> None:

        test_cases = [
            "https://bucket-name.s3.Region.amazonaws.com/key-name",
            "https://fbpcs-github-e2e.s3.us-west-2.amazonaws.com/lift/results/partner_expected_result.json",
            "https://s3-s3-amazonaws-com-name.s3.Region.amazonaws.com/us-west-s3S3amazoncom/-name",  # contrived, 'worst' case example
            "https://bucket-name-more-dashes.s3.us-east-1.amazonaws.com/Capital!(/LETTERS/06/12/976e100-75ig-4fjfjfcee-aaaa3l-f36a9e258.csv",
        ]
        expected_results = [
            "https://bucket-name.s3.Region.amazonaws.com/key-name",
            "https://fbpcs-github-e2e.s3.us-west-2.amazonaws.com/lift/results/partner_expected_result.json",
            "https://s3-s3-amazonaws-com-name.s3.Region.amazonaws.com/us-west-s3S3amazoncom/-name",
            "https://bucket-name-more-dashes.s3.us-east-1.amazonaws.com/Capital!(/LETTERS/06/12/976e100-75ig-4fjfjfcee-aaaa3l-f36a9e258.csv",
        ]

        for x, y in zip(test_cases, expected_results):
            self.assertEqual(transform_file_path(x), y)
def transform_path(path_to_check: str) -> str:
    """
    Checks that a path is a valid file or a valid S3 path.
    If necessary, S3 path will be re-formated into the  “virtual-hosted-style access” format

    Arg:
        path_to_check: string containing file or S3 path

    Returns:
        a string valid file path or a valid S3 path
    """
    # If the file exists on the local system,
    # the path is good and nothing else to do
    if os.path.exists(path_to_check):
        return path_to_check
    # Otherwise, check if the path is an S3 path and
    # carry out any necessary transformation into virtual-hosted format
    s3_path = transform_file_path(path_to_check)
    return s3_path