Completed
Pull Request — master (#15)
by
unknown
03:13
created

test_manager_one_route()   A

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
1
# -*- coding: utf-8 -*-
2
# vi:si:et:sw=4:sts=4:ts=4
3
4
import asyncio
5
from unittest import mock
6
7
from loafer.exceptions import ConsumerError
8
from loafer.dispatcher import LoaferDispatcher
0 ignored issues
show
Bug introduced by
The name dispatcher does not seem to exist in module loafer.
Loading history...
Configuration introduced by
Unable to import 'loafer.dispatcher' (invalid syntax (<string>, line 35))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
9
from loafer.manager import LoaferManager
10
from loafer.route import Route
0 ignored issues
show
Bug introduced by
The name route does not seem to exist in module loafer.
Loading history...
Configuration introduced by
Unable to import 'loafer.route' (invalid syntax (<string>, line 25))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
11
12
from loafer.aws.consumer import Consumer as AWSConsumer
0 ignored issues
show
Bug introduced by
The name consumer does not seem to exist in module loafer.aws.
Loading history...
Configuration introduced by
Unable to import 'loafer.aws.consumer' (invalid syntax (<string>, line 29))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
13
14
15
def test_manager_with_no_routes(event_loop):
16
    manager = LoaferManager('test-queue', event_loop=event_loop)
17
    assert len(manager.routes) == 0
18
19
20
def test_manager_one_route(event_loop):
21
    route = Route('test-queue', lambda x: None)
22
    manager = LoaferManager('test-queue', event_loop=event_loop)
23
    manager.routes.append(route)
24
25
    assert len(manager.routes) == 1
26
27
28
def test_consumers(event_loop):
29
    manager = LoaferManager('test-queue', event_loop=event_loop)
30
    assert manager.consumers
31
    assert len(manager.consumers) == 1
32
33
34
def test_consumers_returns_default_if_not_manually_set(event_loop):
0 ignored issues
show
Coding Style Naming introduced by
The name test_consumers_returns_default_if_not_manually_set does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
35
    manager = LoaferManager('test-queue', event_loop=event_loop)
36
    assert manager.consumers[0].__class__ == AWSConsumer
37
38
39
def test_dispatcher(event_loop):
40
    manager = LoaferManager('test-queue', event_loop=event_loop)
41
    assert isinstance(manager.get_dispatcher(), LoaferDispatcher)
42
43
44
def test_on_future_errors(event_loop):
45
    manager = LoaferManager('test-queue', event_loop=event_loop)
46
    manager.stop = mock.Mock()
47
    future = asyncio.Future()
48
    future.set_exception(ConsumerError)
49
    manager.on_future__errors(future)
50
51
    assert manager.stop.called
52
    assert manager.stop.called_once_with()
53