Example #1
0
class Message(DjangoModelFactory):
    class Meta:
        model = MessageModel

    author = SubFactory(User)
    in_conversation = SubFactory(Conversation)
    content = LazyAttribute(lambda x: faker.text())
Example #2
0
 def setUpClass(cls):
     super().setUpClass()
     cls.user = User()
     cls.group = GroupFactory()
     cls.url = '/api/groups/'
     cls.group_data = {'name': faker.name(),
                       'description': faker.text(),
                       'address': faker.address(),
                       'latitude': faker.latitude(),
                       'longitude': faker.longitude()}
Example #3
0
 def setUpClass(cls):
     super().setUpClass()
     cls.user = User()
     cls.group = GroupFactory()
     cls.url = '/api/groups/'
     cls.group_data = {
         'name': faker.name(),
         'description': faker.text(),
         'address': faker.address(),
         'latitude': faker.latitude(),
         'longitude': faker.longitude()
     }
class User(DjangoModelFactory):
    class Meta:
        model = get_user_model()
        strategy = CREATE_STRATEGY

    is_active = True
    is_staff = False
    display_name = LazyAttribute(lambda _: faker.name())
    email = LazyAttribute(lambda _: faker.email())
    description = LazyAttribute(lambda _: faker.text())

    # Use display_name as password, as it is readable
    password = PostGeneration(
        lambda obj, *args, **kwargs: obj.set_password(obj.display_name))

    wall = SubFactory(Wall)
 def setUpClass(cls):
     super().setUpClass()
     cls.user = UserFactory()
     cls.member = UserFactory()
     cls.group = GroupFactory(members=[
         cls.member,
     ])
     cls.group_with_password = GroupFactory(password='******')
     cls.join_password_url = '/api/groups/{}/join/'.format(
         cls.group_with_password.id)
     cls.url = '/api/groups/'
     cls.group_data = {
         'name': faker.name(),
         'description': faker.text(),
         'address': faker.address(),
         'latitude': faker.latitude(),
         'longitude': faker.longitude()
     }
    def setUpClass(cls):
        super().setUpClass()
        cls.url = '/api/conversations/'

        # A chat with 2 participants
        cls.participant = User()
        cls.participant2 = User()
        cls.conversation = Conversation(participants=[cls.participant, cls.participant2])
        cls.conversation_url = cls.url + str(cls.conversation.id) + '/'

        # not a participant
        cls.user = User()

        # another chat
        cls.conversation_data = {'topic': faker.name(),
                                 'with_participants': [cls.participant2.id, ],
                                 'message': faker.text()}
        cls.patch_data = {'topic': 'new topic'}
        cls.put_data = {'topic': 'new topic'}
Example #7
0
class UserFactory(DjangoModelFactory):

    class Meta:
        model = get_user_model()
        strategy = CREATE_STRATEGY

    is_active = True
    is_staff = False
    display_name = LazyAttribute(lambda _: faker.name())
    email = LazyAttribute(lambda _: faker.email())
    description = LazyAttribute(lambda _: faker.text())

    # Use display_name as password, as it is readable
    password = PostGeneration(lambda obj, *args, **kwargs: obj.set_password(obj.display_name))

    @classmethod
    def _create(cls, model_class, *args, **kwargs):
        user = super()._create(model_class, *args, **kwargs)
        user._unverify_mail()
        return user
Example #8
0
    def setUpClass(cls):
        super().setUpClass()
        cls.url = '/api/conversations/'

        # A chat with 2 participants
        cls.participant = User()
        cls.participant2 = User()
        cls.conversation = Conversation(
            participants=[cls.participant, cls.participant2])
        cls.conversation_url = cls.url + str(cls.conversation.id) + '/'

        # not a participant
        cls.user = User()

        # another chat
        cls.conversation_data = {
            'topic': faker.name(),
            'with_participants': [
                cls.participant2.id,
            ],
            'message': faker.text()
        }
        cls.patch_data = {'topic': 'new topic'}
        cls.put_data = {'topic': 'new topic'}