FlightDeck/utils/test.py

39 строки
1.3 KiB
Python
Исходник Обычный вид История

2010-10-20 20:35:11 +04:00
import os
from test_utils import TestCase as _TestCase
2010-11-02 14:05:20 +03:00
from django.conf import settings
2010-10-20 20:35:11 +04:00
class TestCase(_TestCase):
"""
Base class for tests depending on existance of lib/jetpack-sdk
"""
def createCore(self):
" discover the newest dir and link to it "
2010-10-20 20:58:24 +04:00
# find the newest SDK
2010-11-02 14:05:20 +03:00
sdks = os.listdir(os.path.join(settings.FRAMEWORK_PATH, 'lib'))
2010-10-20 20:58:24 +04:00
self.sdk_filename = None
sdk_time = -1
for sdk in sdks:
if sdk != '__init__.py':
2011-02-01 18:23:39 +03:00
sdk_inf = os.stat(os.path.join(settings.FRAMEWORK_PATH, 'lib',
sdk))
2010-10-20 20:58:24 +04:00
if sdk_time < 0 or sdk_time > sdk_inf.st_ctime:
sdk_time = sdk_inf.st_ctime
self.sdk_filename = sdk
2011-02-01 18:23:39 +03:00
self.sdk_path = os.path.join(settings.FRAMEWORK_PATH,
'lib/jetpack-sdk')
sdk_orig = os.path.join(settings.FRAMEWORK_PATH, 'lib',
self.sdk_filename)
2010-10-20 20:35:11 +04:00
self.core_link_created = False
if not os.path.exists(self.sdk_path):
os.symlink(sdk_orig, self.sdk_path)
self.core_link_created = True
def deleteCore(self):
" remove symlink "
2010-10-20 20:58:24 +04:00
if not hasattr(self, 'core_link_created'):
2010-10-20 20:35:11 +04:00
return
if self.core_link_created:
os.remove(self.sdk_path)