summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-08-31 12:21:33 +0200
committerJuergen Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-11-30 10:01:20 +0100
commit05ea9b3cfbc6a2147ae7ff98dfc43911471f973b (patch)
tree5d2ac67e9f10a15f38648bdd7d9af18e839b8460
parent1050c436d1283848763bd3c50d6548747f8c2c22 (diff)
downloadqtivi-qface-05ea9b3cfbc6a2147ae7ff98dfc43911471f973b.tar.gz
Fixed the tests again. Copied the face files into the tests folder to make them more contained.
-rwxr-xr-xcli.py2
-rw-r--r--qface/generator.py7
-rw-r--r--tests/in/climate.qface111
-rw-r--r--tests/in/test.qface33
-rw-r--r--tests/in/tuner.qface54
-rw-r--r--tests/test_climate.py9
-rw-r--r--tests/test_generator.py11
-rw-r--r--tests/test_parser.py8
8 files changed, 216 insertions, 19 deletions
diff --git a/cli.py b/cli.py
index 97a06d7..2e2d24a 100755
--- a/cli.py
+++ b/cli.py
@@ -32,7 +32,7 @@ def antlr():
@cli.command()
def test():
- sh('python3 -m pytest -v -s -l --pdb')
+ sh('python3 -m pytest -v -s -l')
@cli.command()
diff --git a/qface/generator.py b/qface/generator.py
index 217dafd..7ee80d0 100644
--- a/qface/generator.py
+++ b/qface/generator.py
@@ -23,9 +23,10 @@ def upper_first_filter(s):
class Generator(object):
- def __init__(self, searchpath: str ='templates'):
- searchpath = Path(searchpath).resolve().as_posix()
- self.env = Environment(loader=FileSystemLoader(searchpath), trim_blocks=True, lstrip_blocks=True)
+ def __init__(self, searchpath: str):
+ if searchpath:
+ searchpath = Path(searchpath).resolve().as_posix()
+ self.env = Environment(loader=FileSystemLoader(searchpath), trim_blocks=True, lstrip_blocks=True)
self.register_filters()
def get_template(self, name: str):
diff --git a/tests/in/climate.qface b/tests/in/climate.qface
new file mode 100644
index 0000000..d3b6091
--- /dev/null
+++ b/tests/in/climate.qface
@@ -0,0 +1,111 @@
+package vehicle.climate;
+
+/*!
+ * The ClimateControl provides a QML interface to the climate control
+ * of the vehicle.
+ */
+service ClimateControl {
+ /*!
+ * Value is true if the air conditioning is enabled.
+ */
+ bool airConditioning;
+ /*!
+ * value holds the airflow directions
+ */
+ AirflowDirections airflowDirections;
+ /*!
+ * value is true if the heater is enabled.
+ */
+ bool heater;
+ /*!
+ * value holds the fan speed level, where the level can be between
+ * minimumValue(off) to maximumValue (strongest).
+ */
+ int fanSpeedLevel;
+ /*!
+ * value holds the steering wheel heater level, where the level can
+ * be between minimumValue(off) to maximumValue (warmest).
+ */
+ int steeringWheelHeater;
+ /*!
+ * value holds the target temperature of the zone expressed
+ * in centigrades, where the temperature can be between
+ * minimumValue(coolest) to maximumValue (warmest).
+ */
+ int targetTemperature;
+ /*!
+ * value holds the seat cooler level, where the level can be
+ * between minimumValue(off) to maximumValue (coolest).
+ */
+ int seatCooler;
+ /*!
+ * value holds the seat heater level, where the level can be between
+ * minimumValue(off) to maximumValue (warmest).
+ */
+ int seatHeater;
+ /*!
+ * value holds the outside temperature of the zone expressed in
+ * centigrades, where the temperature can be between
+ * minimumValue(coolest) to maximumValue (warmest).
+ */
+ int outsideTemperature;
+ /*!
+ * value is true if the zone synchronization is enabled.
+ *
+ * Which zones and properties are synchronized is controlled
+ * by the backend implementing it.
+ */
+ bool zoneSynchronization;
+ /*!
+ * value is true if defrost is enabled. Usually that means that the fans
+ * are on the highest level to remove ice from the windshield.
+ */
+ bool defrost;
+ /*!
+ * value holds the recirculation mode
+ */
+ RecirculationMode recirculationMode;
+ /*!
+ * value is true if the recirculation is currently running.
+ */
+ bool recirculation;
+ /*!
+ * value holds the sensitivity level of the recirculation
+ * system when the recirculationMode is set to AutoRecirculation,
+ * where the level can be between minimumValue(least sensitive)
+ * to maximumValue(most sensitive).
+ */
+ int recirculationSensitivityLevel;
+ /*!
+ * value holds the climate mode
+ */
+ ClimateMode climateMode;
+ /*!
+ * value holds the intensity level of the fan when the climateMode
+ * is set to AutoClimate, where the level can be between
+ * minimumValue(least intensity) to maximumValue(most intensity).
+ */
+ int automaticClimateFanIntensityLevel;
+}
+
+flag AirflowDirection {
+ Windshield = 1,
+ Dashboard = 2,
+ Floor = 4
+}
+
+enum RecirculationMode {
+ RecirculationOff = 0x0,
+ RecirculationOn = 0x1,
+ AutoRecirculation = 0x2
+}
+
+enum ClimateMode {
+ ClimateOff = 0x0,
+ ClimateOn = 0x1,
+ AutoClimate = 0x2
+}
+
+service Extra {
+
+}
diff --git a/tests/in/test.qface b/tests/in/test.qface
new file mode 100644
index 0000000..399bb6d
--- /dev/null
+++ b/tests/in/test.qface
@@ -0,0 +1,33 @@
+package com.pelagicore.test;
+
+service ContactService {
+ State state;
+ int intValue;
+ readonly string stringValue;
+ bool boolValue;
+ real realValue;
+ Contact currentContact;
+
+ void addContact(Contact contact);
+ void removeContact(Contact contact);
+ void updateContact(Contact contact);
+
+ list<Contact> contactList;
+ model<Contact> contactModel;
+}
+
+enum State {
+ Null = 0x00,
+ Loading = 0x01,
+ Ready = 0x02,
+ Failure = 0x03
+}
+
+/*!
+ * The contact information
+ */
+struct Contact {
+ string name;
+ int age;
+ bool isMarried;
+}
diff --git a/tests/in/tuner.qface b/tests/in/tuner.qface
new file mode 100644
index 0000000..54a6381
--- /dev/null
+++ b/tests/in/tuner.qface
@@ -0,0 +1,54 @@
+package entertainment.tuner;
+
+/*! Service Tuner */
+service Tuner {
+ /*! attribute currentStation */
+ readonly Station currentStation;
+ /*! operation nextStation */
+ void nextStation();
+ /*! operation previousStation */
+ void previousStation();
+ /*! operation updateCurrentStation */
+ void updateCurrentStation(int stationId);
+
+ list<int> primitiveList;
+ list<Station> complexList;
+ model<int> primitiveModel;
+ model<Station> complexModel;
+}
+
+/*! enum State */
+enum State {
+ /*! value State.Null */
+ Null=0,
+ /*! value State.Loading */
+ Loading=1,
+ /*! value State.Ready */
+ Ready=2,
+ /*! value State.Error */
+ Error=3
+}
+
+/*! enum Waveband */
+enum Waveband {
+ /*! value Waveband.FM */
+ FM=0,
+ /*! value Waveband.AM */
+ AM=1
+}
+
+flag Features {
+ Mono = 0x1,
+ Stereo = 0x2,
+}
+
+/*! struct Station */
+struct Station {
+ /*! member stationId */
+ int stationId;
+ /*! member name */
+ string name;
+}
+
+
+
diff --git a/tests/test_climate.py b/tests/test_climate.py
index 54769e7..ec660f3 100644
--- a/tests/test_climate.py
+++ b/tests/test_climate.py
@@ -1,5 +1,4 @@
-from qface.idl.domain import System
-from qface.generator import FileSystem, Generator
+from qface.generator import FileSystem
import logging
import logging.config
from pathlib import Path
@@ -9,12 +8,12 @@ logging.basicConfig()
log = logging.getLogger(__name__)
-examples = Path('./examples')
-log.debug('examples folder: {0}'.format(examples.absolute()))
+inputPath = Path('tests/in')
+log.debug('input path folder: {0}'.format(inputPath.absolute()))
def load_system():
- path = examples / 'vehicle.climate.ClimateControl.qface'
+ path = inputPath / 'climate.qface'
return FileSystem.parse_document(path)
diff --git a/tests/test_generator.py b/tests/test_generator.py
index 2302eca..c346753 100644
--- a/tests/test_generator.py
+++ b/tests/test_generator.py
@@ -1,4 +1,3 @@
-from qface.idl.domain import System
from qface.generator import FileSystem, Generator
import logging
import logging.config
@@ -9,18 +8,18 @@ logging.basicConfig()
log = logging.getLogger(__name__)
-examples = Path('./examples')
-log.debug('examples folder: {0}'.format(examples.absolute()))
+inputPath = Path('tests/in')
+log.debug('input path folder: {0}'.format(inputPath.absolute()))
def loadSystem():
- path = examples / 'entertainment.tuner.Tuner.qface'
+ path = inputPath / 'tuner.qface'
return FileSystem.parse_document(path)
def test_gen_package():
system = loadSystem()
- gen = Generator()
+ gen = Generator(searchpath='tests/templates')
template = "{{package}}"
package = system.lookup_package('entertainment.tuner')
text = gen.apply(template, {"package": package})
@@ -29,7 +28,7 @@ def test_gen_package():
def test_gen_service():
system = loadSystem()
- gen = Generator()
+ gen = Generator(searchpath='tests/templates')
template = """
{%- for service in package.services -%}
{{service}}
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 2edb1d6..0f5c1ee 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -9,18 +9,18 @@ logging.basicConfig()
log = logging.getLogger(__name__)
-examples = Path('./examples')
-log.debug('examples folder: {0}'.format(examples.absolute()))
+inputPath = Path('tests/in')
+log.debug('input path folder: {0}'.format(inputPath.absolute()))
def loadTuner():
- path = examples / 'entertainment.tuner.Tuner.qface'
+ path = inputPath / 'tuner.qface'
return FileSystem.parse_document(path)
def test_parse():
log.debug('test parse')
- names = FileSystem.find_files(examples, '*.qface')
+ names = FileSystem.find_files(inputPath, '*.qface')
# import pdb; pdb.set_trace()
system = System()
for name in names: