forked from HearthSim/UnityPack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a unit test for extracting a single text asset, mostly as an example
closes HearthSim#107
- Loading branch information
Showing
4 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from .. import * | ||
import unittest | ||
from .. import load | ||
from pathlib import Path | ||
|
||
def get_bundle_fixture(name): | ||
return Path(__file__).parent / 'fixtures' / 'bundles' / name | ||
|
||
class TestReadAssetBundle(unittest.TestCase): | ||
def test_single_text_file(self): | ||
with get_bundle_fixture("single-text-file-2019.3.13f1-no-compression").open("rb") as f: | ||
bundle = load(f) | ||
self.assertEqual(bundle.name, "CAB-2c069a3745be5cfe0c630ceac750b567") | ||
self.assertFalse(bundle.compressed) | ||
self.assertEqual(len(bundle.assets), 1) | ||
asset = bundle.assets[0] | ||
self.assertEqual(len(asset.objects), 2) | ||
obj = list(asset.objects.items())[0][1] | ||
self.assertEqual(obj.type, "TextAsset") | ||
data = obj.read() | ||
self.assertEqual(data.name, "example") | ||
self.assertEqual(data.bytes, "ligma\n") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|