mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2026-02-12 15:05:41 -05:00
Added some basic tests for the commonkeys and nus modules
This commit is contained in:
12
test/__init__.py
Normal file
12
test/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# "__init__.py" from libWiiPy by NinjaCheetah & Contributors
|
||||
# https://github.com/NinjaCheetah/libWiiPy
|
||||
#
|
||||
# Complete set of tests to be run.
|
||||
|
||||
import unittest
|
||||
|
||||
from .title.commonkeys_test import *
|
||||
from .title.nus_test import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
0
test/title/__init__.py
Normal file
0
test/title/__init__.py
Normal file
21
test/title/commonkeys_test.py
Normal file
21
test/title/commonkeys_test.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# "commonkeys_test.py" from libWiiPy by NinjaCheetah & Contributors
|
||||
# https://github.com/NinjaCheetah/libWiiPy
|
||||
|
||||
import unittest
|
||||
|
||||
from libWiiPy import title
|
||||
|
||||
|
||||
class TestCommonKeys(unittest.TestCase):
|
||||
def test_common(self):
|
||||
self.assertEqual(title.get_common_key(0), b'\xeb\xe4*"^\x85\x93\xe4H\xd9\xc5Es\x81\xaa\xf7')
|
||||
|
||||
def test_korean(self):
|
||||
self.assertEqual(title.get_common_key(1), b'c\xb8+\xb4\xf4aN.\x13\xf2\xfe\xfb\xbaL\x9b~')
|
||||
|
||||
def test_vwii(self):
|
||||
self.assertEqual(title.get_common_key(2), b'0\xbf\xc7n|\x19\xaf\xbb#\x1630\xce\xd7\xc2\x8d')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
67
test/title/nus_test.py
Normal file
67
test/title/nus_test.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# "nus_test.py" from libWiiPy by NinjaCheetah & Contributors
|
||||
# https://github.com/NinjaCheetah/libWiiPy
|
||||
|
||||
import hashlib
|
||||
import unittest
|
||||
|
||||
import libWiiPy
|
||||
|
||||
|
||||
class TestNUSDownloads(unittest.TestCase):
|
||||
def test_download_title(self):
|
||||
title = libWiiPy.title.download_title("0000000100000002", 513)
|
||||
title_hash = hashlib.sha1(title.dump_wad()).hexdigest()
|
||||
self.assertEqual(title_hash, "c5e25fdb1ae6921597058b9f07045be0b003c550")
|
||||
title = libWiiPy.title.download_title("0000000100000002", 513, wiiu_endpoint=True)
|
||||
title_hash = hashlib.sha1(title.dump_wad()).hexdigest()
|
||||
self.assertEqual(title_hash, "c5e25fdb1ae6921597058b9f07045be0b003c550")
|
||||
|
||||
def test_download_tmd(self):
|
||||
tmd = libWiiPy.title.download_tmd("0000000100000002", 513)
|
||||
tmd_hash = hashlib.sha1(tmd).hexdigest()
|
||||
self.assertEqual(tmd_hash, "e8f9657d591b305e300c109b5641630aa4e2318b")
|
||||
tmd = libWiiPy.title.download_tmd("0000000100000002", 513, wiiu_endpoint=True)
|
||||
tmd_hash = hashlib.sha1(tmd).hexdigest()
|
||||
self.assertEqual(tmd_hash, "e8f9657d591b305e300c109b5641630aa4e2318b")
|
||||
with self.assertRaises(ValueError):
|
||||
libWiiPy.title.download_tmd("TEST_STRING")
|
||||
|
||||
def test_download_ticket(self):
|
||||
ticket = libWiiPy.title.download_ticket("0000000100000002")
|
||||
ticket_hash = hashlib.sha1(ticket).hexdigest()
|
||||
self.assertEqual(ticket_hash, "7076891f96ad3e4a6148a4a308e4a12fc72cc4b5")
|
||||
ticket = libWiiPy.title.download_ticket("0000000100000002", wiiu_endpoint=True)
|
||||
ticket_hash = hashlib.sha1(ticket).hexdigest()
|
||||
self.assertEqual(ticket_hash, "7076891f96ad3e4a6148a4a308e4a12fc72cc4b5")
|
||||
with self.assertRaises(ValueError):
|
||||
libWiiPy.title.download_ticket("TEST_STRING")
|
||||
|
||||
def test_download_cert(self):
|
||||
cert = libWiiPy.title.download_cert()
|
||||
self.assertIsNotNone(cert)
|
||||
cert = libWiiPy.title.download_cert(wiiu_endpoint=True)
|
||||
self.assertIsNotNone(cert)
|
||||
|
||||
def test_download_content(self):
|
||||
content = libWiiPy.title.download_content("0000000100000002", 150)
|
||||
content_hash = hashlib.sha1(content).hexdigest()
|
||||
self.assertEqual(content_hash, "1f10abe6517d29950aa04c71b264c18d204ed363")
|
||||
content = libWiiPy.title.download_content("0000000100000002", 150, wiiu_endpoint=True)
|
||||
content_hash = hashlib.sha1(content).hexdigest()
|
||||
self.assertEqual(content_hash, "1f10abe6517d29950aa04c71b264c18d204ed363")
|
||||
with self.assertRaises(ValueError):
|
||||
libWiiPy.title.download_content("TEST_STRING", 150)
|
||||
with self.assertRaises(ValueError):
|
||||
libWiiPy.title.download_content("0000000100000002", -1)
|
||||
|
||||
def test_download_contents(self):
|
||||
tmd = libWiiPy.title.TMD()
|
||||
tmd.load(libWiiPy.title.download_tmd("0000000100000002"))
|
||||
contents = libWiiPy.title.download_contents("0000000100000002", tmd)
|
||||
self.assertIsNotNone(contents)
|
||||
contents = libWiiPy.title.download_contents("0000000100000002", tmd, wiiu_endpoint=True)
|
||||
self.assertIsNotNone(contents)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user