Skip to content

Commit

Permalink
Adding postgres to the build matrix (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jun 12, 2016
1 parent c490138 commit fa13b77
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ env:
matrix:
#- TOX_ENV=py27-mysql
- TOX_ENV=py27-sqlite
#- TOX_ENV=py27-postgres
- TOX_ENV=py27-postgres
- TOX_ENV=py34-sqlite
- TOX_ENV=py34-mysql
- TOX_ENV=py34-postgres
- TOX_ENV=javascript
before_install:
- npm install -g npm@'>=2.7.1'
Expand Down
6 changes: 3 additions & 3 deletions caravel/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def load_birth_names():
print("Done loading table!")
print("-" * 80)

print("Creating table reference")
print("Creating table [birth_names] reference")
obj = db.session.query(TBL).filter_by(table_name='birth_names').first()
if not obj:
obj = TBL(table_name='birth_names')
Expand Down Expand Up @@ -829,7 +829,7 @@ def load_unicode_test_data():
print("Done loading table!")
print("-" * 80)

print("Creating table reference")
print("Creating table [unicode_test] reference")
obj = db.session.query(TBL).filter_by(table_name='unicode_test').first()
if not obj:
obj = TBL(table_name='unicode_test')
Expand Down Expand Up @@ -908,7 +908,7 @@ def load_random_time_series_data():
print("Done loading table!")
print("-" * 80)

print("Creating table reference")
print("Creating table [random_time_series] reference")
obj = db.session.query(TBL).filter_by(table_name='random_time_series').first()
if not obj:
obj = TBL(table_name='random_time_series')
Expand Down
2 changes: 1 addition & 1 deletion caravel/migrations/versions/4e6a06bad7a8_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def upgrade():
sa.Column('changed_on', sa.DateTime(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('datasource_name', sa.String(length=250), nullable=True),
sa.Column('column_name', sa.String(length=255), sa.ForeignKey("datasources.datasource_name"), nullable=True),
sa.Column('column_name', sa.String(length=255), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('type', sa.String(length=32), nullable=True),
sa.Column('groupby', sa.Boolean(), nullable=True),
Expand Down
1 change: 1 addition & 0 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ def sync_to_db(cls, name, cluster):
flasher("Refreshing datasource [{}]".format(name), "info")
session.flush()
datasource.cluster = cluster
session.flush()

cols = datasource.latest_metadata()
if not cols:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all_files = 1
upload-dir = docs/_build/html

[nosetests]
verbosity=4
verbosity=3
detailed-errors=1
with-coverage=1
nocapture=1
Expand Down
25 changes: 12 additions & 13 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import doctest
import json
import imp
import logging
import os
import unittest
from mock import Mock, patch
Expand Down Expand Up @@ -70,14 +69,12 @@ def login(self, username='admin', password='general'):
assert 'Welcome' in resp.data.decode('utf-8')

def logout(self):
resp = self.client.get('/logout/', follow_redirects=True)
self.client.get('/logout/', follow_redirects=True)

'''
def test_welcome(self):
self.login()
resp = self.client.get('/caravel/welcome')
assert 'Welcome' in resp.data.decode('utf-8')
'''

def setup_public_access_for_dashboard(self, table_name):
public_role = appbuilder.sm.find_role('Public')
Expand All @@ -101,9 +98,13 @@ class CoreTests(CaravelTestCase):
def __init__(self, *args, **kwargs):
# Load examples first, so that we setup proper permission-view relations
# for all example data sources.
self.load_examples()
super(CoreTests, self).__init__(*args, **kwargs)
self.table_ids = {tbl.table_name: tbl.id for tbl in (

@classmethod
def setUpClass(cls):
cli.load_examples(load_test_data=True)
utils.init(caravel)
cls.table_ids = {tbl.table_name: tbl.id for tbl in (
db.session
.query(models.SqlaTable)
.all()
Expand All @@ -115,16 +116,14 @@ def setUp(self):
def tearDown(self):
pass

def load_examples(self):
cli.load_examples(load_test_data=True)

def test_save_slice(self):
self.login(username='admin')

slice_id = (
slc = (
db.session.query(models.Slice.id)
.filter_by(slice_name="Energy Sankey")
.scalar())
.first())
slice_id = slc.id

copy_name = "Test Sankey Save"
tbl_id = self.table_ids.get('energy_usage')
Expand Down Expand Up @@ -152,7 +151,7 @@ def test_slices(self):
(slc.slice_name, 'csv_endpoint', slc.viz.csv_endpoint),
]
for name, method, url in urls:
logging.info("[{name}]/[{method}]: {url}".format(**locals()))
print("[{name}]/[{method}]: {url}".format(**locals()))
self.client.get(url)

def test_dashboard(self):
Expand Down Expand Up @@ -228,7 +227,7 @@ def test_public_user_dashboard_access(self):
# Try access after adding appropriate permissions.
resp = self.client.get('/slicemodelview/list/')
data = resp.data.decode('utf-8')
assert 'birth_names</a>' in data
assert 'birth_names' in data

resp = self.client.get('/dashboardmodelview/list/')
data = resp.data.decode('utf-8')
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ basepython = python2.7
setenv =
CARAVEL__SQLALCHEMY_DATABASE_URI = postgresql+psycopg2://postgres@localhost/caravel

[testenv:py34-postgres]
basepython = python3.4
setenv =
CARAVEL__SQLALCHEMY_DATABASE_URI = postgresql+psycopg2://postgres@localhost/caravel

[testenv:javascript]
commands = {toxinidir}/caravel/assets/js_build.sh

0 comments on commit fa13b77

Please sign in to comment.