def test_delete(self, mock_servstatus, mock_db): """ Assumptions: - delete method run """ ip_obj = mock_servstatus() ServerStatusOp.delete(ip_obj) db_exp_calls = [ mock.call.session.delete(ip_obj), mock.call.session.commit() ] mock_db.assert_has_calls(db_exp_calls)
def case_delete_records(self, refresh_db_before): """ Create new record in ServerStatus table and then delete it.""" new_status = "NewStatus" ServerStatusOp.add(new_status) status_obj = ServerStatusOp.get(name=new_status) self.assertTrue(len(status_obj) is 1) self.assertEqual(status_obj[0].name, new_status) ServerStatusOp.delete(status_obj[0]) status_obj = ServerStatusOp.get(name=new_status) self.assertFalse(status_obj)