Bring tests under typing checks, fix existing type errors.
This commit is contained in:
parent
6efd07d02f
commit
fa0b2bd6cd
@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from typing import Container, List, Dict, Any
|
from typing import Iterable, List, Dict, Any
|
||||||
|
|
||||||
|
|
||||||
# Supress custom handler tracebacks inside handler frames
|
# Supress custom handler tracebacks inside handler frames
|
||||||
@ -14,7 +14,7 @@ class ExtendedTestCase(unittest.TestCase):
|
|||||||
def verbose(self) -> bool:
|
def verbose(self) -> bool:
|
||||||
return ("-v" in sys.argv) or ("--verbose" in sys.argv)
|
return ("-v" in sys.argv) or ("--verbose" in sys.argv)
|
||||||
|
|
||||||
def assertItemsEqual(self, a: Container[Any], b: Container[Any]) -> None:
|
def assertItemsEqual(self, a: Iterable[Any], b: Iterable[Any]) -> None:
|
||||||
a_items = {x for x in a}
|
a_items = {x for x in a}
|
||||||
b_items = {x for x in b}
|
b_items = {x for x in b}
|
||||||
self.assertEqual(a_items, b_items)
|
self.assertEqual(a_items, b_items)
|
||||||
|
@ -15,10 +15,10 @@ class TestCardCipher(unittest.TestCase):
|
|||||||
for pair in test_ciphers:
|
for pair in test_ciphers:
|
||||||
inp = bytes(pair[0])
|
inp = bytes(pair[0])
|
||||||
out = bytes(pair[1])
|
out = bytes(pair[1])
|
||||||
encoded = CardCipher._encode(inp) # type: ignore
|
encoded = CardCipher._encode(inp)
|
||||||
self.assertEqual(encoded, out, f"Card encode {encoded} doesn't match expected {out}")
|
self.assertEqual(encoded, out, f"Card encode {encoded!r} doesn't match expected {out!r}")
|
||||||
decoded = CardCipher._decode(out) # type: ignore
|
decoded = CardCipher._decode(out)
|
||||||
self.assertEqual(decoded, inp, f"Card decode {decoded} doesn't match expected {inp}")
|
self.assertEqual(decoded, inp, f"Card decode {decoded!r} doesn't match expected {inp!r}")
|
||||||
|
|
||||||
def test_external_cipher(self) -> None:
|
def test_external_cipher(self) -> None:
|
||||||
test_cards = [
|
test_cards = [
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
|
from bemani.common import GameConstants
|
||||||
from bemani.data.mysql.game import GameData
|
from bemani.data.mysql.game import GameData
|
||||||
from bemani.tests.helpers import FakeCursor
|
from bemani.tests.helpers import FakeCursor
|
||||||
|
|
||||||
@ -13,20 +14,20 @@ class TestGameData(unittest.TestCase):
|
|||||||
|
|
||||||
# Verify that we catch incorrect input order
|
# Verify that we catch incorrect input order
|
||||||
with self.assertRaises(Exception) as context:
|
with self.assertRaises(Exception) as context:
|
||||||
game.put_time_sensitive_settings('game', 1, 'work', {'start_time': 12345, 'end_time': 12340})
|
game.put_time_sensitive_settings(GameConstants.BISHI_BASHI, 1, 'work', {'start_time': 12345, 'end_time': 12340})
|
||||||
self.assertTrue('Start time is greater than end time!' in str(context.exception))
|
self.assertTrue('Start time is greater than end time!' in str(context.exception))
|
||||||
|
|
||||||
# Verify that we catch events spanning no time
|
# Verify that we catch events spanning no time
|
||||||
with self.assertRaises(Exception) as context:
|
with self.assertRaises(Exception) as context:
|
||||||
game.put_time_sensitive_settings('game', 1, 'work', {'start_time': 12345, 'end_time': 12345})
|
game.put_time_sensitive_settings(GameConstants.BISHI_BASHI, 1, 'work', {'start_time': 12345, 'end_time': 12345})
|
||||||
self.assertTrue('This setting spans zero seconds!' in str(context.exception))
|
self.assertTrue('This setting spans zero seconds!' in str(context.exception))
|
||||||
|
|
||||||
# Verify that we ignore finding ourselves before updating
|
# Verify that we ignore finding ourselves before updating
|
||||||
game.execute = Mock(return_value=FakeCursor([{'start_time': 12345, 'end_time': 12346}]))
|
game.execute = Mock(return_value=FakeCursor([{'start_time': 12345, 'end_time': 12346}])) # type: ignore
|
||||||
game.put_time_sensitive_settings('game', 1, 'work', {'start_time': 12345, 'end_time': 12346})
|
game.put_time_sensitive_settings(GameConstants.BISHI_BASHI, 1, 'work', {'start_time': 12345, 'end_time': 12346})
|
||||||
|
|
||||||
# Verify that we catch events overlapping other events in the DB
|
# Verify that we catch events overlapping other events in the DB
|
||||||
game.execute = Mock(return_value=FakeCursor([{'start_time': 12345, 'end_time': 12350}]))
|
game.execute = Mock(return_value=FakeCursor([{'start_time': 12345, 'end_time': 12350}])) # type: ignore
|
||||||
with self.assertRaises(Exception) as context:
|
with self.assertRaises(Exception) as context:
|
||||||
game.put_time_sensitive_settings('game', 1, 'work', {'start_time': 12347, 'end_time': 12355})
|
game.put_time_sensitive_settings(GameConstants.BISHI_BASHI, 1, 'work', {'start_time': 12347, 'end_time': 12355})
|
||||||
self.assertTrue('This event overlaps an existing one with start time 12345 and end time 12350' in str(context.exception))
|
self.assertTrue('This event overlaps an existing one with start time 12345 and end time 12350' in str(context.exception))
|
||||||
|
@ -58,12 +58,12 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
JubeatProp._get_league_buckets(
|
JubeatProp._get_league_buckets(
|
||||||
[
|
[
|
||||||
(5, 12345),
|
(UserID(5), 12345),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
5,
|
UserID(5),
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
@ -74,17 +74,17 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
JubeatProp._get_league_buckets(
|
JubeatProp._get_league_buckets(
|
||||||
[
|
[
|
||||||
(5, 12345),
|
(UserID(5), 12345),
|
||||||
(7, 54321),
|
(UserID(7), 54321),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
7,
|
UserID(7),
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
5,
|
UserID(5),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -93,20 +93,20 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
JubeatProp._get_league_buckets(
|
JubeatProp._get_league_buckets(
|
||||||
[
|
[
|
||||||
(5, 12345),
|
(UserID(5), 12345),
|
||||||
(7, 54321),
|
(UserID(7), 54321),
|
||||||
(9, 33333),
|
(UserID(9), 33333),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
7,
|
UserID(7),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
9,
|
UserID(9),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
5,
|
UserID(5),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -115,34 +115,34 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
JubeatProp._get_league_buckets(
|
JubeatProp._get_league_buckets(
|
||||||
[
|
[
|
||||||
(5, 55555),
|
(UserID(5), 55555),
|
||||||
(7, 77777),
|
(UserID(7), 77777),
|
||||||
(9, 99999),
|
(UserID(9), 99999),
|
||||||
(1, 11111),
|
(UserID(1), 11111),
|
||||||
(6, 66666),
|
(UserID(6), 66666),
|
||||||
(8, 88888),
|
(UserID(8), 88888),
|
||||||
(2, 22222),
|
(UserID(2), 22222),
|
||||||
(3, 33333),
|
(UserID(3), 33333),
|
||||||
(10, 100000),
|
(UserID(10), 100000),
|
||||||
(4, 44444),
|
(UserID(4), 44444),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
10,
|
UserID(10),
|
||||||
9,
|
UserID(9),
|
||||||
8,
|
UserID(8),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
7,
|
UserID(7),
|
||||||
6,
|
UserID(6),
|
||||||
5,
|
UserID(5),
|
||||||
4,
|
UserID(4),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
3,
|
UserID(3),
|
||||||
2,
|
UserID(2),
|
||||||
1,
|
UserID(1),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -171,7 +171,7 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_scores(
|
JubeatProp._get_league_scores(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[(UserID(1337), {})],
|
[(UserID(1337), ValidatedDict())],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[(1337, 1368)],
|
[(1337, 1368)],
|
||||||
@ -193,7 +193,7 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_scores(
|
JubeatProp._get_league_scores(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[(UserID(1337), {})],
|
[(UserID(1337), ValidatedDict())],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[],
|
[],
|
||||||
@ -230,14 +230,14 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_absentees(
|
JubeatProp._get_league_absentees(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.assert_called_once_with(
|
data.local.user.get_achievements.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.reset_mock()
|
data.local.user.get_achievements.reset_mock()
|
||||||
|
|
||||||
@ -249,14 +249,14 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_absentees(
|
JubeatProp._get_league_absentees(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.assert_called_once_with(
|
data.local.user.get_achievements.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.reset_mock()
|
data.local.user.get_achievements.reset_mock()
|
||||||
|
|
||||||
@ -268,14 +268,14 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_absentees(
|
JubeatProp._get_league_absentees(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
),
|
),
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.assert_called_once_with(
|
data.local.user.get_achievements.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.reset_mock()
|
data.local.user.get_achievements.reset_mock()
|
||||||
|
|
||||||
@ -288,14 +288,14 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_absentees(
|
JubeatProp._get_league_absentees(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.assert_called_once_with(
|
data.local.user.get_achievements.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.reset_mock()
|
data.local.user.get_achievements.reset_mock()
|
||||||
|
|
||||||
@ -307,14 +307,14 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
JubeatProp._get_league_absentees(
|
JubeatProp._get_league_absentees(
|
||||||
data,
|
data,
|
||||||
999,
|
999,
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
),
|
),
|
||||||
[1337],
|
[UserID(1337)],
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.assert_called_once_with(
|
data.local.user.get_achievements.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
)
|
)
|
||||||
data.local.user.get_achievements.reset_mock()
|
data.local.user.get_achievements.reset_mock()
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
}))
|
}))
|
||||||
JubeatProp._modify_profile(
|
JubeatProp._modify_profile(
|
||||||
data,
|
data,
|
||||||
1337,
|
UserID(1337),
|
||||||
'demote',
|
'demote',
|
||||||
)
|
)
|
||||||
self.assertFalse(data.local.user.put_profile.called)
|
self.assertFalse(data.local.user.put_profile.called)
|
||||||
@ -342,7 +342,7 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
}))
|
}))
|
||||||
JubeatProp._modify_profile(
|
JubeatProp._modify_profile(
|
||||||
data,
|
data,
|
||||||
1337,
|
UserID(1337),
|
||||||
'promote',
|
'promote',
|
||||||
)
|
)
|
||||||
self.assertFalse(data.local.user.put_profile.called)
|
self.assertFalse(data.local.user.put_profile.called)
|
||||||
@ -355,13 +355,13 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
}))
|
}))
|
||||||
JubeatProp._modify_profile(
|
JubeatProp._modify_profile(
|
||||||
data,
|
data,
|
||||||
1337,
|
UserID(1337),
|
||||||
'promote',
|
'promote',
|
||||||
)
|
)
|
||||||
data.local.user.put_profile.assert_called_once_with(
|
data.local.user.put_profile.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
{
|
{
|
||||||
'league_class': 1,
|
'league_class': 1,
|
||||||
'league_subclass': 4,
|
'league_subclass': 4,
|
||||||
@ -382,13 +382,13 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
}))
|
}))
|
||||||
JubeatProp._modify_profile(
|
JubeatProp._modify_profile(
|
||||||
data,
|
data,
|
||||||
1337,
|
UserID(1337),
|
||||||
'demote',
|
'demote',
|
||||||
)
|
)
|
||||||
data.local.user.put_profile.assert_called_once_with(
|
data.local.user.put_profile.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
{
|
{
|
||||||
'league_class': 1,
|
'league_class': 1,
|
||||||
'league_subclass': 4,
|
'league_subclass': 4,
|
||||||
@ -413,13 +413,13 @@ class TestJubeatProp(unittest.TestCase):
|
|||||||
}))
|
}))
|
||||||
JubeatProp._modify_profile(
|
JubeatProp._modify_profile(
|
||||||
data,
|
data,
|
||||||
1337,
|
UserID(1337),
|
||||||
'demote',
|
'demote',
|
||||||
)
|
)
|
||||||
data.local.user.put_profile.assert_called_once_with(
|
data.local.user.put_profile.assert_called_once_with(
|
||||||
JubeatProp.game,
|
JubeatProp.game,
|
||||||
JubeatProp.version,
|
JubeatProp.version,
|
||||||
1337,
|
UserID(1337),
|
||||||
{
|
{
|
||||||
'league_class': 1,
|
'league_class': 1,
|
||||||
'league_subclass': 5,
|
'league_subclass': 5,
|
||||||
|
@ -3,6 +3,7 @@ import unittest
|
|||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
|
from bemani.common import GameConstants
|
||||||
from bemani.data.mysql.network import NetworkData
|
from bemani.data.mysql.network import NetworkData
|
||||||
from bemani.tests.helpers import FakeCursor
|
from bemani.tests.helpers import FakeCursor
|
||||||
|
|
||||||
@ -32,20 +33,20 @@ class TestNetworkData(unittest.TestCase):
|
|||||||
|
|
||||||
with freeze_time('2016-01-01'):
|
with freeze_time('2016-01-01'):
|
||||||
# Check for should schedule if nothing in DB
|
# Check for should schedule if nothing in DB
|
||||||
network.execute = Mock(return_value=FakeCursor([]))
|
network.execute = Mock(return_value=FakeCursor([])) # type: ignore
|
||||||
self.assertTrue(network.should_schedule('game', 1, 'work', 'daily'))
|
self.assertTrue(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'daily'))
|
||||||
self.assertTrue(network.should_schedule('game', 1, 'work', 'weekly'))
|
self.assertTrue(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'weekly'))
|
||||||
|
|
||||||
# Check for don't schedule if DB time is our current time
|
# Check for don't schedule if DB time is our current time
|
||||||
network.execute = Mock(return_value=FakeCursor([{'year': 2016, 'day': 1}]))
|
network.execute = Mock(return_value=FakeCursor([{'year': 2016, 'day': 1}])) # type: ignore
|
||||||
self.assertFalse(network.should_schedule('game', 1, 'work', 'daily'))
|
self.assertFalse(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'daily'))
|
||||||
|
|
||||||
network.execute = Mock(return_value=FakeCursor([{'year': None, 'day': 16797}]))
|
network.execute = Mock(return_value=FakeCursor([{'year': None, 'day': 16797}])) # type: ignore
|
||||||
self.assertFalse(network.should_schedule('game', 1, 'work', 'weekly'))
|
self.assertFalse(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'weekly'))
|
||||||
|
|
||||||
# Check for do schedule if DB time is older than our current time
|
# Check for do schedule if DB time is older than our current time
|
||||||
network.execute = Mock(return_value=FakeCursor([{'year': 2015, 'day': 365}]))
|
network.execute = Mock(return_value=FakeCursor([{'year': 2015, 'day': 365}])) # type: ignore
|
||||||
self.assertTrue(network.should_schedule('game', 1, 'work', 'daily'))
|
self.assertTrue(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'daily'))
|
||||||
|
|
||||||
network.execute = Mock(return_value=FakeCursor([{'year': None, 'day': 16790}]))
|
network.execute = Mock(return_value=FakeCursor([{'year': None, 'day': 16790}])) # type: ignore
|
||||||
self.assertTrue(network.should_schedule('game', 1, 'work', 'weekly'))
|
self.assertTrue(network.should_schedule(GameConstants.BISHI_BASHI, 1, 'work', 'weekly'))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# vim: set fileencoding=utf-8
|
# vim: set fileencoding=utf-8
|
||||||
|
from abc import ABC
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bemani.common import Parallel
|
from bemani.common import Parallel
|
||||||
@ -66,23 +67,27 @@ class TestParallel(unittest.TestCase):
|
|||||||
self.assertEqual(results, [20, -20, 4, -4, 2])
|
self.assertEqual(results, [20, -20, 4, -4, 2])
|
||||||
|
|
||||||
def test_class(self) -> None:
|
def test_class(self) -> None:
|
||||||
class A:
|
class Base(ABC):
|
||||||
|
def fun(self, x: int) -> int:
|
||||||
|
...
|
||||||
|
|
||||||
|
class A(Base):
|
||||||
def fun(self, x: int) -> int:
|
def fun(self, x: int) -> int:
|
||||||
return x * 10
|
return x * 10
|
||||||
|
|
||||||
class B:
|
class B(Base):
|
||||||
def fun(self, x: int) -> int:
|
def fun(self, x: int) -> int:
|
||||||
return x * 20
|
return x * 20
|
||||||
|
|
||||||
class C:
|
class C(Base):
|
||||||
def fun(self, x: int) -> int:
|
def fun(self, x: int) -> int:
|
||||||
return x * 30
|
return x * 30
|
||||||
|
|
||||||
class D:
|
class D(Base):
|
||||||
def fun(self, x: int) -> int:
|
def fun(self, x: int) -> int:
|
||||||
return x * 40
|
return x * 40
|
||||||
|
|
||||||
class E:
|
class E(Base):
|
||||||
def fun(self, x: int) -> int:
|
def fun(self, x: int) -> int:
|
||||||
return x * 50
|
return x * 50
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# vim: set fileencoding=utf-8
|
# vim: set fileencoding=utf-8
|
||||||
import unittest
|
import unittest
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from bemani.protocol import EAmuseProtocol, Node
|
from bemani.protocol import EAmuseProtocol, Node
|
||||||
|
|
||||||
@ -9,7 +8,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
# Define a function that just encrypts/decrypts and encode/decodes, verify
|
# Define a function that just encrypts/decrypts and encode/decodes, verify
|
||||||
# that we can get the same thing back.
|
# that we can get the same thing back.
|
||||||
def assertLoopback(self, root: Node) -> Optional[int]:
|
def assertLoopback(self, root: Node) -> None:
|
||||||
proto = EAmuseProtocol()
|
proto = EAmuseProtocol()
|
||||||
|
|
||||||
for encoding in [EAmuseProtocol.BINARY, EAmuseProtocol.XML]:
|
for encoding in [EAmuseProtocol.BINARY, EAmuseProtocol.XML]:
|
||||||
@ -36,7 +35,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
newroot = proto.decode('lz77', None, binary)
|
newroot = proto.decode('lz77', None, binary)
|
||||||
self.assertEqual(newroot, root, f"Round trip with {loop_name}, no encryption and lz77 compression doesn't match!")
|
self.assertEqual(newroot, root, f"Round trip with {loop_name}, no encryption and lz77 compression doesn't match!")
|
||||||
|
|
||||||
def test_game_packet1(self) -> Node:
|
def test_game_packet1(self) -> None:
|
||||||
root = Node.void('call')
|
root = Node.void('call')
|
||||||
root.set_attribute('model', 'M39:J:B:A:2014061900')
|
root.set_attribute('model', 'M39:J:B:A:2014061900')
|
||||||
root.set_attribute('srcid', '012010000000DEADBEEF')
|
root.set_attribute('srcid', '012010000000DEADBEEF')
|
||||||
@ -58,7 +57,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_game_packet2(self) -> Node:
|
def test_game_packet2(self) -> None:
|
||||||
root = Node.void('call')
|
root = Node.void('call')
|
||||||
root.set_attribute('model', 'LDJ:A:A:A:2015060700')
|
root.set_attribute('model', 'LDJ:A:A:A:2015060700')
|
||||||
root.set_attribute('srcid', '012010000000DEADBEEF')
|
root.set_attribute('srcid', '012010000000DEADBEEF')
|
||||||
@ -79,13 +78,13 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_game_packet3(self) -> Node:
|
def test_game_packet3(self) -> None:
|
||||||
root = Node.void('response')
|
root = Node.void('response')
|
||||||
root.add_child(Node.void('music'))
|
root.add_child(Node.void('music'))
|
||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_game_packet4(self) -> Node:
|
def test_game_packet4(self) -> None:
|
||||||
root = Node.void('response')
|
root = Node.void('response')
|
||||||
game = Node.void('game')
|
game = Node.void('game')
|
||||||
root.add_child(game)
|
root.add_child(game)
|
||||||
@ -111,7 +110,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_game_packet5(self) -> Node:
|
def test_game_packet5(self) -> None:
|
||||||
root = Node.void('call')
|
root = Node.void('call')
|
||||||
root.set_attribute('model', 'LDJ:A:A:A:2015060700')
|
root.set_attribute('model', 'LDJ:A:A:A:2015060700')
|
||||||
root.set_attribute('srcid', '012010000000DEADBEEF')
|
root.set_attribute('srcid', '012010000000DEADBEEF')
|
||||||
@ -271,7 +270,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_game_packet6(self) -> Node:
|
def test_game_packet6(self) -> None:
|
||||||
root = Node.void('response')
|
root = Node.void('response')
|
||||||
facility = Node.void('facility')
|
facility = Node.void('facility')
|
||||||
root.add_child(facility)
|
root.add_child(facility)
|
||||||
@ -327,7 +326,7 @@ class TestProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertLoopback(root)
|
self.assertLoopback(root)
|
||||||
|
|
||||||
def test_packet1(self) -> Node:
|
def test_packet1(self) -> None:
|
||||||
root = Node.void('test')
|
root = Node.void('test')
|
||||||
root.set_attribute('test', 'test string value')
|
root.set_attribute('test', 'test string value')
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ types-requests
|
|||||||
types-PyYAML
|
types-PyYAML
|
||||||
types-Werkzeug
|
types-Werkzeug
|
||||||
types-Flask
|
types-Flask
|
||||||
|
types-freezegun
|
||||||
flake8
|
flake8
|
||||||
typed-ast
|
typed-ast
|
||||||
freezegun
|
freezegun
|
||||||
|
@ -31,6 +31,12 @@ do
|
|||||||
cmdline+=("bemani.utils.$project")
|
cmdline+=("bemani.utils.$project")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for test in `find bemani/tests/ -name "test_*.py" | sed 's,.*/,,' | sed 's,\.py,,'`
|
||||||
|
do
|
||||||
|
cmdline+=('-m')
|
||||||
|
cmdline+=("bemani.tests.$test")
|
||||||
|
done
|
||||||
|
|
||||||
MYPYPATH=$(python -c "import os; print(os.path.realpath('.'))") mypy \
|
MYPYPATH=$(python -c "import os; print(os.path.realpath('.'))") mypy \
|
||||||
"${cmdline[@]}" \
|
"${cmdline[@]}" \
|
||||||
--warn-redundant-casts \
|
--warn-redundant-casts \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user