Skip to content

Commit

Permalink
merged 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Apr 28, 2019
2 parents dffeac1 + b0030cf commit 4b5cfae
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# generated by deepsource.io
version = 1

test_patterns = [
'tests/**/*.py'
]

exclude_patterns = [
'databases/migrations/*'
]

[[analyzers]]
name = "python"
enabled = true
runtime_version = "3.x.x"
2 changes: 1 addition & 1 deletion masonite/commands/DownCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class DownCommand(Command):
"""
Puts the sever in a maintenance state.
Puts the server in a maintenance state.
down
"""
Expand Down
2 changes: 1 addition & 1 deletion masonite/commands/UpCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UpCommand(Command):
"""
Puts the sever in a maintenance state.
Brings the server out of maintenance state.
up
"""
Expand Down
7 changes: 5 additions & 2 deletions masonite/drivers/queue/QueueAmqpDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,21 @@ def consume(self, channel, fair=False):
self.success('[*] Waiting to process jobs on the "{}" channel. To exit press CTRL+C'.format(
channel))

self.channel.basic_consume(channel, self.work)

if fair:
self.channel.basic_qos(prefetch_count=1)

self.basic_consume(self.work, channel)

try:
self.channel.start_consuming()
finally:
self.channel.stop_consuming()
self.channel.close()
self.connection.close()

def basic_consume(self, callback, queue):
self.channel.basic_consume(callback, queue=queue)

def work(self, ch, method, properties, body):
from wsgi import container
job = pickle.loads(body)
Expand Down
1 change: 1 addition & 0 deletions masonite/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from .optional import Optional as optional
from .structures import config, Dot
from .migrations import has_unmigrated_migrations
from orator.support.collection import Collection as collect
6 changes: 5 additions & 1 deletion masonite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,11 @@ def route(self, name, params={}, full=False):
if full:
route = application.URL + self._get_named_route(name, params)
else:
route = self._get_named_route(name, params)
try:
route = self._get_named_route(name, params)
except KeyError:
params.update(self.url_params)
route = self._get_named_route(name, params)

if not route:
raise RouteException("Route with the name of '{}' was not found.".format(name))
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ def test_request_route_returns_url(self):
with self.assertRaises(RouteException):
self.assertTrue(request.route('not.exists', [1]))

def test_request_route_returns_url_without_passing_args_with_current_param(self):
app = App()
app.bind('Request', self.request)
app.bind('WebRoutes', [
Get('/test/url', 'TestController@show').name('test.url'),
Get('/test/url/@id', 'TestController@show').name('test.id')
])
request = app.make('Request').load_app(app)
request.url_params = {'id': 1}

assert request.route('test.id') == '/test/url/1'

def test_request_redirection(self):
app = App()
app.bind('Request', self.request)
Expand Down
6 changes: 6 additions & 0 deletions tests/helpers/test_collect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from masonite.helpers import collect

class TestCollect:

def test_collect_helper(self):
assert collect([1,2]).first() == 1

0 comments on commit 4b5cfae

Please sign in to comment.