def set_p2p_interface(self, R2): wpacli = WpaCli() if wpacli.check_p2p_interface(): self.logger.info("Already set a p2p interface.") p2p_interface = wpacli.get_p2p_interface() else: self.create_p2p_interface(R2) sleep(3) p2p_interface = wpacli.get_p2p_interface() if p2p_interface is None: raise WpaException("Can not create P2P Wifi interface.") self.logger.info("Start p2p interface: {} address {}".format( p2p_interface, self.config.myaddress)) os.system("sudo ifconfig {} {}".format(p2p_interface, self.config.myaddress)) self.wlandev = p2p_interface
def test_wpa_p2p_interface(monkeypatch): def mockreturn(self, *arg): assert arg == ('interface', ) return [ "Selected interface 'p2p-wlp4s0'", "Available interfaces:", "p2p-wlp4s0", "wlp4s0" ] monkeypatch.setattr(WpaCli, "cmd", mockreturn) wpacli = WpaCli() result = wpacli.get_p2p_interface() assert result == "p2p-wlp4s0"