Esempio n. 1
0
def create_client(data):
    validated_data = data.copy()
    client = Client.objects.create(
        client_name=validated_data.get('client_name'))
    validated_data.pop('client_name')
    validated_data['client_id'] = client.id
    create_user(data=validated_data, role=2)
    return client
    def test_creating_user_with_proper_data_is_working(self):
        self.assertEqual(0, BaseUser.objects.count())

        user_data = {
            'email': fake.email(),
            'password': fake.password()
        }

        create_user(**user_data)

        self.assertEqual(1, BaseUser.objects.count())
        self.assertTrue(
            BaseUser.objects.filter(email=user_data['email']).exists()
        )
Esempio n. 3
0
def create_client(data):
    validated_data = data.copy()
    user = get_user_by(email=data.get('email'), raise_exception=False)
    if user:
        raise DuplicateEntry(entry=user.email, key='email')
    client_name = validated_data.get('client_name')
    client = get_client_by(client_name=client_name, raise_exception=False)
    if client:
        raise DuplicateEntry(entry=client_name, key='client_name')
    client = Client.objects.create(client_name=client_name,
                                   address=validated_data.get('address'))
    validated_data.pop('client_name')
    validated_data.pop('address')
    validated_data['client_id'] = client.id
    create_user(data=validated_data, role=2)
    return client
Esempio n. 4
0
def register_user(request):
    response = UsersService.create_user(request.data)

    if response["status"]:
        return Response(response, status=status.HTTP_201_CREATED)
    else:
        return Response(response, status=status.HTTP_200_OK)
Esempio n. 5
0
 def setUp(self):
     self.user = create_user("*****@*****.**", "test123", "user")
     start = datetime.date.today() + datetime.timedelta(days=10)
     end = datetime.date.today() + datetime.timedelta(days=12)
     self.user.save()
     self.trip = Trip(user=self.user,
                      destination="Test",
                      comment="test",
                      start_date=start,
                      end_date=end)
     self.trip.save()
Esempio n. 6
0
def test_create_user():
    correo = "*****@*****.**"

    is_created, user = create_user(
        correo=correo,
        password="******",
        nombre="TestMan",
        apellido="Sanchez",
        rut="191366360",
        numero_serie_carnet="123456789",
    )

    assert is_created
    assert user == User.objects.get(correo=correo)
Esempio n. 7
0
 def setUp(self):
     self.user = create_user("*****@*****.**", "test123", "user")
     self.user.save()
Esempio n. 8
0
def user(event_loop):
    from users import services
    user = event_loop.run_until_complete(services.create_user('test', '1234'))
    user.raw_password = '******'
    return user
Esempio n. 9
0
 def create(self, validated_data):
     return services.create_user(
         **validated_data
     )