def test_convert(self): with open(BEHAVE_JSON) as f: converted = b2c.convert(json.load(f)) with open(EXPECTED_JSON) as f: expected_result = json.load(f) assert (sorted(converted) == sorted(expected_result))
def test_ids_are_unique(self): with open(BEHAVE_JSON) as f: converted = b2c.convert(json.load(f)) ids = [] for feature in converted: ids.append(feature['id']) for element in feature['elements']: ids.append(element['id']) assert (len(set(ids)) == 5)
def convert_behave_to_cucumber_json(behave_filename, cucumber_filename, encoding="UTF-8", pretty=True): """Convert behave JSON dialect into cucumber JSON dialect. .. param behave_filename: Input filename with behave JSON data. .. param cucumber_filename: Output filename with cucumber JSON data. """ dump_kwargs = {"encoding": encoding} if pretty: dump_kwargs.update(indent=2, sort_keys=True) with open(behave_filename, "r") as behave_json: with open(cucumber_filename, "w+") as output_file: cucumber_json = b2c.convert(json.load(behave_json, encoding)) # cucumber_text = json.dumps(cucumber_json, **dump_kwargs) # output_file.write(cucumber_text) json.dump(cucumber_json, output_file, **dump_kwargs) return 0