This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import sys
|
from slic.utils import snapshot
|
||||||
import os
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
||||||
from slic.utils.snapshot import *
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +31,7 @@ def test_snapshot_excludes_internal_by_default():
|
|||||||
hidden = FakeAdjustable("internal", internal=True)
|
hidden = FakeAdjustable("internal", internal=True)
|
||||||
|
|
||||||
with patch("slic.utils.snapshot.instances", return_value=[visible, hidden]):
|
with patch("slic.utils.snapshot.instances", return_value=[visible, hidden]):
|
||||||
result = snapshot()
|
result = snapshot.snapshot()
|
||||||
assert visible in result
|
assert visible in result
|
||||||
assert hidden not in result
|
assert hidden not in result
|
||||||
|
|
||||||
@@ -45,7 +42,7 @@ def test_snapshot_include_internal_flag():
|
|||||||
hidden = FakeAdjustable("internal", internal=True)
|
hidden = FakeAdjustable("internal", internal=True)
|
||||||
|
|
||||||
with patch("slic.utils.snapshot.instances", return_value=[visible, hidden]):
|
with patch("slic.utils.snapshot.instances", return_value=[visible, hidden]):
|
||||||
result = snapshot(include_internal=True)
|
result = snapshot.snapshot(include_internal=True)
|
||||||
assert visible in result
|
assert visible in result
|
||||||
assert hidden in result
|
assert hidden in result
|
||||||
assert len(result) == 2
|
assert len(result) == 2
|
||||||
@@ -54,7 +51,7 @@ def test_snapshot_include_internal_flag():
|
|||||||
def test_snapshot_empty_result():
|
def test_snapshot_empty_result():
|
||||||
|
|
||||||
with patch("slic.utils.snapshot.instances", return_value=[]):
|
with patch("slic.utils.snapshot.instances", return_value=[]):
|
||||||
result = snapshot()
|
result = snapshot.snapshot()
|
||||||
assert isinstance(result, list)
|
assert isinstance(result, list)
|
||||||
assert result == []
|
assert result == []
|
||||||
|
|
||||||
@@ -84,7 +81,7 @@ def test_snapshot_sort_keys(sort_key, expected_order):
|
|||||||
unordered = [c, a, b] # intentionally unsorted
|
unordered = [c, a, b] # intentionally unsorted
|
||||||
|
|
||||||
with patch("slic.utils.snapshot.instances", return_value=unordered):
|
with patch("slic.utils.snapshot.instances", return_value=unordered):
|
||||||
result = snapshot(sort_key=sort_key)
|
result = snapshot.snapshot(sort_key=sort_key)
|
||||||
# We check that the objects returned match the expected names (using original mapping)
|
# We check that the objects returned match the expected names (using original mapping)
|
||||||
result_names = [adj.name for adj in result]
|
result_names = [adj.name for adj in result]
|
||||||
assert result_names == [name_to_obj[n].name for n in expected_order]
|
assert result_names == [name_to_obj[n].name for n in expected_order]
|
||||||
|
|||||||
Reference in New Issue
Block a user