summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/001.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/002.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/003.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/004.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/info.vdr6
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/001.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/002.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/003.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/004.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/info.vdr6
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/001.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/002.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/003.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/004.vdr1
-rw-r--r--tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/info.vdr6
-rw-r--r--tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00001.ts1
-rw-r--r--tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00002.ts1
-rw-r--r--tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00003.ts1
-rw-r--r--tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00004.ts1
-rw-r--r--tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/info6
-rw-r--r--tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/001.vdr1
-rw-r--r--tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/002.vdr1
-rw-r--r--tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/003.vdr1
-rw-r--r--tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/004.vdr1
-rw-r--r--tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/info.vdr6
-rw-r--r--tests/syslog.py2
-rwxr-xr-xtests/test_all40
-rw-r--r--tests/test_dir.py40
-rw-r--r--tests/test_gettattr.py38
-rw-r--r--tests/test_mpg.py46
-rw-r--r--tests/test_nfo.py47
-rw-r--r--tests/test_path_to_node_mapping.py45
33 files changed, 308 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/001.vdr b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/001.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/001.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/002.vdr b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/002.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/002.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/003.vdr b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/003.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/003.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/004.vdr b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/004.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/004.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/info.vdr b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/info.vdr
new file mode 100644
index 0000000..08787fc
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/info.vdr
@@ -0,0 +1,6 @@
+C S19.2E-1-1101-28112
+E 6345 1189982700 18900 4E 10
+T Movie Title
+S Movie Subtitle
+D A movie about something
+X 2 03 deu stereo
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/001.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/001.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/001.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/002.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/002.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/002.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/003.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/003.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/003.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/004.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/004.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/004.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/info.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/info.vdr
new file mode 100644
index 0000000..08787fc
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/info.vdr
@@ -0,0 +1,6 @@
+C S19.2E-1-1101-28112
+E 6345 1189982700 18900 4E 10
+T Movie Title
+S Movie Subtitle
+D A movie about something
+X 2 03 deu stereo
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/001.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/001.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/001.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/002.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/002.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/002.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/003.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/003.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/003.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/004.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/004.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/004.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/info.vdr b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/info.vdr
new file mode 100644
index 0000000..08787fc
--- /dev/null
+++ b/tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/info.vdr
@@ -0,0 +1,6 @@
+C S19.2E-1-1101-28112
+E 6345 1189982700 18900 4E 10
+T Movie Title
+S Movie Subtitle
+D A movie about something
+X 2 03 deu stereo
diff --git a/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00001.ts b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00001.ts
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00001.ts
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00002.ts b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00002.ts
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00002.ts
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00003.ts b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00003.ts
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00003.ts
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00004.ts b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00004.ts
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00004.ts
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/info b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/info
new file mode 100644
index 0000000..08787fc
--- /dev/null
+++ b/tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/info
@@ -0,0 +1,6 @@
+C S19.2E-1-1101-28112
+E 6345 1189982700 18900 4E 10
+T Movie Title
+S Movie Subtitle
+D A movie about something
+X 2 03 deu stereo
diff --git a/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/001.vdr b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/001.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/001.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/002.vdr b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/002.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/002.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/003.vdr b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/003.vdr
new file mode 100644
index 0000000..6a537b5
--- /dev/null
+++ b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/003.vdr
@@ -0,0 +1 @@
+1234567890 \ No newline at end of file
diff --git a/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/004.vdr b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/004.vdr
new file mode 100644
index 0000000..c76a964
--- /dev/null
+++ b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/004.vdr
@@ -0,0 +1 @@
+abcdefghij \ No newline at end of file
diff --git a/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/info.vdr b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/info.vdr
new file mode 100644
index 0000000..08787fc
--- /dev/null
+++ b/tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/info.vdr
@@ -0,0 +1,6 @@
+C S19.2E-1-1101-28112
+E 6345 1189982700 18900 4E 10
+T Movie Title
+S Movie Subtitle
+D A movie about something
+X 2 03 deu stereo
diff --git a/tests/syslog.py b/tests/syslog.py
new file mode 100644
index 0000000..abadaa2
--- /dev/null
+++ b/tests/syslog.py
@@ -0,0 +1,2 @@
+def syslog(*arg):
+ raise
diff --git a/tests/test_all b/tests/test_all
new file mode 100755
index 0000000..02ab99f
--- /dev/null
+++ b/tests/test_all
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import os
+import sys
+import unittest
+
+def suite():
+ suite = unittest.TestSuite()
+ for _, _, files in os.walk('.'):
+ for name in filter(is_test, files):
+ tests = unittest.defaultTestLoader.loadTestsFromName(name[:-3])
+ suite.addTests(tests)
+ return suite
+
+def is_test(filename):
+ return filename.startswith('test_') and filename.endswith('.py')
+
+if __name__ == "__main__":
+ sys.path.insert(0, '.')
+ unittest.main(defaultTest="suite")
diff --git a/tests/test_dir.py b/tests/test_dir.py
new file mode 100644
index 0000000..e7562f0
--- /dev/null
+++ b/tests/test_dir.py
@@ -0,0 +1,40 @@
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import os
+import unittest
+import xml.etree.ElementTree
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from vdrnfofs.vdrnfofs import *
+
+class TestDir(unittest.TestCase):
+ def setUp(self):
+ self.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir')
+
+ def test_not_existing(self):
+ node = get_node(self.video, '/does_not_exist')
+ self.assertEqual(None, node)
+
+ def test_content(self):
+ node = get_node(self.video, '/')
+ self.assertEqual(5, len(node.content()))
+
diff --git a/tests/test_gettattr.py b/tests/test_gettattr.py
new file mode 100644
index 0000000..7bae140
--- /dev/null
+++ b/tests/test_gettattr.py
@@ -0,0 +1,38 @@
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import os
+import unittest
+import stat
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+
+from vdrnfofs.vdrnfofs import *
+
+class TestPathToNodeMapping(unittest.TestCase):
+ def setUp(self):
+ self.fs = VdrNfoFs()
+ self.fs.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir')
+
+ def test_root(self):
+ attr = self.fs.getattr('/')
+ self.assertEqual(stat.S_IFDIR | 0755, attr.st_mode)
+ self.assertEqual(2 + 5, attr.st_nlink)
diff --git a/tests/test_mpg.py b/tests/test_mpg.py
new file mode 100644
index 0000000..397b5fe
--- /dev/null
+++ b/tests/test_mpg.py
@@ -0,0 +1,46 @@
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import os
+import unittest
+import xml.etree.ElementTree
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from vdrnfofs.vdrnfofs import *
+
+class TestMpg(unittest.TestCase):
+ def setUp(self):
+ self.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir')
+
+ def test_not_existing(self):
+ node = get_node(self.video, '/does_not_exist_2008-03-28.20.13.99.99.rec.mpg')
+ self.assertEqual(None, node)
+
+ def test_mpg(self):
+ node = get_node(self.video, '/sample_2008-03-28.20.13.99.99.rec.mpg')
+ self.assertEqual(40, node.size())
+ self.assertEqual('1234567890abcdefghij1234567890abcdefghij', node.read(0, 4096))
+
+ def test_mpg_new(self):
+ node = get_node(self.video, '/sample-vdr1.7_2008-03-28.20.13.99.99.rec.mpg')
+ self.assertEqual(40, node.size())
+ self.assertEqual('1234567890abcdefghij1234567890abcdefghij', node.read(0, 4096))
+
diff --git a/tests/test_nfo.py b/tests/test_nfo.py
new file mode 100644
index 0000000..e7107a3
--- /dev/null
+++ b/tests/test_nfo.py
@@ -0,0 +1,47 @@
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import os
+import unittest
+import xml.etree.ElementTree
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from vdrnfofs.vdrnfofs import *
+
+class TestNfo(unittest.TestCase):
+ def setUp(self):
+ self.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir')
+
+ def test_not_existing(self):
+ node = get_node(self.video, '/does_not_exist_2008-03-28.20.13.99.99.rec.nfo')
+ self.assertEqual(None, node)
+
+ def test_nfo(self):
+ node = get_node(self.video, '/sample_2008-03-28.20.13.99.99.rec.nfo')
+ nfo = xml.etree.ElementTree.fromstring(node.read(0, 4096))
+ self.assertEqual('Movie Title', nfo.find('title').text)
+ self.assertEqual('A movie about something', nfo.find('plot').text)
+
+ def test_nfo_new(self):
+ node = get_node(self.video, '/sample-vdr1.7_2008-03-28.20.13.99.99.rec.nfo')
+ nfo = xml.etree.ElementTree.fromstring(node.read(0, 4096))
+ self.assertEqual('Movie Title', nfo.find('title').text)
+ self.assertEqual('A movie about something', nfo.find('plot').text)
diff --git a/tests/test_path_to_node_mapping.py b/tests/test_path_to_node_mapping.py
new file mode 100644
index 0000000..59f3515
--- /dev/null
+++ b/tests/test_path_to_node_mapping.py
@@ -0,0 +1,45 @@
+# VDR-NFO-FS creates a file system for VDR recordings, which maps each
+# recording to a single mpg-file and nfo-file containing some meta data.
+#
+# Copyright (C) 2010 - 2011 by Tobias Grimm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import os
+import unittest
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from vdrnfofs.vdrnfofs import *
+
+class TestPathToNodeMapping(unittest.TestCase):
+ def setUp(self):
+ self.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir')
+
+ def test_root(self):
+ node = get_node(self.video, '/')
+ self.assertEqual('', node.file_system_name)
+ self.assertEqual(self.video, node.path)
+
+ def test_subdir(self):
+ node = get_node(self.video, '/folder')
+ self.assertEqual('folder', node.file_system_name)
+ self.assertEqual(self.video + '/folder', node.path)
+
+ def test_mpg(self):
+ node = get_node(self.video, '/sample_2008-03-28.20.13.99.99.rec.mpg')
+ self.assertEqual('sample_2008-03-28.20.13.99.99.rec.mpg', node.file_system_name)
+ self.assertEqual(self.video + '/sample/2008-03-28.20.13.99.99.rec', node.path)