Commit 1217039e authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Adding SQLAlchemy tests to CircleCI suite

parent e6e698e3
......@@ -8,7 +8,7 @@ PY_SRC:=$(filter-out dmt/B_mappers/antlr.main.py dmt/A_mappers/Stubs.py, ${PY_SR
TYPING_FOLDER:=$(shell pip3 show typing | grep ^Location | sed 's,^.*: ,,')
export PYTHONPATH=${TYPING_FOLDER}
all: flake8 pylint mypy coverage
all: flake8 pylint mypy coverage testDB
flake8:
@echo Performing syntax checks via flake8...
......@@ -26,4 +26,8 @@ coverage:
@echo Performing coverage checks...
@$(MAKE) -C tests-coverage || exit 1
testDB:
@echo Performing database tests...
@$(MAKE) -C tests-sqlalchemy || exit 1
.PHONY: flake8 pylint mypy coverage
MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- Original definition by Alain
--T-POS ::= BOOLEAN
MyInt ::= INTEGER (0 .. 20)
My2ndInt ::= MyInt ( 1 .. 18)
MySeq ::= SEQUENCE {
anInt MyInt,
anotherInt My2ndInt
}
MyChoice ::= CHOICE {
anInt MyInt,
aReal REAL (0.0 .. 10.0)
}
AType ::= SEQUENCE {
blArray SEQUENCE (SIZE(10)) OF BOOLEAN
}
MySuperSeq ::= SEQUENCE {
aSeq MySeq,
anotherSeq MySeq,
anArray T-ARR3,
aString OCTET STRING (SIZE(1..10))
}
My2ndAType ::= AType
TypeEnumerated ::= ENUMERATED {
red(0),
green(1),
blue(2)
}
My2ndEnumerated ::= TypeEnumerated
TypeNested ::= SEQUENCE {
intVal INTEGER(0..10),
int2Val INTEGER(-10..10),
int3Val MyInt (10..12),
intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3),
realArray SEQUENCE (SIZE (10)) OF REAL (0.1 .. 3.14),
octStrArray SEQUENCE (SIZE (10)) OF OCTET STRING (SIZE(1..10)),
boolArray SEQUENCE (SIZE (10)) OF T-BOOL,
enumArray SEQUENCE (SIZE (10)) OF TypeEnumerated,
enumValue TypeEnumerated,
enumValue2 ENUMERATED {
truism(0),
falsism(1)
},
label OCTET STRING (SIZE(10..40)),
bAlpha T-BOOL,
bBeta BOOLEAN,
sString T-STRING,
arr T-ARR,
arr2 T-ARR2
}
My2ndTypeNested ::= TypeNested
T-POS ::= CHOICE {
longitude REAL(-180.0..180.0),
latitude REAL(-90.0..90.0),
height REAL(30000.0..45000.0),
subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested,
label OCTET STRING (SIZE(50)),
intArray T-ARR,
myIntSet T-SET,
myIntSetOf T-SETOF,
anInt My2ndInt
}
T-POS-SET ::= SET {
longitude REAL(-180.0..180.0),
latitude REAL(-90.0..90.0),
height REAL(30000.0..45000.0),
subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested,
label OCTET STRING (SIZE(20..50)),
intArray T-ARR,
myIntSet T-SET,
myIntSetOf T-SETOF
}
T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..32764)
My2ndArr ::= T-ARR
T-ARR2 ::= SEQUENCE (SIZE (5..6)) OF REAL (0.1 .. 4.2)
T-ARR3 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 39.2)
T-ARR4 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 4.3)
T-SET ::= SET {
data1 INTEGER(0..131071),
data2 REAL(-100.0 .. 10.0),
data3 INTEGER(-1024..1024),
data4 INTEGER(-1310720..131071)
}
T-SETOF ::= SET (SIZE (5..6)) OF INTEGER (0..4)
T-BOOL ::= BOOLEAN
My2ndBool ::= T-BOOL
T-INT ::= INTEGER (0..50)
T-REAL ::= REAL (-3.14..3.14)
My2ndReal ::= T-REAL
T-STRING ::= OCTET STRING (SIZE(10..15))
My2ndString ::= T-STRING
T-FIXEDSTRING ::= OCTET STRING (SIZE(15))
T-META ::= T-POS
END
all: cleanDB test
cleanDB:
# PostgreSQL
echo 'drop database circle_test; create database circle_test;' | psql -h 127.0.0.1 -U ubuntu postgres || exit 1
rm -f sql.log
#
# MySQL (is a toy - disabled related tests)
# echo 'drop database test; create database test;' | mysql -u taste || exit 1
#
# SQLite
rm -f test.db
clean:
rm -rf verifier/asn2dataModel verifier/lotsofdatatypes_model.* */*.pyc verifier/LotsOfDataTypes.asn .coverage
$(MAKE) cleanDB
build:
cd verifier/ ; if [ ! -d asn2dataModel ] ; then mkdir -p asn2dataModel ; [ ! -h LotsOfDataTypes.asn ] && ln -s ../LotsOfDataTypes.asn ; LC_ALL=C asn2dataModel -o asn2dataModel -toPython LotsOfDataTypes.asn ; fi
cd verifier/asn2dataModel || exit 1 && make -f Makefile.python
cd verifier ; LC_ALL=C asn2dataModel -toSqlalchemy -o asn2dataModel/ LotsOfDataTypes.asn
touch verifier/asn2dataModel/__init__.py
debug: |build
ipdb -m verifier.testSQLengines.py
test: |build
python -m verifier.testSQLengines
print:
@for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \
echo "========" ; \
echo PostgreSQL Content of $$i ; \
echo "========" ; \
echo "select * from \"$$i\" " | psql -h 127.0.0.1 -U ubuntu circle_test ; \
done
# @for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \
# echo "========" ; \
# echo MySQL Content of $$i ; \
# echo "========" ; \
# echo "select * from $$i " | mysql -u taste test ; \
# done | less
@for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \
echo "========" ; \
echo SQLite Content of $$i ; \
echo "========" ; \
echo "select * from $$i ;" | sqlite3 test.db ; \
done
from sqlalchemy import MetaData
from sqlalchemy_schemadisplay import create_schema_graph
# create the pydot graph object by autoloading all tables via a bound metadata object
graph = create_schema_graph(metadata=MetaData('postgresql+psycopg2://taste:tastedb@localhost/test'),
show_datatypes=False, # The image would get nasty big if we'd show the datatypes
show_indexes=False, # ditto for indexes
rankdir='LR', # From left to right (instead of top to bottom)
concentrate=False # Don't try to join the relation lines together
)
graph.write_png('/home/assert/Desktop/C_DRIVE/work/dbschema.png') # write out the file
2004-04-28 21:50 carrer
* pydot.py: Some of the changes already made should allow pydot to
run on OSX. Bumped version to 0.9.2
2004-04-24 17:52 carrer
* setup.py: Added more metainformation to the distribution.
2004-04-24 17:51 carrer
* pydot.py: Added support for circo and fdp. Fixed piping mechanism
to not to capture stderr.
2004-04-24 13:26 carrer
* ChangeLog, LICENSE, MANIFEST, README, setup.py: Adding
suplementary files to the distribution to the CVS.
2004-04-24 12:57 carrer
* pydot.py: Bumped version to 0.9.1
2004-04-24 01:36 carrer
* pydot.py: Implemented tweaks suggested by John B. Cole to handle
non-str nodes, converting them to strings.
2004-04-24 01:10 carrer
* pydot.py: Applied patch for Windows support by Kent Johnson.
2004-04-24 01:05 carrer
* pydot.py: Fixed to properly handle unicode strings in attributes.
2004-04-20 00:06 carrer
* pydot.py:
Fixed silly error in graph_from_edges. When pasting the function
into the code, the references to the pydot module were not
removed, which are no longer needed since we now are _in_ the
module.
2004-04-19 23:33 carrer
* pydot.py:
Added support to write files with the desired output format with
write_[format]
2004-04-19 22:53 carrer
* pydot.py:
Done some clean up, no major changes.
2004-04-08 00:22 carrer
* pydot.py:
Initial revision.
2004-04-08 00:22 carrer
* pydot.py: Initial revision
Copyright (c) 2004 Ero Carrera
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
pydot - Python interface to Graphviz's Dot language
Ero Carrera (c) 2004-2007
ero@dkbza.org
This code is distributed under the MIT license.
Requirements:
-------------
pyparsing: pydot requires the pyparsing module in order to be
able to load DOT files.
GraphViz: is needed in order to render the graphs into any of
the plethora of output formats supported.
Installation:
-------------
Should suffice with doing:
python setup.py install
Needless to say, no installation is needed just to use the module. A mere:
import pydot
should do it, provided that the directory containing the modules is on Python
module search path.
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
unset pydoc
# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/assert/tool-src/DMT/tests-sqlalchemy/sqlalchemy_schemadisplay"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "$PYTHONHOME" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
alias pydoc="python -m pydoc"
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/home/assert/tool-src/DMT/tests-sqlalchemy/sqlalchemy_schemadisplay"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
if ("" != "") then
set env_name = ""
else
if (`basename "$VIRTUAL_ENV"` == "__") then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
endif
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt"