diff --git a/src/run_tests.py b/src/run_tests.py index 034d6e4..d766a39 100644 --- a/src/run_tests.py +++ b/src/run_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import unittest -testmodules = ['test.test_extractors'] +testmodules = ['test.test_storage', 'test.test_extractors'] suite = unittest.TestSuite() diff --git a/src/test/test_storage.py b/src/test/test_storage.py new file mode 100644 index 0000000..0a5acbc --- /dev/null +++ b/src/test/test_storage.py @@ -0,0 +1,35 @@ +""" Unittests for Path generation stuff. """ +from __future__ import unicode_literals +import os +import shutil +import unittest +import tempfile +import storage +import paths + +class storageTestCase(unittest.TestCase): + + def test_portable_path(self): + """ Testing if paths are generated appropiately. """ + storage.setup() + self.assertEquals(storage.app_type, "portable") + self.assertTrue(os.path.exists(storage.data_directory)) + self.assertEquals(storage.data_directory, os.path.join(paths.app_path(), "data")) + + def test_installer_path(self): + """ Testing if paths are generated appropiately. """ + fake_installer_file = open(os.path.join(paths.app_path(), "uninstall.exe"), "w") + fake_installer_file.close() + storage.setup() + self.assertEquals(storage.app_type, "installed") + self.assertTrue(os.path.exists(storage.data_directory)) + self.assertEquals(storage.data_directory, paths.app_data_path("musicDL")) + + def tearDown(self): + """ Removes uninstall.exe created for tests and data path.""" + if os.path.exists(paths.app_data_path("musicDL")): + shutil.rmtree(paths.app_data_path("musicDL")) + if os.path.exists(os.path.join(paths.app_path(), "uninstall.exe")): + os.remove(os.path.join(paths.app_path(), "uninstall.exe")) +if __name__ == "__main__": + unittest.main() \ No newline at end of file