def setUp(self): """ Load in the examples and pre-parse the expected results """ with open("examples/test.json", "r") as f: self.input_json = f.read() with open("examples/test.yaml", "r") as f: self.input_yaml = f.read() with open("examples/clean.json", "r") as f: self.clean_json = f.read() with open("examples/clean.yaml", "r") as f: self.clean_yaml = f.read() self.parsed_json = json.loads(self.input_json) self.parsed_yaml = custom_yaml.load(self.input_yaml) self.parsed_clean_json = json.loads(self.clean_json) self.parsed_clean_yaml = custom_yaml.load(self.clean_yaml) self.bad_data = "<!DOCTYPE html>\n\n<html>\n\tThis isn't right!\n</html>" self.fail_message = "Could not determine the input format: .+"
def setUp(self): """ Load in the examples and pre-parse the expected results """ with open("examples/test.json", "r") as f: self.input_json = f.read() with open("examples/test.yaml", "r") as f: self.input_yaml = f.read() with open("examples/clean.json", "r") as f: self.clean_json = f.read() with open("examples/clean.yaml", "r") as f: self.clean_yaml = f.read() self.parsed_json = json.loads(self.input_json) self.parsed_yaml = custom_yaml.load(self.input_yaml) self.parsed_clean_json = json.loads(self.clean_json) self.parsed_clean_yaml = custom_yaml.load(self.clean_yaml) self.bad_data = "<!DOCTYPE html>\n\n<html>\n\tThis isn't right!\n</html>" self.fail_message = "Could not determine the input format: .+"
def test_to_yaml_with_json(self): """ Test that to_yaml performs correctly """ actual = cfn_flip.to_yaml(self.input_json) # The result should not parse as json with self.assertRaises(ValueError): json.loads(actual) parsed_actual = custom_yaml.load(actual) self.assertDictEqual(parsed_actual, self.parsed_yaml)
def test_flip_to_yaml(self): """ Test that flip performs correctly transforming from json to yaml """ actual = cfn_flip.flip(self.input_json) # The result should not parse as json with self.assertRaises(ValueError): json.loads(actual) parsed_actual = custom_yaml.load(actual) self.assertDictEqual(parsed_actual, self.parsed_yaml)
def test_to_yaml_with_json(self): """ Test that to_yaml performs correctly """ actual = cfn_flip.to_yaml(self.input_json) # The result should not parse as json with self.assertRaises(ValueError): json.loads(actual) parsed_actual = custom_yaml.load(actual) self.assertDictEqual(parsed_actual, self.parsed_yaml)
def test_flip_to_yaml(self): """ Test that flip performs correctly transforming from json to yaml """ actual = cfn_flip.flip(self.input_json) # The result should not parse as json with self.assertRaises(ValueError): json.loads(actual) parsed_actual = custom_yaml.load(actual) self.assertDictEqual(parsed_actual, self.parsed_yaml)