--[[----------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2016 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

	-- WF.core.os
local WFPlatformInfo = require 'WFPlatformInfo'

	-- WF.core.self_test
local WFRxTestCase = require "WFRxTestCase"

	-- WF.core.utils
local KSIdGenerator = require 'KSIdGenerator'

	-- WF.lrmobile
local LrmConfig = require 'LrmConfig'
local LrmLibraryAlbumStatusModelImp = require 'LrmLibraryAlbumStatusModelImp'
local LrmCatalogTestHelper = require 'LrmCatalogTestHelper'

--------------------------------------------------------------------------------

local LrmLibraryAlbumStatusModelImpTest = {}

--------------------------------------------------------------------------------

local catalog

--------------------------------------------------------------------------------

local function makeLocalOnly( withProxy, withOriginal )
	if WFPlatformInfo.isiOS then
		local localOnly = {
			files = {
				thumbnail2x = {
					path = 'blobs/...',
					contentId = '16b97d9d9e3042d09633c3878622d48a',
				},
				preview = {
					path = 'blobs/...',
					contentId = '16b97d9d9e3042d09633c3878622d48a',
				},
				proxy = {
					path = 'Originals',
				}
			}
		}
		
		if withProxy then
			localOnly.files.proxy = {
				path = 'Originals',
			}
		end
		
		if withOriginal then
			localOnly.files.master = {
				path = 'Originals/...',
			}
		end
		
		return localOnly
	else
		local localOnly = {
			thumbnail2x = {
				md5 = 'hash',
				revId = '16b97d9d9e3042d09633c3878622d48a',
			},
			preview = {
				md5 = 'hash',
				revId = '16b97d9d9e3042d09633c3878622d48a',
			},
			proxy = {
				filePath = '/path',
			}
		}
		
		if withProxy then
			localOnly.proxy = {
				filePath = '/path'
			}
		end
		
		if withOriginal then
			localOnly.originalFilePath = '/path'
		end
		
		return localOnly
	end
end

--------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.setUp()

	catalog = LrmCatalogTestHelper.makeCatalogService()

end

--------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.tearDown()

	catalog:close()

end

--------------------------------------------------------------------------------

-- @mark unsynchronizedAssetsForAlbum tests

--------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.rxTestBinaryDownloadProgressPreferredProxy( rxTest )

	rxTest:setTimeLimit( 5 )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	local obs = rxTest:observe( LrmLibraryAlbumStatusModelImp.unsynchronizedAssetsForAlbum( parentModel, albumId, LrmConfig.StrategyPreferProxy ).value )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album',
				_id = albumId,
				subtype = 'collection',
				name = 'test album',
				_localOnly = {
					useOffline = true,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album_asset',
				_id = albumAssetId,
				album = {
					id = albumId,
				},
				asset = {
					id = assetId,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
					},
				}
			},
			':ignore:' )

		obs:expectData( 1 )

		rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_localOnly = makeLocalOnly( true, false ),
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
						[ '/rels/master' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/master'
						},
					},
				}
			},
			':ignore:' )

		obs:expectData( 0 )

end

--------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.rxTestBinaryDownloadProgressPreferredMaster( rxTest )

	rxTest:setTimeLimit( 5 )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	local obs = rxTest:observe( LrmLibraryAlbumStatusModelImp.unsynchronizedAssetsForAlbum( parentModel, albumId, LrmConfig.StrategyPreferMaster ).value )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album',
				_id = albumId,
				subtype = 'collection',
				name = 'test album',
				_localOnly = {
					useOffline = true,
				}
			},
			':ignore:' )


	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album_asset',
				_id = albumAssetId,
				album = {
					id = albumId,
				},
				asset = {
					id = assetId,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
						[ '/rels/master' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/master'
						},
					},
				}
			},
			':ignore:' )

	obs:expectData( 1 )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'asset',
			_id = assetId,
			subtype = 'image',
			_localOnly = makeLocalOnly( true, true ),
			_serverProvidedMetadata = {
				links = {
					[ '/rels/rendition_type/thumbnail2x' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/rendition_type/2048' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/proxy_type/2560' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
					},
					[ '/rels/master' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/master'
					},
				},
			}
		},
		':ignore:' )

	obs:expectData( 0 )

end

----------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.rxTestBinaryDownloadProgressPreferredMasterWithProxyOnly( rxTest )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	local obs = rxTest:observe( LrmLibraryAlbumStatusModelImp.unsynchronizedAssetsForAlbum( parentModel, albumId, LrmConfig.StrategyPreferMaster ).value )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'album',
			_id = albumId,
			subtype = 'collection',
			name = 'test album',
			_localOnly = {
				useOffline = true,
			}
		},
		':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'album_asset',
			_id = albumAssetId,
			album = {
				id = albumId,
			},
			asset = {
				id = assetId,
			},
		},
		':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'asset',
			_id = assetId,
			subtype = 'image',
			_serverProvidedMetadata = {
				links = {
					[ '/rels/rendition_type/thumbnail2x' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/rendition_type/2048' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/proxy_type/2560' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
					},
				},
			}
		},
		':ignore:' )

	obs:expectData( 1 )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'asset',
			_id = assetId,
			_localOnly  = makeLocalOnly( true, false ),
			_serverProvidedMetadata = {
				links = {
					[ '/rels/rendition_type/thumbnail2x' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/rendition_type/2048' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/proxy_type/2560' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
					},
				},
			}
		},
		':ignore:' )

	obs:expectData( 0 )

end

