Added test for storage path
This commit is contained in:
parent
882e03fbab
commit
875aab7e00
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
|
||||
testmodules = ['test.test_extractors']
|
||||
testmodules = ['test.test_storage', 'test.test_extractors']
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
|
35
src/test/test_storage.py
Normal file
35
src/test/test_storage.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user