summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qwifi.py
blob: 188e300b3021f274298c2c52edcf3c7ce91602a6 (plain)
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
from test.helpers.syscmd import SysCommand
import unittest

class Qwifi(unittest.TestCase):

    def __init__(self, testname, testfunc, varlist):
        super(Qwifi, self).__init__(testfunc)
        if "signal" in varlist:
            self.__signal = varlist["signal"]
        else:
            raise Exception('signal param inside Qwifi must be defined')
        self._testMethodDoc = testname

    def execute(self):
        str_cmd= "iw wlan0 link"
        wifi_stats = SysCommand("wifi_stats", str_cmd)
        if wifi_stats.execute() == 0:
            w_stats = wifi_stats.getOutput().decode('ascii').splitlines()
            #self._longMessage = str(self.__raw_out).replace("'", "")
            if not w_stats[0] == "Not connected.":
                signal_st = w_stats[5].split(" ")[1]
                try:
                    int(signal_st)
                    if -1*int(signal_st) > int(self.__signal):
                        self.fail("failed: signal to server lower than expected")
                except ValueError:
                    self.fail("failed: error output (Bad connection?)")
            else:
                self.fail("failed: error output (Bad connection?)")
            #tx_brate = float(w_stats[6].split(" ")[2])
        else:
            self.fail("failed: couldn't execute iw command")