Skip to content

Commit

Permalink
style: Add missing __init__.py files and fix lint issues (#36)
Browse files Browse the repository at this point in the history
Pylint wasn't checking these modules since they weren't importable
packages, due to the missing init files.
  • Loading branch information
timmc-edx authored Aug 31, 2022
1 parent fa7c4fd commit 94d7c9f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Unreleased
[0.5.0] - 2022-08-31
********************

Fixed
=====

* Various lint issues (and missing ``__init__.py`` files.)

[0.5.0] - 2022-08-31
********************

Changed
=======

Expand Down
2 changes: 1 addition & 1 deletion edx_event_bus_kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Kafka implementation for Open edX event bus.
"""

__version__ = '0.5.0'
__version__ = '0.5.1'
Empty file.
14 changes: 4 additions & 10 deletions edx_event_bus_kafka/consumer/tests/test_event_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import copy
from contextlib import contextmanager
from unittest.mock import Mock, patch

from django.core.management import call_command
Expand All @@ -15,12 +14,6 @@
from edx_event_bus_kafka.consumer.event_consumer import KafkaEventConsumer
from edx_event_bus_kafka.management.commands.consume_events import Command

# See https://github.com/openedx/event-bus-kafka/blob/main/docs/decisions/0005-optional-import-of-confluent-kafka.rst
try:
from confluent_kafka.serialization import StringSerializer
except ImportError: # pragma: no cover
pass


class FakeMessage:
"""
Expand Down Expand Up @@ -65,6 +58,7 @@ class TestEmitSignals(TestCase):
"""

def setUp(self):
super().setUp()
self.normal_event_data = {
'user': UserData(
id=123,
Expand Down Expand Up @@ -99,7 +93,7 @@ def test_emit(self):

def test_no_type(self):
msg = copy.copy(self.normal_message)
msg._headers = []
msg._headers = [] # pylint: disable=protected-access

with patch.object(OpenEdxPublicSignal, 'get_signal_by_type') as mock_lookup:
self.event_consumer.emit_signals_from_message(msg)
Expand All @@ -117,10 +111,10 @@ def test_unknown_type(self):

def test_unwanted_types(self):
msg = copy.copy(self.normal_message)
msg._headers = [
msg._headers = [ # pylint: disable=protected-access
['ce_type', b'xxxx']
]
with patch.object(OpenEdxPublicSignal, 'get_signal_by_type', self.mock_signal) as mock_lookup:
with patch.object(OpenEdxPublicSignal, 'get_signal_by_type', self.mock_signal):
self.event_consumer.emit_signals_from_message(msg)

assert not self.mock_signal.send_event.called
Expand Down
Empty file.
Empty file.
4 changes: 3 additions & 1 deletion edx_event_bus_kafka/management/commands/consume_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
Makes ``consume_events`` management command available.
Implements required ``APP.management.commands.*.Command`` structure.
"""

from edx_event_bus_kafka.consumer.event_consumer import ConsumeEventsCommand as Command
from edx_event_bus_kafka.consumer.event_consumer import ConsumeEventsCommand as Command # pylint: disable=unused-import
3 changes: 2 additions & 1 deletion edx_event_bus_kafka/management/commands/produce_event.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
Produce a single event. Intended for testing.
Implements required ``APP.management.commands.*.Command`` structure.
"""

import json
import logging

from django.core.management.base import BaseCommand
from django.utils.module_loading import import_string
from openedx_events.tooling import OpenEdxPublicSignal

from edx_event_bus_kafka.publishing.event_producer import get_producer

Expand Down

0 comments on commit 94d7c9f

Please sign in to comment.