Disable cache for cmd testcases
Right now, we don't actually need a cache for our current tests, so for now we'll disable it. Future cmd tests, will enable this making sure we have the proper coverage. Change-Id: If7a25c3281fd57257473054348555aa06b5b6d95 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
319600e106
commit
6316206005
@ -24,10 +24,12 @@ class Cache(object):
|
||||
|
||||
def __init__(self, cachedir):
|
||||
cache_dir = self._get_cache_dir(cachedir)
|
||||
filename = os.path.join(cache_dir, 'cache.dbm')
|
||||
LOG.debug('Using cache: %s' % filename)
|
||||
self.region = make_region().configure(
|
||||
'dogpile.cache.dbm',
|
||||
arguments={
|
||||
'filename': os.path.join(cache_dir, 'cache.dbm')
|
||||
'filename': filename,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -15,12 +15,15 @@
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import yaml
|
||||
|
||||
from slugify import slugify
|
||||
|
||||
from grafana_dashboards.schema.dashboard import Dashboard
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class YamlParser(object):
|
||||
|
||||
@ -31,8 +34,10 @@ class YamlParser(object):
|
||||
data = self.data.get('dashboard', {}).get(slug, None)
|
||||
md5 = None
|
||||
if data:
|
||||
content = json.dumps(data)
|
||||
# Sort json keys to help our md5 hash are constant.
|
||||
content = json.dumps(data, sort_keys=True)
|
||||
md5 = hashlib.md5(content.encode('utf-8')).hexdigest()
|
||||
LOG.debug('Dashboard %s: %s' % (slug, md5))
|
||||
|
||||
return data, md5
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
@ -22,6 +23,8 @@ from tests.base import TestCase
|
||||
|
||||
|
||||
class TestCase(TestCase):
|
||||
configfile = os.path.join(
|
||||
os.path.dirname(__file__), 'fixtures/cmd/grafyaml.conf')
|
||||
|
||||
def shell(self, argstr, exitcodes=(0,)):
|
||||
orig = sys.stdout
|
||||
@ -29,7 +32,10 @@ class TestCase(TestCase):
|
||||
try:
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stderr = six.StringIO()
|
||||
argv = ['grafana-dashboards']
|
||||
argv = [
|
||||
'grafana-dashboards',
|
||||
'--config-file=%s' % self.configfile,
|
||||
]
|
||||
argv += argstr.split()
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.argv', argv))
|
||||
cmd.main()
|
||||
|
5
tests/fixtures/cmd/grafyaml.conf
vendored
Normal file
5
tests/fixtures/cmd/grafyaml.conf
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
[grafana]
|
||||
url = http://grafana.example.org
|
||||
|
||||
[cache]
|
||||
enabled = false
|
Loading…
x
Reference in New Issue
Block a user