]> kaliko git repositories - python-musicpd.git/blobdiff - test.py
More robust MPD_HOST parsing
[python-musicpd.git] / test.py
diff --git a/test.py b/test.py
index 449101b994f6c096b989cb9df0de3afbe5553064..ecf62ffb6c70e70fc28abc8f668644c00003aa3a 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -61,6 +61,20 @@ class testEnvVar(unittest.TestCase):
         self.assertEqual(client.pwd, 'pa55w04d')
         self.assertEqual(client.host, 'example.org')
 
+        # Test password extraction (no host)
+        os.environ['MPD_HOST'] = 'pa55w04d@'
+        with mock.patch('os.path.exists', return_value=False):
+            client = musicpd.MPDClient()
+        self.assertEqual(client.pwd, 'pa55w04d')
+        self.assertEqual(client.host, 'localhost')
+
+        # Test badly formatted MPD_HOST
+        os.environ['MPD_HOST'] = '@'
+        with mock.patch('os.path.exists', return_value=False):
+            client = musicpd.MPDClient()
+        self.assertEqual(client.pwd, None)
+        self.assertEqual(client.host, 'localhost')
+
         # Test unix socket extraction
         os.environ['MPD_HOST'] = 'pa55w04d@/unix/sock'
         client = musicpd.MPDClient()