Using real objects is considered polite

Previously, ToddlerBase and derived classes were used directly, but none
of the methods is marked as a class or static method. Amazingly enough,
it worked regardless. It's useful to have a constructor, though, so do
things conventionally.

As we can't just monkey-patch the classes then, use the shared `toddler`
fixture which creates the object for the test methods that need it.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2020-07-16 13:16:38 +02:00
parent 3f081a66ac
commit 7fe0937190
14 changed files with 167 additions and 225 deletions

View file

@ -1,16 +1,17 @@
import fedora_messaging.api
import toddlers.plugins.debug
from toddlers.plugins.debug import DebugToddler
class TestDebugToddler:
def test_accepts_topic(self):
assert toddlers.plugins.debug.DebugToddler.accepts_topic("foo.bar")
def test_process(self):
toddler_cls = DebugToddler
def test_accepts_topic(self, toddler):
assert toddler.accepts_topic("foo.bar")
def test_process(self, toddler):
msg = fedora_messaging.api.Message()
msg.id = 123
msg.topic = "toddlers.test.topic"
assert (
toddlers.plugins.debug.DebugToddler.process(config={}, message=msg) is None
)
assert toddler.process(config={}, message=msg) is None