# Path: raspi/scripts/gwf.py
# RANDOM_DELAY_PARAM = 300
# SYNC_TIMEOUT = 5
# ENV_TYPE = "prod"
# GET_SERIAL_FAILURE_WAIT = 60
# NETWORKING_RESTART_WAIT = 30
# def get_process(args):
# def perform_command_and_validate(process, err_msg):
# def check_if_wifi_available():
# def check_if_synced():
# def perform_ntp_sync():
# def execute_get_serial(env_type):
# def main():


import datetime
from mock import Mock, patch
from nose.tools import assert_raises, eq_
from raspi.scripts import gwf
        response = """
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+152.79.105.129  129.6.15.30
*152.79.105.132  173.71.69.90
        """
        perf.return_value = (response, "")
        is_synced = gwf.check_if_synced()
        assert not is_synced


def test_check_if_synced_neg_offset():
    with patch("raspi.scripts.gwf.perform_command_and_validate") as perf:
        response = """
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*152.79.105.129  129.6.15.30      2 u    2   64    1    2.480   -0.579   0.001
 152.79.105.132  173.71.69.90     2 u    1   64    1    1.294   -2.128   0.001
        """
        perf.return_value = (response, "")
        is_synced = gwf.check_if_synced()
        assert is_synced


def test_check_if_wifi_available_up_state():
    with patch("raspi.scripts.gwf.perform_command_and_validate") as perf:
        with patch("raspi.scripts.gwf.get_process"):
            response = """
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:0f:60:08:07:7c brd ff:ff:ff:ff:ff:ff

# Path: raspi/scripts/gwf.py
# RANDOM_DELAY_PARAM = 300
# SYNC_TIMEOUT = 5
# ENV_TYPE = "prod"
# GET_SERIAL_FAILURE_WAIT = 60
# NETWORKING_RESTART_WAIT = 30
# def get_process(args):
# def perform_command_and_validate(process, err_msg):
# def check_if_wifi_available():
# def check_if_synced():
# def perform_ntp_sync():
# def execute_get_serial(env_type):
# def main():


# Path: raspi/tests/test_gwf.py
import datetime
from mock import Mock, patch
from nose.tools import assert_raises, eq_
from raspi.scripts import gwf

        response = """
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+152.79.105.129  129.6.15.30
*152.79.105.132  173.71.69.90
        """
        perf.return_value = (response, "")
        is_synced = gwf.check_if_synced()
        assert not is_synced


def test_check_if_synced_neg_offset():
    with patch("raspi.scripts.gwf.perform_command_and_validate") as perf:
        response = """
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*152.79.105.129  129.6.15.30      2 u    2   64    1    2.480   -0.579   0.001
 152.79.105.132  173.71.69.90     2 u    1   64    1    1.294   -2.128   0.001
        """
        perf.return_value = (response, "")
        is_synced = gwf.check_if_synced()
        assert is_synced


def test_check_if_wifi_available_up_state():
    with patch("raspi.scripts.gwf.perform_command_and_validate") as perf:
        with patch("raspi.scripts.gwf.get_process"):
            response = """
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:0f:60:08:07:7c brd ff:ff:ff:ff:ff:ff

        inet 10.190.16.81/20 brd 10.190.31.255 scope global wlan0