summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-03-25 10:41:23 +0100
committerhut <hut@lepus.uberspace.de>2016-03-25 10:41:23 +0100
commit7351c7a78906150b2e28b5c851a321efa3273f12 (patch)
tree9695f408de966b2fb7ac80903176c56257c812c2 /tests
parentf9a30bac4009fa646fcbe7cd5eba12f1005b821c (diff)
parent4c6117fded0bce5844c1aa46a60c2946d50568c3 (diff)
downloadranger-7351c7a78906150b2e28b5c851a321efa3273f12.tar.gz
Merge branch 'master' of https://github.com/lverweijen/ranger
Diffstat (limited to 'tests')
-rw-r--r--tests/ranger/container/test_fsobject.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ranger/container/test_fsobject.py b/tests/ranger/container/test_fsobject.py
new file mode 100644
index 00000000..4e521806
--- /dev/null
+++ b/tests/ranger/container/test_fsobject.py
@@ -0,0 +1,34 @@
+import pytest
+import operator
+
+from ranger.container.fsobject import FileSystemObject
+
+
+class MockFM(object):
+    """Used to fullfill the dependency by FileSystemObject."""
+
+    default_linemodes = []
+
+
+def create_filesystem_object(path):
+    """Create a FileSystemObject without an fm object."""
+    fso = FileSystemObject.__new__(FileSystemObject)
+    fso.fm = MockFM()
+    fso.__init__(path)
+    return fso
+
+
+def test_basename_natural1():
+    """Test filenames without extensions."""
+    fsos = [create_filesystem_object(path)
+            for path in "hello", "hello1", "hello2"]
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))
+
+
+def test_basename_natural2():
+    """Test filenames with extensions."""
+    fsos = [create_filesystem_object(path)
+            for path in "hello", "hello.txt", "hello1.txt", "hello2.txt"]
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
+    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))