def case_delete_records(self, refresh_db_before): """ Create new record in ServerType table and then delete it.""" new_type = "New type" ServerTypeOp.add(new_type) type_obj = ServerTypeOp.get(name=new_type) self.assertTrue(len(type_obj) is 1) self.assertEqual(type_obj[0].name, new_type) ServerTypeOp.delete(type_obj[0]) type_obj = ServerTypeOp.get(name=new_type) self.assertFalse(type_obj)
def test_delete(self, mock_servtype, mock_db): """ Assumptions: - delete method run """ ip_obj = mock_servtype() ServerTypeOp.delete(ip_obj) db_exp_calls = [ mock.call.session.delete(ip_obj), mock.call.session.commit() ] mock_db.assert_has_calls(db_exp_calls)