示例#1
0
 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)]
     )
示例#2
0
 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)])
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
 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)
示例#6
0
文件: test_me.py 项目: magul/pah-fm
 def setUp(self):
     self.url = reverse("me")
     self.user = UserFactory.make(
         username="******",
         groups=[Group.objects.get(name=Groups.Driver.name)])