Fix namespace declaration
melange/__init__.py may not exist depending on order of installation. Change-Id: I875152afbd691e221414ef700371317730237506
This commit is contained in:
parent
b4707d28ea
commit
05612066e9
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ tags
|
|||||||
*~
|
*~
|
||||||
ChangeLog
|
ChangeLog
|
||||||
melange/vcsversion.py
|
melange/vcsversion.py
|
||||||
|
requirements.txt
|
||||||
|
@ -26,11 +26,17 @@ This script can be run as a cron job on the melange server.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
#TODO(jkoelker) Convert this to an entry_point
|
||||||
|
|
||||||
|
import gettext
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
gettext.install('melange', unicode=1)
|
||||||
|
|
||||||
|
|
||||||
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
@ -16,11 +16,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
#TODO(jkoelker) Convert this to an entry_point
|
||||||
|
|
||||||
|
import gettext
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
|
gettext.install('melange', unicode=1)
|
||||||
|
|
||||||
|
|
||||||
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
@ -32,7 +37,6 @@ if os.path.exists(os.path.join(possible_topdir, 'melange', '__init__.py')):
|
|||||||
|
|
||||||
from melange import version
|
from melange import version
|
||||||
from melange.common import config
|
from melange.common import config
|
||||||
from melange.common import wsgi
|
|
||||||
from melange.common import utils
|
from melange.common import utils
|
||||||
from melange.db import db_api
|
from melange.db import db_api
|
||||||
|
|
||||||
|
@ -16,11 +16,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
#TODO(jkoelker) Convert this to an entry_point
|
||||||
|
|
||||||
|
import gettext
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
|
gettext.install('melange', unicode=1)
|
||||||
|
|
||||||
|
|
||||||
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
# If ../melange/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
|
@ -14,25 +14,8 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
try:
|
||||||
import gettext
|
__import__('pkg_resources').declare_namespace(__name__)
|
||||||
import pkgutil
|
except ImportError:
|
||||||
import os
|
from pkgutil import extend_path
|
||||||
|
__path__ = extend_path(__path__, __name__)
|
||||||
|
|
||||||
__path__ = pkgutil.extend_path(__path__, __name__)
|
|
||||||
|
|
||||||
|
|
||||||
gettext.install('melange', unicode=1)
|
|
||||||
|
|
||||||
|
|
||||||
def melange_root_path():
|
|
||||||
return os.path.dirname(__file__)
|
|
||||||
|
|
||||||
|
|
||||||
def melange_bin_path(filename="."):
|
|
||||||
return os.path.join(melange_root_path(), "..", "bin", filename)
|
|
||||||
|
|
||||||
|
|
||||||
def melange_etc_path(filename="."):
|
|
||||||
return os.path.join(melange_root_path(), "..", "etc", "melange", filename)
|
|
||||||
|
@ -14,3 +14,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
import gettext
|
||||||
|
|
||||||
|
gettext.install('melange', unicode=1)
|
||||||
|
@ -15,14 +15,37 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mox
|
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||||
|
# The code below enables nosetests to work with i18n _() blocks
|
||||||
|
import __builtin__
|
||||||
|
setattr(__builtin__, '_', lambda x: x)
|
||||||
|
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
import mox
|
||||||
|
|
||||||
from melange.db import db_api
|
from melange.db import db_api
|
||||||
from melange.common import utils
|
from melange.common import utils
|
||||||
|
|
||||||
|
|
||||||
|
def melange_root_path():
|
||||||
|
return os.path.join(os.path.dirname(__file__), "..", "..")
|
||||||
|
|
||||||
|
|
||||||
|
def melange_bin_path(filename="."):
|
||||||
|
return os.path.join(melange_root_path(), "bin", filename)
|
||||||
|
|
||||||
|
|
||||||
|
def melange_etc_path(filename="."):
|
||||||
|
return os.path.join(melange_root_path(), "etc", "melange", filename)
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_file():
|
||||||
|
return melange_etc_path("melange.conf.sample")
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(unittest.TestCase):
|
class BaseTest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -18,17 +18,13 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import melange
|
from melange import tests
|
||||||
from melange.common import config
|
from melange.common import config
|
||||||
from melange.db import db_api
|
from melange.db import db_api
|
||||||
|
|
||||||
|
|
||||||
def test_config_file():
|
|
||||||
return melange.melange_etc_path("melange.conf.sample")
|
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
options = dict(config_file=test_config_file())
|
options = dict(config_file=tests.test_config_file())
|
||||||
_db_sync(options)
|
_db_sync(options)
|
||||||
_configure_db(options)
|
_configure_db(options)
|
||||||
|
|
||||||
@ -60,7 +56,7 @@ def execute(cmd, raise_error=True):
|
|||||||
|
|
||||||
# Make sure that we use the programs in the
|
# Make sure that we use the programs in the
|
||||||
# current source directory's bin/ directory.
|
# current source directory's bin/ directory.
|
||||||
env['PATH'] = melange.melange_bin_path() + ':' + env['PATH']
|
env['PATH'] = tests.melange_bin_path() + ':' + env['PATH']
|
||||||
process = subprocess.Popen(cmd,
|
process = subprocess.Popen(cmd,
|
||||||
shell=True,
|
shell=True,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
@ -26,8 +26,8 @@ from melange.tests import functional
|
|||||||
|
|
||||||
|
|
||||||
def run_melange_manage(command):
|
def run_melange_manage(command):
|
||||||
melange_manage = melange.melange_bin_path('melange-manage')
|
melange_manage = tests.melange_bin_path('melange-manage')
|
||||||
config_file = functional.test_config_file()
|
config_file = tests.test_config_file()
|
||||||
return functional.execute("%(melange_manage)s %(command)s "
|
return functional.execute("%(melange_manage)s %(command)s "
|
||||||
"--config-file=%(config_file)s" % locals())
|
"--config-file=%(config_file)s" % locals())
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ class TestDeleteDeallocatedIps(tests.BaseTest):
|
|||||||
days = config.Config.get('keep_deallocated_ips_for_days')
|
days = config.Config.get('keep_deallocated_ips_for_days')
|
||||||
self._push_back_deallocated_date(ip, days)
|
self._push_back_deallocated_date(ip, days)
|
||||||
|
|
||||||
script = melange.melange_bin_path('melange-delete-deallocated-ips')
|
script = tests.melange_bin_path('melange-delete-deallocated-ips')
|
||||||
config_file = functional.test_config_file()
|
config_file = tests.test_config_file()
|
||||||
functional.execute("{0} --config-file={1}".format(script, config_file))
|
functional.execute("{0} --config-file={1}".format(script, config_file))
|
||||||
|
|
||||||
self.assertIsNone(models.IpAddress.get(ip.id))
|
self.assertIsNone(models.IpAddress.get(ip.id))
|
||||||
|
@ -15,25 +15,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
|
||||||
# The code below enables nosetests to work with i18n _() blocks
|
|
||||||
import __builtin__
|
|
||||||
setattr(__builtin__, '_', lambda x: x)
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import webtest
|
import webtest
|
||||||
|
|
||||||
import melange
|
from melange import tests
|
||||||
from melange.common import config
|
from melange.common import config
|
||||||
from melange.common import utils
|
from melange.common import utils
|
||||||
from melange.common import wsgi
|
from melange.common import wsgi
|
||||||
from melange.db import db_api
|
from melange.db import db_api
|
||||||
|
|
||||||
|
|
||||||
def test_config_path():
|
|
||||||
return melange.melange_etc_path("melange.conf.sample")
|
|
||||||
|
|
||||||
|
|
||||||
def sanitize(data):
|
def sanitize(data):
|
||||||
serializer = wsgi.JSONDictSerializer()
|
serializer = wsgi.JSONDictSerializer()
|
||||||
return json.loads(serializer.serialize(data))
|
return json.loads(serializer.serialize(data))
|
||||||
@ -79,7 +70,7 @@ class TestApp(webtest.TestApp):
|
|||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
options = {"config_file": test_config_path()}
|
options = {"config_file": tests.test_config_file()}
|
||||||
conf = config.Config.load_paste_config("melangeapp", options, None)
|
conf = config.Config.load_paste_config("melangeapp", options, None)
|
||||||
|
|
||||||
db_api.drop_db(conf)
|
db_api.drop_db(conf)
|
||||||
|
@ -19,15 +19,15 @@ import routes
|
|||||||
import unittest
|
import unittest
|
||||||
import webtest
|
import webtest
|
||||||
|
|
||||||
|
from melange import tests
|
||||||
from melange.common import config
|
from melange.common import config
|
||||||
from melange.common import wsgi
|
from melange.common import wsgi
|
||||||
from melange.tests import unit
|
|
||||||
|
|
||||||
|
|
||||||
class TestExtensions(unittest.TestCase):
|
class TestExtensions(unittest.TestCase):
|
||||||
|
|
||||||
def test_extension_loads_with_melange_xmlns(self):
|
def test_extension_loads_with_melange_xmlns(self):
|
||||||
options = {'config_file': unit.test_config_path()}
|
options = {'config_file': tests.test_config_file()}
|
||||||
conf, app = config.Config.load_paste_app('melangeapi',
|
conf, app = config.Config.load_paste_app('melangeapi',
|
||||||
options, None)
|
options, None)
|
||||||
test_app = webtest.TestApp(app)
|
test_app = webtest.TestApp(app)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
import string
|
import string
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import mox
|
|
||||||
import netaddr
|
import netaddr
|
||||||
import routes
|
import routes
|
||||||
import webob.exc
|
import webob.exc
|
||||||
@ -41,7 +40,7 @@ class ControllerTestBase(tests.BaseTest):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ControllerTestBase, self).setUp()
|
super(ControllerTestBase, self).setUp()
|
||||||
conf, melange_app = config.Config.load_paste_app('melangeapp',
|
conf, melange_app = config.Config.load_paste_app('melangeapp',
|
||||||
{"config_file": unit.test_config_path()}, None)
|
{"config_file": tests.test_config_file()}, None)
|
||||||
self.app = unit.TestApp(melange_app)
|
self.app = unit.TestApp(melange_app)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,14 +19,13 @@ import webtest
|
|||||||
|
|
||||||
from melange.common import config
|
from melange.common import config
|
||||||
from melange import tests
|
from melange import tests
|
||||||
from melange.tests import unit
|
|
||||||
|
|
||||||
|
|
||||||
class TestVersionsController(tests.BaseTest):
|
class TestVersionsController(tests.BaseTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
conf, melange_app = config.Config.load_paste_app('melange',
|
conf, melange_app = config.Config.load_paste_app('melange',
|
||||||
{"config_file": unit.test_config_path()}, None)
|
{"config_file": tests.test_config_file()}, None)
|
||||||
self.test_app = webtest.TestApp(melange_app)
|
self.test_app = webtest.TestApp(melange_app)
|
||||||
super(TestVersionsController, self).setUp()
|
super(TestVersionsController, self).setUp()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user