35 lines
1.2 KiB
Python
Raw Normal View History

2018-12-29 21:08:06 -06:00
""" 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()