-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstatus_test.py
executable file
·57 lines (44 loc) · 1.33 KB
/
status_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020-2021 by Murray Altheim. All rights reserved. This file is part
# of the Robot Operating System project, released under the MIT License. Please
# see the LICENSE file included as part of this package.
#
# This tests the Status task, which turns on and off the status LED.
#
import pytest
import os, sys, signal, time, threading
from colorama import init, Fore, Style
init()
from lib.config_loader import ConfigLoader
from lib.logger import Level
from lib.status import Status
_status = None
# ..............................................................................
@pytest.mark.unit
def test_status():
print(Fore.CYAN + "status task running...")
# read YAML configuration
_loader = ConfigLoader(Level.INFO)
filename = 'config.yaml'
_config = _loader.configure(filename)
_status = Status(_config, Level.INFO)
_status.blink(True)
for i in range(5):
print(Fore.CYAN + "blinking...")
time.sleep(1)
_status.blink(False)
_status.enable()
time.sleep(5)
_status.close()
# call main ......................................
def main():
try:
test_status()
except KeyboardInterrupt:
print(Fore.RED + 'Ctrl-C caught: interrupted.')
finally:
pass
if __name__== "__main__":
main()