From 23c9ecc72a1610f7fd5eebea5a9808fd304a8b46 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Thu, 13 Sep 2018 14:00:59 -0500 Subject: [PATCH] Removed the catch all for exceptions in add_object. Exceptions will now raise out of that function. --- geoffrey/DatabaseInterface.py | 1 - geoffrey/DatabaseModels.py | 1 + geoffrey/tests/test_geoffreyDatabase.py | 8 ++++---- geoffrey/tests/test_minecraftInfoGrabber.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/geoffrey/DatabaseInterface.py b/geoffrey/DatabaseInterface.py index 5c578f3..6500095 100644 --- a/geoffrey/DatabaseInterface.py +++ b/geoffrey/DatabaseInterface.py @@ -57,7 +57,6 @@ class DatabaseInterface: mc_uuid = grab_UUID(player_name) try: player = self.find_player_by_mc_uuid(session, mc_uuid) - player.name = player_name except PlayerNotFound: player = Player(player_name, discord_uuid) self.database.add_object(session, player) diff --git a/geoffrey/DatabaseModels.py b/geoffrey/DatabaseModels.py index 406da9a..5513403 100644 --- a/geoffrey/DatabaseModels.py +++ b/geoffrey/DatabaseModels.py @@ -54,6 +54,7 @@ class GeoffreyDatabase: raise DatabaseValueError except: session.rollback() + raise Exception def query_by_filter(self, session, obj_type, *args, limit=10): filter_value = self.combine_filter(args) diff --git a/geoffrey/tests/test_geoffreyDatabase.py b/geoffrey/tests/test_geoffreyDatabase.py index 44a3e6f..0423d19 100644 --- a/geoffrey/tests/test_geoffreyDatabase.py +++ b/geoffrey/tests/test_geoffreyDatabase.py @@ -13,7 +13,7 @@ class TestGeoffreyDatabase(TestCase): self.interface = DatabaseInterface(self.bot_config, True) self.session = self.interface.database.Session() self.interface.database.clear_all(self.session) - self.owner = Player('BirbHD', '143072699567177728') + self.owner = Player('YMCA', '151081244824698880') self.loc = Location('test', 1, 3, self.owner, dimension='Nether') self.tunnel = Tunnel(self.owner, "west", 105, self.loc) @@ -38,7 +38,7 @@ class TestGeoffreyDatabase(TestCase): self.interface.database.add_object(self.session, self.owner) self.interface.database.add_object(self.session, self.tunnel) - uuid = grab_UUID('BirbHD') + uuid = grab_UUID('YMCA') expr = Player.mc_uuid == uuid p = self.interface.database.query_by_filter(self.session, Player, expr)[0] @@ -62,9 +62,9 @@ class TestGeoffreyDatabase(TestCase): expr = Location.owner == self.owner self.interface.database.delete_entry(self.session, Location, expr) - expr = Player.name == 'BirbHD' + expr = Player.name == 'YMCA' player = self.interface.database.query_by_filter(self.session, Player, expr)[0] - self.assertEqual(player.name, 'BirbHD') + self.assertEqual(player.name, 'YMCA') expr = Location.owner == player diff --git a/geoffrey/tests/test_minecraftInfoGrabber.py b/geoffrey/tests/test_minecraftInfoGrabber.py index 0334517..41bf5cc 100644 --- a/geoffrey/tests/test_minecraftInfoGrabber.py +++ b/geoffrey/tests/test_minecraftInfoGrabber.py @@ -6,13 +6,13 @@ from MinecraftAccountInfoGrabber import * class TestMinecraftInfoGrabber(TestCase): def test_handle_data(self): - self.assertEqual(grab_UUID('BirbHD'), 'fe7e84132570458892032b69ff188bc3') + self.assertEqual(grab_UUID('YMCA'), '5c084bd60c6a417ba084e2c5a382d0e1') def test_grab_playername(self): - self.assertEqual(grab_playername('01c29c443f8d4ab490a56919407a5bd2'), 'CoolBirb123') + self.assertEqual(grab_playername('5c084bd60c6a417ba084e2c5a382d0e1'), 'YMCA') def test_grab_playername_wrong_case(self): - self.assertEqual(grab_UUID('birbhd'), 'fe7e84132570458892032b69ff188bc3') + self.assertEqual(grab_UUID('ymca'), '5c084bd60c6a417ba084e2c5a382d0e1') def test_grab_invalid_player(self): self.assertRaises(UsernameLookupFailed, grab_UUID, 'lsdlkjsljglfjgldkj')