def test_wrap_store_fs(valid_mock, settings, tmpdir): """Add a store_fs for a store that doesnt exist yet""" settings.POOTLE_FS_WORKING_PATH = os.path.join(str(tmpdir), "fs_file_test") valid_mock.side_effect = lambda x: x store_fs = MockStoreFS() fs_file = FSFile(store_fs) assert (fs_file.file_path == os.path.join(store_fs.project.local_fs_path, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.pootle_changed is False assert fs_file.fs_changed is False assert fs_file.store is None assert fs_file.store_exists is False assert fs_file.deserialize() is None assert fs_file.serialize() is None assert str(fs_file) == "<FSFile: %s::%s>" % (fs_file.pootle_path, fs_file.path) assert hash(fs_file) == hash( "%s::%s::%s::%s" % (fs_file.path, fs_file.pootle_path, fs_file.store_fs.last_sync_hash, fs_file.store_fs.last_sync_revision)) assert fs_file == FSFile(store_fs) testdict = {} testdict[fs_file] = "foo" testdict[FSFile(store_fs)] = "bar" assert len(testdict.keys()) == 1 assert testdict.values()[0] == "bar"
def test_wrap_store_fs(settings, tmpdir): """Add a store_fs for a store that doesnt exist yet """ pootle_fs_path = os.path.join(str(tmpdir), "fs_file_test") settings.POOTLE_FS_PATH = pootle_fs_path project = Project.objects.get(code="project0") pootle_path = "/language0/%s/example.po" % project.code fs_path = "/some/fs/example.po" store_fs = StoreFS.objects.create(pootle_path=pootle_path, path=fs_path) fs_file = FSFile(store_fs) assert (fs_file.file_path == os.path.join(pootle_fs_path, project.code, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.pootle_changed is False assert fs_file.fs_changed is False assert fs_file.store is None assert fs_file.store_exists is False assert fs_file.deserialize() is None assert fs_file.serialize() is None assert str(fs_file) == "<FSFile: %s::%s>" % (pootle_path, fs_path) assert hash(fs_file) == hash( "%s::%s::%s::%s" % (fs_file.path, fs_file.pootle_path, fs_file.store_fs.last_sync_hash, fs_file.store_fs.last_sync_revision)) assert fs_file == FSFile(store_fs) testdict = {} testdict[fs_file] = "foo" testdict[FSFile(store_fs)] = "bar" assert len(testdict.keys()) == 1 assert testdict.values()[0] == "bar"
def test_wrap_store_fs(valid_mock, settings, tmpdir): """Add a store_fs for a store that doesnt exist yet""" settings.POOTLE_FS_WORKING_PATH = os.path.join(str(tmpdir), "fs_file_test") valid_mock.side_effect = lambda x: x store_fs = MockStoreFS() fs_file = FSFile(store_fs) assert ( fs_file.file_path == os.path.join( store_fs.project.local_fs_path, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.pootle_changed is False assert fs_file.fs_changed is False assert fs_file.store is None assert fs_file.store_exists is False assert fs_file.deserialize() is None assert fs_file.serialize() is None assert str(fs_file) == "<FSFile: %s::%s>" % (fs_file.pootle_path, fs_file.path) assert hash(fs_file) == hash( "%s::%s::%s::%s" % (fs_file.path, fs_file.pootle_path, fs_file.store_fs.last_sync_hash, fs_file.store_fs.last_sync_revision)) assert fs_file == FSFile(store_fs) testdict = {} testdict[fs_file] = "foo" testdict[FSFile(store_fs)] = "bar" assert len(testdict.keys()) == 1 assert testdict.values()[0] == "bar"
def test_wrap_store_fs_with_store(settings, tmpdir, tp0_store): pootle_fs_path = os.path.join(str(tmpdir), "fs_file_test") settings.POOTLE_FS_PATH = pootle_fs_path fs_path = "/some/fs/example.po" store_fs = StoreFS.objects.create(path=fs_path, store=tp0_store) project = tp0_store.translation_project.project fs_file = FSFile(store_fs) assert (fs_file.file_path == os.path.join(pootle_fs_path, project.code, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.fs_changed is False assert fs_file.pootle_changed is True assert fs_file.store == tp0_store assert fs_file.store_exists is True serialized = fs_file.serialize() assert serialized assert serialized == tp0_store.serialize() assert fs_file.deserialize() is None
def test_wrap_store_fs_with_store(valid_mock): valid_mock.side_effect = lambda x: x store_mock = PropertyMock() store_mock.configure_mock(**{ "data.max_unit_revision": 23, "serialize.return_value": 73 }) store_fs = MockStoreFS() store_fs.store = store_mock fs_file = FSFile(store_fs) assert (fs_file.file_path == os.path.join(store_fs.project.local_fs_path, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.fs_changed is False assert fs_file.pootle_changed is True assert fs_file.store is store_mock assert fs_file.store_exists is True assert fs_file.serialize() == 73 assert fs_file.deserialize() is None
def test_wrap_store_fs(settings, tmpdir): """Add a store_fs for a store that doesnt exist yet """ pootle_fs_path = os.path.join(str(tmpdir), "fs_file_test") settings.POOTLE_FS_PATH = pootle_fs_path project = Project.objects.get(code="project0") pootle_path = "/language0/%s/example.po" % project.code fs_path = "/some/fs/example.po" store_fs = StoreFS.objects.create( pootle_path=pootle_path, path=fs_path) fs_file = FSFile(store_fs) assert ( fs_file.file_path == os.path.join( pootle_fs_path, project.code, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.pootle_changed is False assert fs_file.fs_changed is False assert fs_file.store is None assert fs_file.store_exists is False assert fs_file.deserialize() is None assert fs_file.serialize() is None assert str(fs_file) == "<FSFile: %s::%s>" % (pootle_path, fs_path) assert hash(fs_file) == hash( "%s::%s::%s::%s" % (fs_file.path, fs_file.pootle_path, fs_file.store_fs.last_sync_hash, fs_file.store_fs.last_sync_revision)) assert fs_file == FSFile(store_fs) testdict = {} testdict[fs_file] = "foo" testdict[FSFile(store_fs)] = "bar" assert len(testdict.keys()) == 1 assert testdict.values()[0] == "bar"
def test_wrap_store_fs_with_store(settings, tmpdir, tp0_store): settings.POOTLE_FS_WORKING_PATH = os.path.join(str(tmpdir), "fs_file_test") fs_path = "/some/fs/example.po" store_fs = StoreFS.objects.create( path=fs_path, store=tp0_store) project = tp0_store.translation_project.project fs_file = FSFile(store_fs) assert ( fs_file.file_path == os.path.join( settings.POOTLE_FS_WORKING_PATH, project.code, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.fs_changed is False assert fs_file.pootle_changed is True assert fs_file.store == tp0_store assert fs_file.store_exists is True serialized = fs_file.serialize() assert serialized assert serialized == tp0_store.serialize() assert fs_file.deserialize() is None
def test_wrap_store_fs_with_store(valid_mock): valid_mock.side_effect = lambda x: x store_mock = PropertyMock() store_mock.configure_mock( **{"data.max_unit_revision": 23, "serialize.return_value": 73}) store_fs = MockStoreFS() store_fs.store = store_mock fs_file = FSFile(store_fs) assert ( fs_file.file_path == os.path.join( store_fs.project.local_fs_path, store_fs.path.strip("/"))) assert fs_file.file_exists is False assert fs_file.latest_hash is None assert fs_file.fs_changed is False assert fs_file.pootle_changed is True assert fs_file.store is store_mock assert fs_file.store_exists is True assert fs_file.serialize() == 73 assert fs_file.deserialize() is None