From 158db7054287d1279ee82cb6d019607b035a533a Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Fri, 21 Apr 2017 10:48:44 +0100
Subject: [PATCH] Unit test for settings.filePath function

---
 tests/test_settings.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/test_settings.py b/tests/test_settings.py
index 2bb1db4db..66d02c3b1 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -36,6 +36,7 @@ def test_initialise():
     assert settings.readFile('nothing') is None
     settings.writeFile('nothing', 'nothing')
     settings.deleteFile('nothing')
+    assert settings.filePath() is None
     assert settings.readAll() == {}
     assert settings.listFiles() == []
     settings.clear()
@@ -339,6 +340,28 @@ def test_listFiles():
 
         assert list(sorted(s.listFiles('*/setting1.txt'))) == list(sorted([ns1files[0]] + [ns2files[0]]))
 
+
+def test_filePath():
+
+    testfiles  = ['file1.txt',
+                  'dir1/file2.txt',
+                  'dir1/dir2/file3.txt']
+
+    with tests.testdir() as testdir:
+
+        s = settings.Settings(cfgid='test', cfgdir=testdir, writeOnExit=False)
+
+        assert s.filePath('nofile') == op.join(testdir, 'nofile')
+
+        for fn in testfiles:
+            s.writeFile(fn, fn)
+
+        assert s.filePath('nofile') == op.join(testdir, 'nofile')
+
+        for f in testfiles:
+            assert s.filePath(f) == op.join(testdir, f)
+
+
 def test_clear():
 
     testsettings = [('setting1', '1'),
-- 
GitLab