def test_should_download_if_config_exists_but_not_downloaded( self, download_manager: MagicMock, embedding_manager: EmbeddingManager): embedding_manager.download_and_install_embedding( EXTERNAL_TXT_URL_1) download_manager.reset_mock() assert embedding_manager.ensure_available( EXTERNAL_TXT_URL_1) == EMBEDDING_NAME_1 download_manager.download_if_url.assert_called_with( EXTERNAL_TXT_URL_1)
def test_should_download_and_install_embedding( self, download_manager: MagicMock, embedding_manager: EmbeddingManager, download_path_1: Path): embedding_manager.download_and_install_embedding( EXTERNAL_TXT_URL_1) download_manager.download_if_url.assert_called_with( EXTERNAL_TXT_URL_1) embedding_config = embedding_manager.get_embedding_config( EMBEDDING_NAME_1) assert embedding_config assert embedding_config['name'] == EMBEDDING_NAME_1 assert embedding_config['path'] == str(download_path_1)
def test_should_not_download_if_already_downloaded( self, download_manager: MagicMock, embedding_manager: EmbeddingManager): embedding_manager.download_and_install_embedding( EXTERNAL_TXT_URL_1) download_manager.reset_mock() embedding_config = embedding_manager.get_embedding_config( EMBEDDING_NAME_1) assert embedding_config Path(embedding_config['path']).touch() assert embedding_manager.ensure_available( EXTERNAL_TXT_URL_1) == EMBEDDING_NAME_1 download_manager.download_if_url.assert_not_called()
def test_should_unzip_mdb_embedding( self, download_manager: MagicMock, embedding_manager: EmbeddingManager): embedding_manager.download_and_install_embedding( EXTERNAL_MDB_GZ_URL_1) download_manager.download.assert_called_with( EXTERNAL_MDB_GZ_URL_1, local_file=str( embedding_manager.get_embedding_lmdb_cache_data_path( EMBEDDING_NAME_1))) embedding_config = embedding_manager.get_embedding_config( EMBEDDING_NAME_1) assert embedding_config assert embedding_config['name'] == EMBEDDING_NAME_1