summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qamper.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2020-07-31 02:07:37 +0200
committerManel Caro <mcaro@iseebcn.com>2020-07-31 02:07:37 +0200
commitd46bce422fd03cd57d1ba336361da17d6efb48db (patch)
treee5ec7aa1ee5d53a655ce121a7c2ddd95888fc989 /test-cli/test/tests/qamper.py
parent907b96801230e04d02575a3732a73e452089637b (diff)
downloadboard-d46bce422fd03cd57d1ba336361da17d6efb48db.zip
board-d46bce422fd03cd57d1ba336361da17d6efb48db.tar.gz
board-d46bce422fd03cd57d1ba336361da17d6efb48db.tar.bz2
TEST restructure
Diffstat (limited to 'test-cli/test/tests/qamper.py')
-rw-r--r--test-cli/test/tests/qamper.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/test-cli/test/tests/qamper.py b/test-cli/test/tests/qamper.py
index 58054c9..df340eb 100644
--- a/test-cli/test/tests/qamper.py
+++ b/test-cli/test/tests/qamper.py
@@ -5,6 +5,7 @@ from test.helpers.amper import Amper
class Qamper(unittest.TestCase):
params = None
__resultlist = None # resultlist is a python list of python dictionaries
+ dummytest = False
# varlist: undercurrent, overcurrent
def __init__(self, testname, testfunc, varlist):
@@ -21,8 +22,28 @@ class Qamper(unittest.TestCase):
raise Exception('overcurrent param inside Qamp must be defined')
self._testMethodDoc = testname
self.__resultlist = []
+ if "dummytest" in varlist:
+ self.dummytest = varlist["dummytest"]
+
+ def saveresultinfile(self, currentvalue):
+ # save result in a file
+ with open('/mnt/station_ramdisk/amper.txt', 'w') as outfile:
+ n = outfile.write("Current: {} A".format(currentvalue))
+ outfile.close()
+ self.__resultlist.append(
+ {
+ "description": "Amperimeter values",
+ "filepath": "/mnt/station_ramdisk/amper.txt",
+ "mimetype": "text/plain"
+ }
+ )
def execute(self):
+ if self.dummytest:
+ self.current = "0.0"
+ self.saveresultinfile(self.current)
+ return
+
amp = Amper()
# open serial connection
if not amp.open():
@@ -35,16 +56,7 @@ class Qamper(unittest.TestCase):
# get current value (in Amperes)
self.current = amp.getCurrent()
# save result in a file
- with open('/mnt/station_ramdisk/amper.txt', 'w') as outfile:
- n = outfile.write("Current: {} A".format(self.current))
- outfile.close()
- self.__resultlist.append(
- {
- "description": "Amperimeter values",
- "filepath": "/mnt/station_ramdisk/amper.txt",
- "mimetype": "text/plain"
- }
- )
+ self.saveresultinfile(self.current)
# close serial connection
amp.close()
# Check current range