Fixed issue with adding a tunnel without a location in the database.

doc_update
Joey Hines 2018-09-13 13:28:18 -05:00
parent fcafb1d141
commit 18ec866fb0
3 changed files with 9 additions and 0 deletions

View File

@ -83,6 +83,8 @@ class Commands:
if location_name is None: if location_name is None:
location_list = self.interface.find_location_by_owner(session, player) location_list = self.interface.find_location_by_owner(session, player)
if len(location_list) == 0:
raise NoLocationsInDatabase
if len(location_list) > 1: if len(location_list) > 1:
raise EntryNameNotUniqueError raise EntryNameNotUniqueError

View File

@ -100,6 +100,9 @@ class Add_Commands:
except LocationLookUpError: except LocationLookUpError:
await ctx.send('{}, you do not have a location called **{}**.'.format( await ctx.send('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc_name)) 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: except LocationHasTunnelError:
await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name)) await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
except TunnelInitError: except TunnelInitError:

View File

@ -140,6 +140,10 @@ class TestCommands(TestCase):
def test_tunnel(self): def test_tunnel(self):
self.commands.register('BirbHD', '143072699567177728') 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_shop(0, 0, shop_name='test shop', discord_uuid='143072699567177728')
self.commands.add_tunnel("soUTH", 50, None, discord_uuid='143072699567177728') self.commands.add_tunnel("soUTH", 50, None, discord_uuid='143072699567177728')