def test_networks(): inp = StringIO( dedent("""\ network={ ssid="foo bar" psk="secret" eap=TLS } network = { ssid="nsa" psk="password" scan_ssid = 1 } """)) conf = WpaSupplicantConf(inp) assert conf.fields() == {} assert conf.networks() == OrderedDict([ ('foo bar', OrderedDict([ ("psk", '"secret"'), ("eap", "TLS"), ])), ('nsa', OrderedDict([ ("psk", '"password"'), ("scan_ssid", "1"), ])), ])
def test_full_config(): inp = StringIO( dedent("""\ country=NZ network={ ssid="foo bar" psk="secret" eap=TLS } update_config = 1 """)) conf = WpaSupplicantConf(inp) assert conf.fields() == OrderedDict([ ("country", "NZ"), ("update_config", "1"), ]) assert conf.networks() == OrderedDict([ ('foo bar', OrderedDict([ ("psk", '"secret"'), ("eap", "TLS"), ])), ])
def test_comments(): inp = StringIO( dedent("""\ # This should be ignored. country=NZ # So should this. """)) conf = WpaSupplicantConf(inp) assert conf.fields() == OrderedDict([ ("country", "NZ"), ])
def test_blank_lines(): inp = StringIO(dedent("""\ foo=1 bar=2 """)) conf = WpaSupplicantConf(inp) assert conf.fields() == OrderedDict([ ("foo", "1"), ("bar", "2"), ])
def test_fields(): inp = StringIO( dedent("""\ country=NZ ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config = 1 """)) conf = WpaSupplicantConf(inp) assert conf.fields() == OrderedDict([ ("country", "NZ"), ("ctrl_interface", "DIR=/var/run/wpa_supplicant GROUP=netdev"), ("update_config", "1"), ]) assert conf.networks() == {}
def test_empty(): conf = WpaSupplicantConf(StringIO("")) assert conf.fields() == {} assert conf.networks() == {}