def test_as_dict(self): """Test the method as_dict.""" attributes = { "controller": get_controller_mock(), "id": "custom_id", "name": "custom_name", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "start_date": "2018-08-21T18:44:54", "end_date": "2018-08-21T18:44:55", "primary_links": [], "request_time": "2018-08-21T19:10:41", "creation_time": "2018-08-21T18:44:54", "owner": "my_name", "circuit_scheduler": [ CircuitSchedule.from_dict({ "id": 234243247, "action": "create", "frequency": "1 * * * *", }), CircuitSchedule.from_dict({ "id": 234243239, "action": "create", "interval": { "hours": 2 }, }), ], "enabled": True, "priority": 2, } evc = EVC(**attributes) expected_dict = { "id": "custom_id", "name": "custom_name", "uni_a": attributes["uni_a"].as_dict(), "uni_z": attributes["uni_z"].as_dict(), "start_date": "2018-08-21T18:44:54", "end_date": "2018-08-21T18:44:55", "bandwidth": 0, "primary_links": [], "backup_links": [], "current_path": [], "primary_path": [], "backup_path": [], "dynamic_backup_path": False, "request_time": "2018-08-21T19:10:41", "creation_time": "2018-08-21T18:44:54", "circuit_scheduler": [ { "id": 234243247, "action": "create", "frequency": "1 * * * *", }, { "id": 234243239, "action": "create", "interval": { "hours": 2 }, }, ], "active": False, "enabled": True, "priority": 2, } actual_dict = evc.as_dict() for name, value in expected_dict.items(): actual = actual_dict.get(name) self.assertEqual(value, actual)
def test_as_dict(self): """Test the method as_dict.""" attributes = { "controller": get_controller_mock(), "id": "custom_id", "name": "custom_name", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "start_date": '2018-08-21T18:44:54', "end_date": '2018-08-21T18:44:55', 'primary_links': [], 'request_time': '2018-08-21T19:10:41', 'creation_time': '2018-08-21T18:44:54', 'owner': "my_name", 'circuit_scheduler': [ CircuitSchedule.from_dict({"id": 234243247, "action": "create", "frequency": "1 * * * *"}), CircuitSchedule.from_dict({"id": 234243239, "action": "create", "interval": {"hours": 2}}) ], 'enabled': True, 'priority': 2 } evc = EVC(**attributes) expected_dict = { 'id': 'custom_id', 'name': 'custom_name', 'uni_a': attributes['uni_a'].as_dict(), 'uni_z': attributes['uni_z'].as_dict(), 'start_date': '2018-08-21T18:44:54', 'end_date': '2018-08-21T18:44:55', 'bandwidth': 0, 'primary_links': [], 'backup_links': [], 'current_path': [], 'primary_path': [], 'backup_path': [], 'dynamic_backup_path': False, 'request_time': '2018-08-21T19:10:41', 'creation_time': '2018-08-21T18:44:54', 'circuit_scheduler': [ { "id": 234243247, "action": "create", "frequency": "1 * * * *" }, { "id": 234243239, "action": "create", "interval": { "hours": 2 } } ], 'active': False, 'enabled': True, 'priority': 2 } actual_dict = evc.as_dict() for name, value in expected_dict.items(): actual = actual_dict.get(name) self.assertEqual(value, actual)