----------------------------------------------------------------------------------
--
---- @mark missingCacheSizeForAlbum tests
--
----------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.rxTestMissingCacheSizeOnlyProxy( rxTest )

	rxTest:setTimeLimit( 5 )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album',
				_id = albumId,
				subtype = 'collection',
				name = 'test album',
				_localOnly = {
					useOffline = true,
				}
			},
			':ignore:' )


	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album_asset',
				_id = albumAssetId,
				album = {
					id = albumId,
				},
				asset = {
					id = assetId,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
					},
				}
			},
			':ignore:' )


	local obs = rxTest:observe( LrmLibraryAlbumStatusModelImp.missingCacheSizeForAlbum( parentModel, albumId, LrmConfig.StrategyPreferProxy ).value )

	obs:expectData( 1841516 )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_localOnly = makeLocalOnly( true, false ),
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
						[ '/rels/master' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/master'
						},
					},
				}
			},
			':ignore:' )

	obs:expectData( 0 )

end

----------------------------------------------------------------------------------
--
function LrmLibraryAlbumStatusModelImpTest.rxTestMissingCacheSizeMasterAndProxy( rxTest )

	rxTest:setTimeLimit( 5 )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album',
				_id = albumId,
				subtype = 'collection',
				name = 'test album',
				_localOnly = {
					useOffline = true,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
						[ '/rels/master' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
					},
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album_asset',
				_id = albumAssetId,
				album = {
					id = albumId,
				},
				asset = {
					id = assetId,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				subtype = 'image',
				_serverProvidedMetadata = {
					links = {
						[ '/rels/rendition_type/thumbnail2x' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/rendition_type/2048' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
						},
						[ '/rels/proxy_type/2560' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
						[ '/rels/master' ] = {
							href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
						},
					},
				}
			},
			':ignore:' )

	local obsMaster = rxTest:observe( LrmLibraryAlbumStatusModelImp.missingCacheSizeForAlbum( parentModel, albumId, LrmConfig.StrategyPreferMaster ).value )

	obsMaster:expectData( 21481344 ) --  = thumbnail + preview + proxy + master (jrechtie: StrategyPreferMaster changed meaning, now includes proxy)

	local obsProxy = rxTest:observe( LrmLibraryAlbumStatusModelImp.missingCacheSizeForAlbum( parentModel, albumId, LrmConfig.StrategyPreferProxy ).value )

	obsProxy:expectData( 1841516 )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
			type = 'asset',
			_id = assetId,
			subtype = 'image',
			_localOnly  = makeLocalOnly( true, false ),
			_serverProvidedMetadata = {
				links = {
					[ '/rels/rendition_type/thumbnail2x' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/rendition_type/2048' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/renditions/835c23790d534b28b8b7bb99740d13ba',
					},
					[ '/rels/proxy_type/2560' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/proxies/a5429e4c4bc7402bb8fb9102dbde4317'
					},
					[ '/rels/master' ] = {
						href = '/v1.0/catalogs/f50509f546184519afa38d4e55e442fc/assets/496e4bec7eff1bee558b4760ae00efa3/revisions/16b97d9d9e3042d09633c3878622d48a/master'
					},
				},
			}
		},
		':ignore:' )

	obsMaster:expectData( 20971520 )

	obsProxy:expectData( 0 )

end

--------------------------------------------------------------------------------

function LrmLibraryAlbumStatusModelImpTest.rxTestBinaryDownloadProgressRedacted( rxTest )

	rxTest:setTimeLimit( 5 )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local albumAssetId = KSIdGenerator.uuidInLowercaseHex()

	local parentModel = {
		catalog = catalog,
	}

	local obs = rxTest:observe( LrmLibraryAlbumStatusModelImp.unsynchronizedAssetsForAlbum( parentModel, albumId, LrmConfig.StrategyPreferProxy ).value )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album',
				_id = albumId,
				subtype = 'collection',
				name = 'test album',
				_localOnly = {
					useOffline = true,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'album_asset',
				_id = albumAssetId,
				album = {
					id = albumId,
				},
				asset = {
					id = assetId,
				}
			},
			':ignore:' )

	rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				type = 'asset',
				_id = assetId,
				_spaceId = "cc5b58f1c79544f6abcb2ee50e3297b9",
				subtype = 'image',
				_serverProvidedMetadata = {
					base = "https://photos.adobe.io/v2/spaces/cc5b58f1c79544f6abcb2ee50e3297b9/",
					links = {
						[ "/rels/master" ] = {
							content_type = "image/jpeg",
							exists = true
						},
						[ "/rels/proxy_type/2560" ] = {
							exists = true
						},
						[ "/rels/rendition_type/2048" ] = {
							href = "/v2/spaces/cc5b58f1c79544f6abcb2ee50e3297b9/assets/f63baa7eda254f668b876d000118b00e/revisions/666f265f27c44fc18ad1773319168ffa/renditions/758559a07063312d398fa4e86db148a8"
						},
						[ "/rels/rendition_type/thumbnail2x" ] = {
							href = "/v2/spaces/cc5b58f1c79544f6abcb2ee50e3297b9/assets/f63baa7eda254f668b876d000118b00e/revisions/666f265f27c44fc18ad1773319168ffa/renditions/97c370e7e21bda1b4f4ee7f700ef9159"
						},
						self = {
							href = "/v2/spaces/cc5b58f1c79544f6abcb2ee50e3297b9/updates/14beacbc0f0e92bae0ddfe90f0bdc548"
						}
					},
				},
			},
			':ignore:' )

		obs:expectData( 1 )

		rxTest:expectSingleValue( catalog:docStore():applyOverlay {
				_id = assetId,
				_localOnly = makeLocalOnly( false, false ),
			},
			':ignore:' )

		obs:expectData( 0 )

end

--------------------------------------------------------------------------------

return WFRxTestCase.wrapSuite( LrmLibraryAlbumStatusModelImpTest )

