# Path: pytube/captions.py
# class Caption:
#     def __init__(self, caption_track: Dict):
#     def xml_captions(self) -> str:
#     def generate_srt_captions(self) -> str:
#     def float_to_srt_time_format(d: float) -> str:
#     def xml_caption_to_srt(self, xml_captions: str) -> str:
#     def download(
#         self,
#         title: str,
#         srt: bool = True,
#         output_path: Optional[str] = None,
#         filename_prefix: Optional[str] = None,
#     ) -> str:
#     def __repr__(self):
# 
# Path: pytube/query.py
# class CaptionQuery(Mapping):
#     """Interface for querying the available captions."""
# 
#     def __init__(self, captions: List[Caption]):
#         """Construct a :class:`Caption <Caption>`.
# 
#         param list captions:
#             list of :class:`Caption <Caption>` instances.
# 
#         """
#         self.lang_code_index = {c.code: c for c in captions}
# 
#     @deprecated(
#         "This object can be treated as a dictionary, i.e. captions['en']"
#     )
#     def get_by_language_code(
#         self, lang_code: str
#     ) -> Optional[Caption]:  # pragma: no cover
#         """Get the :class:`Caption <Caption>` for a given ``lang_code``.
# 
#         :param str lang_code:
#             The code that identifies the caption language.
#         :rtype: :class:`Caption <Caption>` or None
#         :returns:
#             The :class:`Caption <Caption>` matching the given ``lang_code`` or
#             None if it does not exist.
#         """
#         return self.lang_code_index.get(lang_code)
# 
#     @deprecated("This object can be treated as a dictionary")
#     def all(self) -> List[Caption]:  # pragma: no cover
#         """Get all the results represented by this query as a list.
# 
#         :rtype: list
# 
#         """
#         return list(self.lang_code_index.values())
# 
#     def __getitem__(self, i: str):
#         return self.lang_code_index[i]
# 
#     def __len__(self) -> int:
#         return len(self.lang_code_index)
# 
#     def __iter__(self):
#         return iter(self.lang_code_index.values())
# 
#     def __repr__(self) -> str:
#         return f"{self.lang_code_index}"


import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytube import Caption, CaptionQuery, captions



def test_float_to_srt_time_format():
    caption1 = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
    )
    assert caption1.float_to_srt_time_format(3.89) == "00:00:03,890"


def test_caption_query_sequence():
    caption1 = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
    )
    caption2 = Caption(
        {"url": "url2", "name": {"simpleText": "name2"}, "languageCode": "fr", "vssId": ".fr"}
    )

# Path: pytube/captions.py
# class Caption:
#     def __init__(self, caption_track: Dict):
#     def xml_captions(self) -> str:
#     def generate_srt_captions(self) -> str:
#     def float_to_srt_time_format(d: float) -> str:
#     def xml_caption_to_srt(self, xml_captions: str) -> str:
#     def download(
#         self,
#         title: str,
#         srt: bool = True,
#         output_path: Optional[str] = None,
#         filename_prefix: Optional[str] = None,
#     ) -> str:
#     def __repr__(self):
# 
# Path: pytube/query.py
# class CaptionQuery(Mapping):
#     """Interface for querying the available captions."""
# 
#     def __init__(self, captions: List[Caption]):
#         """Construct a :class:`Caption <Caption>`.
# 
#         param list captions:
#             list of :class:`Caption <Caption>` instances.
# 
#         """
#         self.lang_code_index = {c.code: c for c in captions}
# 
#     @deprecated(
#         "This object can be treated as a dictionary, i.e. captions['en']"
#     )
#     def get_by_language_code(
#         self, lang_code: str
#     ) -> Optional[Caption]:  # pragma: no cover
#         """Get the :class:`Caption <Caption>` for a given ``lang_code``.
# 
#         :param str lang_code:
#             The code that identifies the caption language.
#         :rtype: :class:`Caption <Caption>` or None
#         :returns:
#             The :class:`Caption <Caption>` matching the given ``lang_code`` or
#             None if it does not exist.
#         """
#         return self.lang_code_index.get(lang_code)
# 
#     @deprecated("This object can be treated as a dictionary")
#     def all(self) -> List[Caption]:  # pragma: no cover
#         """Get all the results represented by this query as a list.
# 
#         :rtype: list
# 
#         """
#         return list(self.lang_code_index.values())
# 
#     def __getitem__(self, i: str):
#         return self.lang_code_index[i]
# 
#     def __len__(self) -> int:
#         return len(self.lang_code_index)
# 
#     def __iter__(self):
#         return iter(self.lang_code_index.values())
# 
#     def __repr__(self) -> str:
#         return f"{self.lang_code_index}"


# Path: tests/test_captions.py
import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytube import Caption, CaptionQuery, captions




def test_float_to_srt_time_format():
    caption1 = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
    )
    assert caption1.float_to_srt_time_format(3.89) == "00:00:03,890"


def test_caption_query_sequence():
    caption1 = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
    )
    caption2 = Caption(
        {"url": "url2", "name": {"simpleText": "name2"}, "languageCode": "fr", "vssId": ".fr"}
    )

    caption_query = CaptionQuery(captions=[caption1, caption2])