Removed the catch all for exceptions in add_object. Exceptions will now raise out of that function.

doc_update
Joey Hines 2018-09-13 14:00:59 -05:00
parent 18ec866fb0
commit 23c9ecc72a
4 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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')