def test_from_json_broken(self): test_id = 5 name = "Grendel" # Bad version jsonified = { "id": test_id, "name": name, "version": -1, } with self.assertRaisesRegexp(TypeError, "has unexpected version"): Group.from_json(jsonified) # Missing key "id" jsonified = { "name": name, "version": Group.VERSION } with self.assertRaisesRegexp(TypeError, "missing value key 'id'"): Group.from_json(jsonified) # Has extra key - should not be a problem jsonified = { "id": test_id, "name": name, "version": Group.VERSION, "programmer": "Cale" } group = Group.from_json(jsonified) self.assertNotIn("programmer", group.to_json())
def test_from_json_broken(self): test_id = 5 name = "Grendel" # Bad version jsonified = { "id": test_id, "name": name, "version": -1, } with self.assertRaisesRegexp(TypeError, "has unexpected version"): Group.from_json(jsonified) # Missing key "id" jsonified = {"name": name, "version": Group.VERSION} with self.assertRaisesRegexp(TypeError, "missing value key 'id'"): Group.from_json(jsonified) # Has extra key - should not be a problem jsonified = { "id": test_id, "name": name, "version": Group.VERSION, "programmer": "Cale" } group = Group.from_json(jsonified) self.assertNotIn("programmer", group.to_json())
def test_from_json(self): test_id = 5 name = "Grendel" jsonified = {"id": test_id, "name": name, "version": Group.VERSION} group = Group.from_json(jsonified) assert group.id == test_id assert group.name == name
def test_from_json(self): test_id = 5 name = "Grendel" jsonified = {"id": test_id, "name": name, "version": Group.VERSION} group = Group.from_json(jsonified) self.assertEqual(group.id, test_id) self.assertEqual(group.name, name)