Beispiel #1
0
 def test_bad_json(self):
     # bad setting
     logging.disable(logging.ERROR);
     json_string ='{"encryption_nonexistant" : true}'
     self.assertFalse(speedifysettings.apply_speedify_settings(json_string))
     # wrong data type on boolean
     json_string ='{ "jumbo" :"bob", "transport":"auto"}'
     self.assertFalse(speedifysettings.apply_speedify_settings(json_string))
     # nonexistant Priority
     json_string ='{"adapter_priority_wifi" : "frank"}'
     self.assertFalse(speedifysettings.apply_speedify_settings(json_string))
     logging.disable(logging.NOTSET)
Beispiel #2
0
 def test_set_defaults(self):
     speedify.encryption(False)
     speedify.transport("tcp")
     self.assertTrue(speedifysettings.apply_speedify_settings(speedifysettings.speedify_defaults))
     settings = speedify.show_settings()
     self.assertTrue(settings["encrypted"])
     self.assertTrue(settings["jumboPackets"])
     self.assertEqual( settings["transportMode"] , "auto")
Beispiel #3
0
 def test_set_json(self):
     # lets use a settings string to apply it back
     json_string ='{"encryption" : false, "jumbo" : false, "packet_aggregation":false,"transport":"tcp","adapter_priority_wifi" : "backup"}'
     self.assertTrue( speedifysettings.apply_speedify_settings(json_string))
     settings = speedify.show_settings()
     self.assertFalse(settings["encrypted"])
     self.assertFalse(settings["jumboPackets"])
     self.assertFalse(settings["packetAggregation"])
     self.assertEqual( settings["transportMode"] , "tcp")
Beispiel #4
0
 def test_reset(self):
     #read settings
     currentsettings = speedifysettings.get_speedify_settings()
     # write them back
     self.assertTrue(speedifysettings.apply_speedify_settings(currentsettings))
Beispiel #5
0
    def test_set_json(self):
        # lets use a settings string to apply it back
        json_string ='{"encryption" : false, "jumbo" : false, "packet_aggregation":false,"transport":"tcp","adapter_priority_wifi" : "backup", "route_default": false}'
        self.assertTrue( speedifysettings.apply_speedify_settings(json_string))
        settings = speedify.show_settings()
        self.assertFalse(settings["encrypted"])
        self.assertFalse(settings["jumboPackets"])
        self.assertFalse(settings["packetAggregation"])
        self.assertFalse(settings["enableDefaultRoute"])
        self.assertEqual( settings["transportMode"] , "tcp")

    def test_bad_json(self):
        # bad setting
        logging.disable(logging.ERROR);
        json_string ='{"encryption_nonexistant" : true}'
        self.assertFalse(speedifysettings.apply_speedify_settings(json_string))
        # wrong data type on boolean
        json_string ='{ "jumbo" :"bob", "transport":"auto"}'
        self.assertFalse(speedifysettings.apply_speedify_settings(json_string))

        # nonexistent Priority
        json_string ='{"adapter_priority_all" : "frank"}'
        self.assertFalse(speedifysettings.apply_speedify_settings(json_string))

        logging.disable(logging.NOTSET)

if __name__ == '__main__':
    unittest.main()
    speedifysettings.apply_speedify_settings(speedifysettings.speedify_defaults)
import sys
sys.path.append('../')
import speedifysettings
import logging

logging.basicConfig(handlers=[logging.FileHandler('test.log'),logging.StreamHandler(sys.stdout)],format='%(asctime)s\t%(levelname)s\t%(module)s\t%(message)s',  level=logging.INFO)

# Get the default settings, and apply them to just put us in a known state
success = speedifysettings.apply_speedify_settings(speedifysettings.speedify_defaults)
if success:
    logging.info("Default settings applied successfully")
    sys.exit(0)
else:
    logging.info("Failed to apply default settings")
    sys.exit(1)
import sys

sys.path.append('../')
import speedifysettings
import logging
import fileinput

# takes a settings json and applies the settings.  Either name on command line or piped in a stdin.
logging.basicConfig(
    handlers=[
        logging.FileHandler('test.log'),
        logging.StreamHandler(sys.stdout)
    ],
    format='%(asctime)s\t%(levelname)s\t%(module)s\t%(message)s',
    level=logging.INFO)

for line in fileinput.input():
    speedifysettings.apply_speedify_settings(line)