From ef9d11bd14ada624435bc5df5fec230a71c9cc6d Mon Sep 17 00:00:00 2001 From: etobi Date: Fri, 30 Sep 2011 22:55:10 +0200 Subject: Initial commit (version 0.6) --- tests/__init__.py | 0 .../sample1/2008-03-28.20.13.99.99.rec/001.vdr | 1 + .../sample1/2008-03-28.20.13.99.99.rec/002.vdr | 1 + .../sample1/2008-03-28.20.13.99.99.rec/003.vdr | 1 + .../sample1/2008-03-28.20.13.99.99.rec/004.vdr | 1 + .../sample1/2008-03-28.20.13.99.99.rec/info.vdr | 6 +++ .../sample2/2008-03-28.20.13.99.98.rec/001.vdr | 1 + .../sample2/2008-03-28.20.13.99.98.rec/002.vdr | 1 + .../sample2/2008-03-28.20.13.99.98.rec/003.vdr | 1 + .../sample2/2008-03-28.20.13.99.98.rec/004.vdr | 1 + .../sample2/2008-03-28.20.13.99.98.rec/info.vdr | 6 +++ .../sample2/2008-03-28.20.13.99.99.rec/001.vdr | 1 + .../sample2/2008-03-28.20.13.99.99.rec/002.vdr | 1 + .../sample2/2008-03-28.20.13.99.99.rec/003.vdr | 1 + .../sample2/2008-03-28.20.13.99.99.rec/004.vdr | 1 + .../sample2/2008-03-28.20.13.99.99.rec/info.vdr | 6 +++ .../2008-03-28.20.13.99.99.rec/00001.ts | 1 + .../2008-03-28.20.13.99.99.rec/00002.ts | 1 + .../2008-03-28.20.13.99.99.rec/00003.ts | 1 + .../2008-03-28.20.13.99.99.rec/00004.ts | 1 + .../sample-vdr1.7/2008-03-28.20.13.99.99.rec/info | 6 +++ .../sample/2008-03-28.20.13.99.99.rec/001.vdr | 1 + .../sample/2008-03-28.20.13.99.99.rec/002.vdr | 1 + .../sample/2008-03-28.20.13.99.99.rec/003.vdr | 1 + .../sample/2008-03-28.20.13.99.99.rec/004.vdr | 1 + .../sample/2008-03-28.20.13.99.99.rec/info.vdr | 6 +++ tests/syslog.py | 2 + tests/test_all | 40 ++++++++++++++++++ tests/test_dir.py | 40 ++++++++++++++++++ tests/test_gettattr.py | 38 +++++++++++++++++ tests/test_mpg.py | 46 +++++++++++++++++++++ tests/test_nfo.py | 47 ++++++++++++++++++++++ tests/test_path_to_node_mapping.py | 45 +++++++++++++++++++++ 33 files changed, 308 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/001.vdr create mode 100644 tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/002.vdr create mode 100644 tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/003.vdr create mode 100644 tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/004.vdr create mode 100644 tests/sample_video_dir/folder/sample1/2008-03-28.20.13.99.99.rec/info.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/001.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/002.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/003.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/004.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.98.rec/info.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/001.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/002.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/003.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/004.vdr create mode 100644 tests/sample_video_dir/folder/sample2/2008-03-28.20.13.99.99.rec/info.vdr create mode 100644 tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00001.ts create mode 100644 tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00002.ts create mode 100644 tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00003.ts create mode 100644 tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/00004.ts create mode 100644 tests/sample_video_dir/sample-vdr1.7/2008-03-28.20.13.99.99.rec/info create mode 100644 tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/001.vdr create mode 100644 tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/002.vdr create mode 100644 tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/003.vdr create mode 100644 tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/004.vdr create mode 100644 tests/sample_video_dir/sample/2008-03-28.20.13.99.99.rec/info.vdr create mode 100644 tests/syslog.py create mode 100755 tests/test_all create mode 100644 tests/test_dir.py create mode 100644 tests/test_gettattr.py create mode 100644 tests/test_mpg.py create mode 100644 tests/test_nfo.py create mode 100644 tests/test_path_to_node_mapping.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 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) -- cgit v1.2.3