From 18ec866fb026558091c4617841f43a234f022c41 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Thu, 13 Sep 2018 13:28:18 -0500 Subject: [PATCH] Fixed issue with adding a tunnel without a location in the database. --- geoffrey/Commands.py | 2 ++ geoffrey/cogs/Add_Commands.py | 3 +++ geoffrey/tests/test_commands.py | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/geoffrey/Commands.py b/geoffrey/Commands.py index e2ffb70..4345d58 100644 --- a/geoffrey/Commands.py +++ b/geoffrey/Commands.py @@ -83,6 +83,8 @@ class Commands: if location_name is None: location_list = self.interface.find_location_by_owner(session, player) + if len(location_list) == 0: + raise NoLocationsInDatabase if len(location_list) > 1: raise EntryNameNotUniqueError diff --git a/geoffrey/cogs/Add_Commands.py b/geoffrey/cogs/Add_Commands.py index 1e0737a..debf160 100644 --- a/geoffrey/cogs/Add_Commands.py +++ b/geoffrey/cogs/Add_Commands.py @@ -100,6 +100,9 @@ class Add_Commands: except LocationLookUpError: await ctx.send('{}, you do not have a location called **{}**.'.format( ctx.message.author.mention, loc_name)) + except NoLocationsInDatabase: + await ctx.send('{}, you do not have a location in the database.'.format( + ctx.message.author.mention, loc_name)) except LocationHasTunnelError: await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name)) except TunnelInitError: diff --git a/geoffrey/tests/test_commands.py b/geoffrey/tests/test_commands.py index 5a46575..1fbf41f 100644 --- a/geoffrey/tests/test_commands.py +++ b/geoffrey/tests/test_commands.py @@ -140,6 +140,10 @@ class TestCommands(TestCase): def test_tunnel(self): self.commands.register('BirbHD', '143072699567177728') + + self.assertRaises(NoLocationsInDatabase, self.commands.add_tunnel, "soUTH", 50, None, + discord_uuid='143072699567177728') + self.commands.add_shop(0, 0, shop_name='test shop', discord_uuid='143072699567177728') self.commands.add_tunnel("soUTH", 50, None, discord_uuid='143072699567177728')