From 647bfe0883d2bb05b4ff7f99894075df3e73d2d5 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 6 Nov 2017 10:06:02 -0500 Subject: [PATCH] ceph-volume tests.simple add checks for get_contents in scan Signed-off-by: Alfredo Deza --- .../tests/devices/simple/test_scan.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py diff --git a/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py new file mode 100644 index 0000000000000..56489f751c136 --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py @@ -0,0 +1,19 @@ +from ceph_volume.devices.simple import scan + + +class TestGetContentst(object): + + def test_multiple_lines_are_left_as_is(self, tmpfile): + magic_file = tmpfile(contents='first\nsecond\n') + scanner = scan.Scan([]) + assert scanner.get_contents(magic_file) == 'first\nsecond\n' + + def test_extra_whitespace_gets_removed(self, tmpfile): + magic_file = tmpfile(contents='first ') + scanner = scan.Scan([]) + assert scanner.get_contents(magic_file) == 'first' + + def test_single_newline_values_are_trimmed(self, tmpfile): + magic_file = tmpfile(contents='first\n') + scanner = scan.Scan([]) + assert scanner.get_contents(magic_file) == 'first' -- 2.39.5