-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for updated functions in proxy
- test_has_service_state_in - test_extract_manual_proxy
- Loading branch information
1 parent
462e2c4
commit dfc7dee
Showing
7 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd kiosk | ||
nix-shell --run "python -m pytest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
steps: | ||
- label: "Kiosk browser" | ||
command: ".buildkite/kiosk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
cd "$(dirname "$0")/.." | ||
|
||
python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import dbus | ||
from kiosk_browser import proxy | ||
|
||
# Mocks | ||
|
||
service_idle = dbus.Struct((dbus.ObjectPath('/net/connman/service/wifi_a0510b58100d_517561657374791f6e657e2d4d7060046065_managed_psk'), dbus.Dictionary({dbus.String('Type'): dbus.String('wifi', variant_level=1), dbus.String('Security'): dbus.Array([dbus.String('psk')], signature=dbus.Signature('s'), variant_level=1), dbus.String('State'): dbus.String('idle', variant_level=1), dbus.String('Strength'): dbus.Byte(54, variant_level=1), dbus.String('Favorite'): dbus.Boolean(False, variant_level=1), dbus.String('Immutable'): dbus.Boolean(False, variant_level=1), dbus.String('AutoConnect'): dbus.Boolean(False, variant_level=1), dbus.String('Name'): dbus.String('Super-Network', variant_level=1), dbus.String('Ethernet'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Interface'): dbus.String('wlp2s0', variant_level=1), dbus.String('Address'): dbus.String('B7:71:01:51:10:AD', variant_level=1), dbus.String('MTU'): dbus.UInt16(1500, variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Nameservers'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Nameservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Proxy'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Proxy.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('direct', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('mDNS'): dbus.Boolean(False, variant_level=1), dbus.String('mDNS.Configuration'): dbus.Boolean(False, variant_level=1), dbus.String('Provider'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1)}, signature=dbus.Signature('sv'))), signature=None) | ||
|
||
service_online_direct = dbus.Struct((dbus.ObjectPath('/net/connman/service/wifi_a0510b58100d_517561657374791f6e657e2d4d7060046065_managed_psk'), dbus.Dictionary({dbus.String('Type'): dbus.String('wifi', variant_level=1), dbus.String('Security'): dbus.Array([dbus.String('psk')], signature=dbus.Signature('s'), variant_level=1), dbus.String('State'): dbus.String('online', variant_level=1), dbus.String('Strength'): dbus.Byte(53, variant_level=1), dbus.String('Favorite'): dbus.Boolean(True, variant_level=1), dbus.String('Immutable'): dbus.Boolean(False, variant_level=1), dbus.String('AutoConnect'): dbus.Boolean(True, variant_level=1), dbus.String('Name'): dbus.String('Super-Network', variant_level=1), dbus.String('Ethernet'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Interface'): dbus.String('wlp2s0', variant_level=1), dbus.String('Address'): dbus.String('B7:71:01:51:10:AD', variant_level=1), dbus.String('MTU'): dbus.UInt16(1500, variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1), dbus.String('Address'): dbus.String('192.168.1.1', variant_level=1), dbus.String('Netmask'): dbus.String('255.255.255.0', variant_level=1), dbus.String('Gateway'): dbus.String('192.168.1.254', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Address'): dbus.String('0a21:e0f:5ba:7390:3304:872c:531c:cbad', variant_level=1), dbus.String('PrefixLength'): dbus.Byte(64, variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Nameservers'): dbus.Array([dbus.String('192.168.1.254')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Nameservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Proxy'): dbus.Dictionary({dbus.String('Method'): dbus.String('direct', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Proxy.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('direct', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('mDNS'): dbus.Boolean(False, variant_level=1), dbus.String('mDNS.Configuration'): dbus.Boolean(False, variant_level=1), dbus.String('Provider'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1)}, signature=dbus.Signature('sv'))), signature=None) | ||
|
||
service_online_proxy = dbus.Struct((dbus.ObjectPath('/net/connman/service/wifi_a0510b58100d_517561657374791f6e657e2d4d7060046065_managed_psk'), dbus.Dictionary({dbus.String('Type'): dbus.String('wifi', variant_level=1), dbus.String('Security'): dbus.Array([dbus.String('psk')], signature=dbus.Signature('s'), variant_level=1), dbus.String('State'): dbus.String('online', variant_level=1), dbus.String('Strength'): dbus.Byte(51, variant_level=1), dbus.String('Favorite'): dbus.Boolean(True, variant_level=1), dbus.String('Immutable'): dbus.Boolean(False, variant_level=1), dbus.String('AutoConnect'): dbus.Boolean(True, variant_level=1), dbus.String('Name'): dbus.String('Super-Network', variant_level=1), dbus.String('Ethernet'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Interface'): dbus.String('wlp2s0', variant_level=1), dbus.String('Address'): dbus.String('B7:71:01:51:10:AD', variant_level=1), dbus.String('MTU'): dbus.UInt16(1500, variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1), dbus.String('Address'): dbus.String('192.168.1.1', variant_level=1), dbus.String('Netmask'): dbus.String('255.255.255.0', variant_level=1), dbus.String('Gateway'): dbus.String('192.168.1.254', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Address'): dbus.String('0a21:e0f:5ba:7390:3304:872c:531c:cbad', variant_level=1), dbus.String('PrefixLength'): dbus.Byte(64, variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Nameservers'): dbus.Array([dbus.String('192.168.1.254')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Nameservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Proxy'): dbus.Dictionary({dbus.String('Servers'): dbus.Array([dbus.String('http://proxy.dividat.com:1234')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Excludes'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Method'): dbus.String('manual', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Proxy.Configuration'): dbus.Dictionary({dbus.String('Servers'): dbus.Array([dbus.String('http://proxy.dividat.com')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Method'): dbus.String('manual', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('mDNS'): dbus.Boolean(False, variant_level=1), dbus.String('mDNS.Configuration'): dbus.Boolean(False, variant_level=1), dbus.String('Provider'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1)}, signature=dbus.Signature('sv'))), signature=None) | ||
|
||
# Tests | ||
|
||
def test_has_service_state_in(): | ||
assert proxy.has_service_state_in(service_idle, ['online', 'ready']) == False | ||
assert proxy.has_service_state_in(service_online_direct, ['online', 'ready']) == True | ||
|
||
def test_extract_manual_proxy(): | ||
assert proxy.extract_manual_proxy(service_idle) == None | ||
assert proxy.extract_manual_proxy(service_online_direct) == None | ||
assert proxy.extract_manual_proxy(service_online_proxy) == proxy.ProxyConfig('proxy.dividat.com', 1234, None, None) |