Esempio n. 1
0
 def test_empty_radar_vin(self):
     self.delete_test_config_file()
     # first pass creates config file
     cs = readconfig.CarSettings(
         optional_config_file_path=self.test_config_file)
     self.assertEqual(cs.radarVIN, "                 ")
     # second pass actually reads the file
     cs = readconfig.CarSettings(
         optional_config_file_path=self.test_config_file)
     self.assertEqual(cs.radarVIN, "                 ")
Esempio n. 2
0
 def test_defaults_missing_file(self):
     # First time proves that data is set locally
     cs = readconfig.CarSettings(
         optional_config_file_path=self.test_config_file)
     self.check_defaults(cs)
     self.assertEqual(cs.did_write_file, True)
     # Run a second time to make sure it was saved and read correctly
     cs = readconfig.CarSettings(
         optional_config_file_path=self.test_config_file)
     self.check_defaults(cs)
     self.assertEqual(cs.did_write_file, False)
Esempio n. 3
0
 def test_float_parsing(self):
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(
         config_file_path, test_parameter_string="radar_offset = 3.14")
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     self.assertEqual(cs.radarOffset, 3.14)
     os.remove(config_file_path)
Esempio n. 4
0
 def test_radar_vin_with_data(self):
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(
         config_file_path,
         test_parameter_string="radar_vin = 12345678901234567")
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     self.assertEqual(cs.radarVIN, "12345678901234567")
     os.remove(config_file_path)
Esempio n. 5
0
 def test_get_value(self):
     config_file_path = "./test_config_file3.cfg"
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     value = cs.get_value("userHandle")
     self.assertEqual(value, 'your_tinkla_username')
     value = cs.get_value("doAutoUpdate")
     self.assertEqual(value, True)
     os.remove(config_file_path)
Esempio n. 6
0
 def test_update_empty_radar_vin(self):
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(
         config_file_path,
         test_parameter_string="radar_vin =                 ")
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     # Should be the correct all spaces VIN
     self.assertEqual(cs.radarVIN, "                 ")
     os.remove(config_file_path)
Esempio n. 7
0
 def test_defaults_non_overriding(self):
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(
         config_file_path,
         test_parameter_string="force_pedal_over_cc = True")
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     # Should still be true, even though the defaut is False
     self.assertEqual(cs.forcePedalOverCC, True)
     os.remove(config_file_path)
Esempio n. 8
0
 def test_comment_update(self):
     config_file_path = "./test_config_file3.cfg"
     old_comment = "# do_auto_update - old description (default: true)"
     old_entry = "do_auto_update = False"
     self.create_empty_config_file(config_file_path,
                                   test_parameter_string="[OP_CONFIG]\n" +
                                   old_comment + "\n" + old_entry)
     expected_comment = "# do_auto_update: set this setting to false if you do not want op to autoupdate every time you reboot and there is a change on the repo (default: true)"
     cs = CarSettings(optional_config_file_path=config_file_path)
     # Make sure setting didn't change
     self.assertEqual(cs.doAutoUpdate, False)
     # Make sure comment was updated:
     fd = open(config_file_path, "r")
     contents = fd.read()
     fd.close()
     self.assertTrue(contents.find(expected_comment) != -1)
     # File should have changed (to update comment)
     self.assertEqual(cs.did_write_file, True)
     # Next time we read, file shouldn't change anymore:
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     self.assertEqual(cs.did_write_file, False)
     # Now remove a config option to cause an update:
     fd = open(config_file_path, "r")
     contents = fd.read()
     fd.close()
     new_contents = contents.replace("limit_battery_max = 80", "")
     os.remove(config_file_path)
     fd = open(config_file_path, "wb")
     fd.write(new_contents)
     fd.close()
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     another_comment = '# radar_vin: if you used an aftermarket tesla bosch radar that already has a coded vin, you will have to enter that vin value here (default: "                 ")'
     # Make sure other comments were written:
     fd = open(config_file_path, "r")
     contents = fd.read()
     fd.close()
     self.assertTrue(contents.find(another_comment) != -1)
     os.remove(config_file_path)
Esempio n. 9
0
 def test_comments(self):
     expected_comment = "# do_auto_update: set this setting to false if you do not want op to autoupdate every time you reboot and there is a change on the repo (default: true)"
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(
         config_file_path,
         test_parameter_string="force_pedal_over_cc = True")
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     # Should still be true, even though the defaut is False
     self.assertEqual(cs.forcePedalOverCC, True)
     # Make sure comment was added:
     fd = open(config_file_path, "r")
     contents = fd.read()
     fd.close()
     self.assertNotEqual(contents.find(expected_comment), -1)
     os.remove(config_file_path)
Esempio n. 10
0
 def test_defaults_empty_file(self):
     config_file_path = "./test_config_file2.cfg"
     self.create_empty_config_file(config_file_path)
     cs = readconfig.CarSettings(optional_config_file_path=config_file_path)
     self.check_defaults(cs)
     os.remove(config_file_path)