def test_update_switchmachine(self): switch.add_switch_machine( 1, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) switch.update_switchmachine( 1, location='test_location', user=self.user_object, ) update_switchmachine = switch.list_switchmachines( user=self.user_object, ) expected = { 'switch_id': 1, 'id': 1, 'mac': '28:6e:d4:46:c4:25', 'location': 'test_location', 'switch_ip': '0.0.0.0', 'machine_id': 1, 'port': '1', 'switch_machine_id': 1 } self.assertTrue( all(item in update_switchmachine[0].items() for item in expected.items()) )
def test_update_switchmachine(self): switch.add_switch_machine( 1, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) switch.update_switchmachine( 1, location='test_location', user=self.user_object, ) update_switchmachine = switch.list_switchmachines( user=self.user_object, ) expected = { 'switch_id': 1, 'id': 1, 'mac': '28:6e:d4:46:c4:25', 'location': 'test_location', 'switch_ip': '0.0.0.0', 'machine_id': 1, 'port': '1', 'switch_machine_id': 1 } self.assertTrue( all(item in update_switchmachine[0].items() for item in expected.items()))
def test_switchmachine(self): switch.add_switch_machine( 1, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) switch.del_switchmachine( 1, user=self.user_object, ) del_switchmachine = switch.list_switchmachines(user=self.user_object) self.assertEqual([], del_switchmachine)
def test_switchmachine(self): switch.add_switch_machine( 1, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) switch.del_switchmachine( 1, user=self.user_object, ) del_switchmachine = switch.list_switchmachines( user=self.user_object ) self.assertEqual([], del_switchmachine)
def test_list_switch_machines_without_ip(self): switch.add_switch( self.user_object, ip='2887583784' ) switch.add_switch_machine( self.user_object, 2, mac='28:6e:d4:46:c4:25', port='1' ) list_switch_machines = switch.list_switchmachines( self.user_object ) self.assertIsNotNone(list_switch_machines)
def test_patch_switchmachine(self): switch.add_switch_machine( 1, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) switch.patch_switchmachine( 1, user=self.user_object, location={'patched_location': 'test_location'}) patch_switchmachine = switch.list_switchmachines(user=self.user_object) expected = {'location': {'patched_location': 'test_location'}} self.assertTrue( all(item in patch_switchmachine[0].items() for item in expected.items()))
def test_list_switch_machines_ip_invalid(self): switch.add_switch( ip='2887583784', user=self.user_object, ) switch.add_switch_machine( 2, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) list_switch_machines = switch.list_switchmachines( switch_ip_int='test', user=self.user_object, ) self.assertEqual(list_switch_machines, [])
def test_list_switch_machines_without_ip(self): switch.add_switch( ip='2887583784', user=self.user_object, ) switch.add_switch_machine( 2, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) list_switch_machines = switch.list_switchmachines( user=self.user_object) expected = {'switch_ip': '172.29.8.40'} self.assertTrue( all(item in list_switch_machines[0].items() for item in expected.items()))
def test_list_switch_machines_with_ip_int(self): switch.add_switch( self.user_object, ip='2887583784' ) switch.add_switch_machine( self.user_object, 2, mac='28:6e:d4:46:c4:25', port='1' ) list_switch_machines = switch.list_switchmachines( self.user_object, switch_ip_int='2887583784' ) expected = '172.29.8.40' self.assertTrue(expected for item in list_switch_machines[0].items())
def test_list_switch_machines_without_ip(self): switch.add_switch( ip='2887583784', user=self.user_object, ) switch.add_switch_machine( 2, mac='28:6e:d4:46:c4:25', port='1', user=self.user_object, ) list_switch_machines = switch.list_switchmachines( user=self.user_object ) expected = {'switch_ip': '172.29.8.40'} self.assertTrue( all(item in list_switch_machines[0].items() for item in expected.items()))
def test_update_switchmachine(self): switch.add_switch_machine( self.user_object, 1, mac='28:6e:d4:46:c4:25', port='1' ) switch.update_switchmachine( self.user_object, 1, location='test_location' ) update_switchmachine = switch.list_switchmachines( self.user_object, ) expected = {'location': 'test_location'} self.assertTrue( item in update_switchmachine[0].items() for item in expected.items() )
def test_patch_switchmachine(self): switch.add_switch_machine( self.user_object, 1, mac='28:6e:d4:46:c4:25', port='1' ) switch.patch_switchmachine( self.user_object, 1, patched_location={ 'patched_location': 'test_location' } ) patch_switchmachine = switch.list_switchmachines( self.user_object ) expected = {'patched_location': 'test_location'} self.assertTrue( item in patch_switchmachine[0].items() for item in expected.items() )