Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing test that assumed local inventory was blank #230

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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