Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Cómo escribir una vista de prueba basada en clases para canales Django usando el módulo unittest

Estoy tratando de escribir pruebas unitarias para mis sockets web. No he escrito ninguno anteriormente, así que tengo dificultades para entender cómo escribir usando el paquete de Python unittest del módulo.

Este es mi consumidor:

 class DepartmentInfoConsumer(JsonWebsocketConsumer): def connect(self): if not self.scope["user"]: raise DenyConnection() self.accept() self.group_name = "test" async_to_sync(self.channel_layer.group_add)(f"department{self.scope['company'].id}", self.channel_name) departmentobject = Department.objects.get(company=self.scope["company"]) self.send_json({"used_id": departmentobject.my_id}) def disconnect(self, close_code): async_to_sync(self.channel_layer.group_discard)(f"department{self.scope['company'].id}", self.channel_name) raise StopConsumer() def used_id_info(self, event): self.send_json({"used_id": event["used_id"]})

MI URL:

 websocket_urlpatterns = [ re_path("bill/", consumers. DepartmentInfoConsumer.as_asgi(), name="billing-ws"), ]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!