zeeguu/core/test/rules/bookmark_rule.py
def _create_model_object(self, user, force_quality=True, **kwargs):
        """
        Creates a Bookmark object with random data.

        Behind the random words, a random number is added since the Faker library does not have too many RANDOM words
        and random words get repeated whenever many random bookmarks are created. To overcome the problem of bookmarks
        with duplicate words in the database, a random number is added.

        Also, if force_quality is set (default) and the bookmark is not .quality_bookmark() the process is
        reiterated till this is true. This simplifies some of the tests

        :param user: User Object, to which the bookmark is assigned.
        :param kwargs: Holds any of the 'props' as key if a field should not be random
        :return:
        """

        bookmark = None

        while not bookmark:

            from zeeguu.core.test.rules.text_rule import TextRule

            random_text = TextRule().text

            random_origin_word = self.faker.word() + str(random.random())
            random_origin_language = user.learned_language

            random_translation_word = self.faker.word() + str(random.random())
            random_translation_language = LanguageRule().random

            if UserWord.exists(
                random_origin_word, random_origin_language
            ) or UserWord.exists(random_translation_word, random_translation_language):
                return self._create_model_object(user)

            random_origin = UserWordRule(
                random_origin_word, random_origin_language
            ).user_word
            random_translation = UserWordRule(
                random_translation_word, random_translation_language
            ).user_word
            random_date = self.faker.date_time_this_month()

            from zeeguu.core.test.rules.article_rule import ArticleRule

            random_article = ArticleRule(real=True).article

            bookmark = Bookmark(
                random_origin, random_translation, user, random_text, random_date
            )
            if force_quality and bad_quality_bookmark(bookmark):
                print("random bookmark was of low quality. retrying...")
                bookmark = False

        for k in kwargs:
            if k in self.props:
                setattr(bookmark, k, kwargs.get(k))

        if self._exists_in_db(bookmark):
            return self._create_model_object(user)

        return bookmark

        Creates a Bookmark object with random data.

        Behind the random words, a random number is added since the Faker library does not have too many RANDOM words
        and random words get repeated whenever many random bookmarks are created. To overcome the problem of bookmarks
        with duplicate words in the database, a random number is added.

        Also, if force_quality is set (default) and the bookmark is not .quality_bookmark() the process is
        reiterated till this is true. This simplifies some of the tests

        :param user: User Object, to which the bookmark is assigned.
        :param kwargs: Holds any of the 'props' as key if a field should not be random
        :return:
        
Creates a Bookmark object with random data.
Behind the random words, a random number is added since the Faker library does not have too many RANDOM words
and random words get repeated whenever many random bookmarks are created. To overcome the problem of bookmarks
with duplicate words in the database, a random number is added.

Also, if force_quality is set (default) and the bookmark is not .quality_bookmark() the process is
reiterated till this is true. This simplifies some of the tests
Creates a Bookmark object with random data . Behind the random words a random number is added since the Faker library does not have too many RANDOM words and random words get repeated whenever many random bookmarks are created . To overcome the problem of bookmarks with duplicate words in the database a random number is added . Also if force_quality is set ( default ) and the bookmark is not . quality_bookmark () the process is reiterated till this is true . This simplifies some of the tests
def _create_model_object(self, user, force_quality=True, **kwargs):
        bookmark = None
        while not bookmark:
            from zeeguu.core.test.rules.text_rule import TextRule
            random_text = TextRule().text
            random_origin_word = self.faker.word() + str(random.random())
            random_origin_language = user.learned_language
            random_translation_word = self.faker.word() + str(random.random())
            random_translation_language = LanguageRule().random
            if UserWord.exists(
                random_origin_word, random_origin_language
            ) or UserWord.exists(random_translation_word, random_translation_language):
                return self._create_model_object(user)
            random_origin = UserWordRule(
                random_origin_word, random_origin_language
            ).user_word
            random_translation = UserWordRule(
                random_translation_word, random_translation_language
            ).user_word
            random_date = self.faker.date_time_this_month()
            from zeeguu.core.test.rules.article_rule import ArticleRule
            random_article = ArticleRule(real=True).article
            bookmark = Bookmark(
                random_origin, random_translation, user, random_text, random_date
            )
            if force_quality and bad_quality_bookmark(bookmark):
                print("random bookmark was of low quality. retrying...")
                bookmark = False
        for k in kwargs:
            if k in self.props:
                setattr(bookmark, k, kwargs.get(k))
        if self._exists_in_db(bookmark):
            return self._create_model_object(user)
        return bookmark
def _create_model_object ( self , user , force_quality = True , ** kwargs ) : bookmark = None while not bookmark : from zeeguu . core . test . rules . text_rule import TextRule random_text = TextRule ( ) . text random_origin_word = self . faker . word ( ) + str ( random . random ( ) ) random_origin_language = user . learned_language random_translation_word = self . faker . word ( ) + str ( random . random ( ) ) random_translation_language = LanguageRule ( ) . random if UserWord . exists ( random_origin_word , random_origin_language ) or UserWord . exists ( random_translation_word , random_translation_language ) : return self . _create_model_object ( user ) random_origin = UserWordRule ( random_origin_word , random_origin_language ) . user_word random_translation = UserWordRule ( random_translation_word , random_translation_language ) . user_word random_date = self . faker . date_time_this_month ( ) from zeeguu . core . test . rules . article_rule import ArticleRule random_article = ArticleRule ( real = True ) . article bookmark = Bookmark ( random_origin , random_translation , user , random_text , random_date ) if force_quality and bad_quality_bookmark ( bookmark ) : print ( "random bookmark was of low quality. retrying..." ) bookmark = False for k in kwargs : if k in self . props : setattr ( bookmark , k , kwargs . get ( k ) ) if self . _exists_in_db ( bookmark ) : return self . _create_model_object ( user ) return bookmark
Creates a Bookmark object with random data.
Creates a Bookmark object with random data .
"""
        Creates a Bookmark object with random data.

        Behind the random words, a random number is added since the Faker library does not have too many RANDOM words
        and random words get repeated whenever many random bookmarks are created. To overcome the problem of bookmarks
        with duplicate words in the database, a random number is added.

        Also, if force_quality is set (default) and the bookmark is not .quality_bookmark() the process is
        reiterated till this is true. This simplifies some of the tests

        :param user: User Object, to which the bookmark is assigned.
        :param kwargs: Holds any of the 'props' as key if a field should not be random
        :return:
        """
None
self
user
User Object, to which the bookmark is assigned.
User Object to which the bookmark is assigned .
force_quality
kwargs
Holds any of the 'props' as key if a field should not be random
Holds any of the ' props ' as key if a field should not be random