def test_exit_level_not_found(self):
        # get original
        original = get_garage_data()

        # ---------- call method ----------
        self.req.body = {
            'vehicle_id': '1',
            'spot_id': '2',
            'row': '0',
            'level': 'not a level'
        }

        with self.assertRaises(APIError) as context:
            http_delete(self.req, self.resp, self.params)

        # get not_updated
        not_updated = get_garage_data()

        # ---------- evaluate response ----------
        self.assertEqual(context.exception.code, 'Invalid Level ID')
        self.assertEqual(original, not_updated)
    def test_exit_garage_bus(self):
        self.req.body = {
            'vehicle_id': '2',
            'spot_id': '7-11',
            'row': '0',
            'level': '0'
        }

        # ---------- call method ----------
        # get original
        original = get_garage_data()

        http_delete(self.req, self.resp, self.params)

        # get updated document
        updated = get_garage_data()

        # ---------- evaluate response ----------
        # assert response status
        self.assertEqual(self.resp.status, status_codes.HTTP_OK)

        # assert document has changed
        self.assertNotEqual(original, updated)

        spots = Garage.decouple_spot_id(self.req.body['spot_id'])

        for spot in spots:
            # assert vehicle was in original location
            original_location = \
                original['levels'][self.req.body['level']]['rows'][self.req.body['row']]['spots'][spot]
            self.assertEqual(self.req.body['vehicle_id'],
                             original_location['vehicle']['vehicle_id'])

            # assert spot is empty in updated
            updated_location = \
                updated['levels'][self.req.body['level']]['rows'][self.req.body['row']]['spots'][spot]
            self.assertEqual({}, updated_location['vehicle'])