Skip to content
Permalink
Browse files

Test automatic updates with/without existing user.

Signed-off-by: Nils Philippsen <nils@redhat.com>
  • Loading branch information...
nphilipp committed Apr 25, 2019
1 parent c3e19d3 commit efd759af8b1344c9e9a3eb567c93da823be71b72
Showing with 34 additions and 1 deletion.
  1. +34 −1 bodhi/tests/server/consumers/test_automatic_updates.py
@@ -29,7 +29,7 @@

from bodhi.server.consumers.automatic_updates import AutomaticUpdateHandler, config
from bodhi.server.exceptions import BodhiException
from bodhi.server.models import Build, Update, UpdateType
from bodhi.server.models import Build, Update, UpdateType, User
from bodhi.tests.server import base


@@ -243,6 +243,39 @@ def test_missing_release(self):
r"'.*' is missing.")):
self.handler(self.sample_message)

def test_missing_user(self, caplog):
"""Test Koji build user missing from DB."""
caplog.set_level(logging.DEBUG)

expected_username = base.buildsys.DevBuildsys._build_data['owner_name']

# ensure user with expected name doesn't exist
self.db.query(User).filter_by(name=expected_username).delete()
self.db.flush()

self.handler(self.sample_message)

assert(f"Creating bodhi user for '{expected_username}'."
in caplog.messages)

def test_existing_user(self, caplog):
"""Test Koji build user existing in DB."""
caplog.set_level(logging.DEBUG)

expected_username = base.buildsys.DevBuildsys._build_data['owner_name']

# ensure user with expected name exists
user = self.db.query(User).filter_by(name=expected_username).first()
if not user:
user = User(name=expected_username)
self.db.add(user)
self.db.flush()

self.handler(self.sample_message)

assert(f"Creating bodhi user for '{expected_username}'."
not in caplog.messages)

# Test messages that should be ignored.

def test_ignored_tag(self, caplog):

0 comments on commit efd759a

Please sign in to comment.
You can’t perform that action at this time.