def test_empty_userdata(self): """ Empty option adds nothing to result. """ options = BenchmarkOptions() options.parseOptions(['--userdata', '']) self.assertIs(parse_userdata(options), None)
def test_json_userdata(self): """ JSON string adds to result. """ options = BenchmarkOptions() options.parseOptions(['--userdata', '{"branch": "master"}']) self.assertEqual(parse_userdata(options), {"branch": "master"})
def test_no_userdata(self): """ Missing option adds nothing to result. """ options = BenchmarkOptions() options.parseOptions([]) self.assertIs(parse_userdata(options), None)
def test_json_file_userdata(self): """ JSON file adds to result. """ json_file = FilePath(self.mktemp()) with json_file.open('w') as f: f.write('{"branch": "master"}\n') options = BenchmarkOptions() options.parseOptions(['--userdata', '@{}'.format(json_file.path)]) self.assertEqual(parse_userdata(options), {"branch": "master"})