Commit a03208a5 authored by Jay's avatar Jay
Browse files

initial stab at postgresql in tests

parent 5b617327
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ sudo: false
branches:
  only:
    - dev
    - testing

os:
  - linux
@@ -14,6 +15,19 @@ env:
  - PYTHON_VERSION=3.6
  - PYTHON_VERSION=3.7

# Setup a postgresql instance w/postgis
services:
  - postgresql
addons:
  postgresql: 9.6
  apt:
    packages:
    - postgresql-9.6-postgis-2.3

before_script:
  - psql -c 'create database travis_ci_test;' -U postgres
  - psql -d travis_ci_test -c "CREATE EXTENSION postgis;"
  
before_install:
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
@@ -34,11 +48,10 @@ before_install:
  - source activate test

  # Install dependencies
  - conda config --add channels menpo
  - conda config --add channels usgs-astrogeology
  - conda config --add channels conda-forge
  - conda env update -n test -f environment.yml
  - export PROJ_LIB=$CONDA_PREFIX/share/proj  
  - export autocnet_config=sample.yml

script:
  - pytest autocnet tests

+0 −0

Empty file added.

+57 −0
Original line number Diff line number Diff line
import pytest
from autocnet.io.db import model
from autocnet import Session, engine

@pytest.fixture
def tables():
    return engine.table_names()

@pytest.fixture
def session(tables, request):
    session = Session()

    def cleanup():
        for t in reversed(tables):
            session.execute(t.delete())
        session.commit()

    request.addfinalizer(cleanup)
    
    return session


def test_keypoints_exists(tables):
    assert model.Keypoints.__tablename__ in tables

def test_edges_exists(tables):
    assert model.Edges.__tablename__ in tables

def test_costs_exists(tables):
    assert model.Costs.__tablename__ in tables

def test_matches_exists(tables):
    assert model.Matches.__tablename__ in tables

def test_cameras_exists(tables):
    assert model.Cameras.__tablename__ in tables

def test_images_exists(tables):
    assert model.Images.__tablename__ in tables

def test_create_image():
    i = model.Images()
    session.add(i)
    session.commit()
    res_i = session.query(Images).first()
    print(i.id)
    print(res_i.id)
    session.close()

def test_overlay_exists(tables):
    assert model.Overlay.__tablename__ in tables

def test_points_exists(tables):
    assert model.Points.__tablename__ in tables

def test_measures_exists(tables):
    assert model.Measures.__tablename__ in tables
 No newline at end of file
+7 −7
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@ cluster:
### Database Configuration ###
database:
    type: 'postgresql'
    username: 'sample'
    password: 'sample'
    host: 'smalls'
    port: 8085
    pgbouncer_port: 8083
    username: 'postgres'
    password: ''
    host: 'localhost'
    port: 5432 # This is a mapped port when postgresql is containerized, e.g., 8085
    pgbouncer_port: 5432  # This is normally a different port, e.g., 8083
    # The name of the database to connect to.  Tables will be created inside this DB.
    name: 'jelysiumtest' # This needs to be all lowercase for PostGreSQL!
    name: 'travis_ci_test' # This needs to be all lowercase for PostGreSQL!
    # The number of seconds to wait while attemping to connect to the DB.
    timeout: 500

@@ -41,7 +41,7 @@ redis:

### Spatial Reference Setup ###
spatial:
    srid: 949900
    srid: 4326  # 949900; this is a custom SRID for Mars. For testing we use WGS84.
    semimajor_rad: 3396190  # in meters
    semiminor_rad: 3376200  # in meters
    proj4_str: '+proj:longlat +a:3396190 +b:3376200 +no_defs'