Ejemplo n.º 1
0
 def setUp(self):
     """
     stores a sample request body for mechanic signup
     :return: None
     """
     self.client = Client()
     self.mechanic = get_sample_mechanic_data()
Ejemplo n.º 2
0
 def setUp(self):
     """
     stores a sample request body for mechanic signup
     creates a dummy mechanic corresponding auth tokens
     :return: None
     """
     self.client = Client()
     self.mechanic = get_sample_mechanic_data()
     self.client.post('/api/mechanic/signup',
                      self.mechanic,
                      content_type="application/json")
     self.user = User.objects.get(email=self.mechanic['email'])
     jwt_token = get_jwt(self.user)
     self.auth_headers = {'HTTP_AUTHORIZATION': 'Bearer ' + jwt_token}
Ejemplo n.º 3
0
    def setUp(self):
        """
        stores a sample request body for mechanic signup
        creates a dummy mechanic, a dummy user, a dummy vehicle and corresponding auth tokens
        stores a sample request body for contact mechanic
        :return: None
        """
        self.client = Client()
        self.mechanic = get_sample_mechanic_data()
        self.client.post('/api/mechanic/signup',
                         self.mechanic,
                         content_type="application/json")
        self.user = User.objects.create(id=2,
                                        email='*****@*****.**',
                                        number='9123456700',
                                        password=bcrypt.hashpw(
                                            'user'.encode('utf-8'),
                                            bcrypt.gensalt()).decode(),
                                        role=User.ROLE_CHOICES.USER,
                                        created_on=timezone.now())
        user_jwt_token = get_jwt(self.user)
        self.user_auth_headers = {
            'HTTP_AUTHORIZATION': 'Bearer ' + user_jwt_token
        }

        mechanic_jwt_token = get_jwt(
            User.objects.get(email=self.mechanic['email']))
        self.mechanic_auth_headers = {
            'HTTP_AUTHORIZATION': 'Bearer ' + mechanic_jwt_token
        }

        self.vehicle = Vehicle.objects.create(pincode='1234',
                                              vin='9NFXO86WBWA082766',
                                              year='2020',
                                              status='ACTIVE',
                                              owner=self.user)
        self.contact_mechanic_request_body = {
            'mechanic_api': 'https://www.google.com',
            'repeat_request_if_failed': True,
            'number_of_repeats': 5,
            'mechanic_code': self.mechanic['mechanic_code'],
            'vin': self.vehicle.vin,
            'problem_details': 'My Car is not working',
        }