Skip to content

Commit

Permalink
Fixing test that assumed local inventory was blank
Browse files Browse the repository at this point in the history
This simply adds the temp_inventory fixture to the file for this test.
There are a few tests in different locations that also use this fixture
so in the future, these could likely be consolidated.
  • Loading branch information
JacobCallahan committed Aug 30, 2023
1 parent c67b246 commit 649a83c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_broker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from broker import broker, Broker, helpers
from broker import broker, Broker, helpers, settings
from broker.providers import test_provider
import pytest


@pytest.fixture(scope="module")
def temp_inventory():
"""Temporarily move the local inventory, then move it back when done"""
backup_path = settings.inventory_path.rename(f"{settings.inventory_path.absolute()}.bak")
yield
settings.inventory_path.unlink()
backup_path.rename(settings.inventory_path)


def test_empty_init():
"""Broker should be able to init without any arguments"""
broker_inst = Broker()
Expand Down Expand Up @@ -50,7 +59,7 @@ def test_broker_empty_checkin():
broker_inst.checkin()


def test_broker_checkin_n_sync_empty_hostname():
def test_broker_checkin_n_sync_empty_hostname(temp_inventory):
"""Test that broker can checkin and sync inventory with a host that has empty hostname"""
broker_inst = broker.Broker(nick="test_nick")
broker_inst.checkout()
Expand Down

0 comments on commit 649a83c

Please sign in to comment.