def setUp(self): self.url = reverse("jwt") self.driver = UserFactory.make( groups=[Group.objects.get(name=Groups.Driver.name)] ) self.passenger = UserFactory.make( groups=[Group.objects.get(name=Groups.Passenger.name)] )
def setUp(self): self.url = reverse("passengers") self.user = UserFactory.make( groups=[Group.objects.get(name=Groups.Driver.name)]) self.passengers = UserFactory.make_batch( size=5, country=self.user.country, groups=[Group.objects.get(name=Groups.Passenger.name)])
def setUp(self): self.url = reverse("drives") self.drivers_group = Group.objects.get(name=Groups.Driver.name) self.passengers_group = Group.objects.get(name=Groups.Passenger.name) self.car = CarFactory.make(id=29) self.project = ProjectFactory.make(id=42, country="UA") self.driver = UserFactory.make(id=51, groups=[self.drivers_group]) self.passenger = UserFactory.make( id=35, rsa_pub_e=257, rsa_priv_d=30593, rsa_modulus_n=50927, groups=[self.passengers_group], ) self.drives = DriveFactory.make_batch(size=10, driver=self.driver, passenger=self.passenger)
def test_can_retrieve_only_my_drives(self): new_driver = UserFactory.make(groups=[self.drivers_group]) DriveFactory.make_batch(size=4, driver=new_driver, passenger=self.passenger) self.client.force_login(self.driver) res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) drives = res.data self.assertEqual(len(drives), len(self.drives)) self.assertEqual({d["driver"]["id"] for d in drives}, {self.driver.id}) for drive in drives: self.assertEqual(drive["driver"]["id"], self.driver.id)
def setUp(self): self.url = reverse("cars") self.user = UserFactory.make( groups=[Group.objects.get(name=Groups.Driver.name)]) self.cars = CarFactory.make_batch(size=3, country=self.user.country)
def setUp(self): self.url = reverse("me") self.user = UserFactory.make( username="******", groups=[Group.objects.get(name=Groups.Driver.name)])