2018-04-01 10:32:36 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# coding: utf-8
|
|
|
|
#
|
|
|
|
# This file is part of Supysonic.
|
|
|
|
# Supysonic is a Python implementation of the Subsonic server API.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Alban 'spl0k' Féron
|
|
|
|
#
|
|
|
|
# Distributed under terms of the GNU AGPLv3 license.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
from supysonic.db import init_database, release_database
|
|
|
|
from supysonic.web import create_application
|
|
|
|
|
|
|
|
from ..testbase import TestConfig
|
|
|
|
|
2019-06-29 15:25:44 +00:00
|
|
|
|
2018-04-01 10:32:36 +00:00
|
|
|
class SecretTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.__dbfile = tempfile.mkstemp()[1]
|
|
|
|
self.__dir = tempfile.mkdtemp()
|
|
|
|
self.config = TestConfig(False, False)
|
2019-06-29 15:25:44 +00:00
|
|
|
self.config.BASE["database_uri"] = "sqlite:///" + self.__dbfile
|
|
|
|
self.config.WEBAPP["cache_dir"] = self.__dir
|
2018-04-01 10:32:36 +00:00
|
|
|
|
2019-06-29 15:25:44 +00:00
|
|
|
init_database(self.config.BASE["database_uri"])
|
2018-04-01 10:32:36 +00:00
|
|
|
release_database()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
shutil.rmtree(self.__dir)
|
|
|
|
os.remove(self.__dbfile)
|
|
|
|
|
|
|
|
def test_key(self):
|
|
|
|
app1 = create_application(self.config)
|
|
|
|
release_database()
|
|
|
|
|
|
|
|
app2 = create_application(self.config)
|
|
|
|
release_database()
|
|
|
|
|
|
|
|
self.assertEqual(app1.secret_key, app2.secret_key)
|
|
|
|
|
|
|
|
|
2019-06-29 15:25:44 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|