Ejemplo n.º 1
0
 def setUp(self):
     self.ENABLE_NOW_PATCHER = True  # We need to set this or snapshot will have different dates
     # XXX: This is hacky way to make sure id aren't changed in snapshot. This makes the test slower.
     management.call_command("flush", "--no-input")
     factory_random.reseed_random(42)
     for factory in self.factories_used:
         factory.reset_sequence()
     super().setUp()
Ejemplo n.º 2
0
    def test_seeding(self):
        fuzz = fuzzy.FuzzyInteger(1, 1000)

        random.reseed_random(42)
        value = utils.evaluate_declaration(fuzz)

        random.reseed_random(42)
        value2 = utils.evaluate_declaration(fuzz)
        self.assertEqual(value, value2)
Ejemplo n.º 3
0
def bootstrap(file_):
    from factory.random import reseed_random

    reseed_random(0)
    from .bootstrapper import Bootstrap
    from .components import Collections, Groups, Pages, Permissions, Users, Workflows

    bootstrap = Bootstrap(file_)
    bootstrap(Users, Groups, Permissions, Pages, Workflows, Collections)
Ejemplo n.º 4
0
    def test_seeding(self):
        fuzz = fuzzy.FuzzyInteger(1, 1000)

        random.reseed_random(42)
        value = utils.evaluate_declaration(fuzz)

        random.reseed_random(42)
        value2 = utils.evaluate_declaration(fuzz)
        self.assertEqual(value, value2)
Ejemplo n.º 5
0
    def test_seeding(self):
        fuzz = fuzzy.FuzzyInteger(1, 1000)

        random.reseed_random(42)
        value = fuzz.evaluate(sequence=1, obj=None, create=False)

        random.reseed_random(42)
        value2 = fuzz.evaluate(sequence=1, obj=None, create=False)
        self.assertEqual(value, value2)
Ejemplo n.º 6
0
    def run(self, print_summary: bool = True) -> None:
        start_time = time.time()
        reseed_random(self.random_seed)

        accounts = self.generate_accounts(self.num_accounts)

        transactions = self.generate_transactions(accounts)
        transactions = sorted(transactions, key=lambda tx: tx.timestamp)

        self.dump_transactions(transactions)

        end_time = time.time()
        if print_summary:
            self._print_summary(
                transactions,
                seconds_spent=end_time - start_time,
            )
Ejemplo n.º 7
0
import factory
from factory import random

from app.models import peak_model

random.reseed_random("skagit60")


class PeakInFactory(factory.Factory):
    class Meta:
        model = peak_model.PeakIn

    name = factory.Faker("sentence", nb_words=2)
    display_name = factory.Faker("sentence", nb_words=2)
    elevation = factory.Faker("pyint", max_value=20000)
    lat = factory.Faker("pyfloat", min_value=-90, max_value=90)
    long = factory.Faker("pyfloat", min_value=-180, max_value=180)
    state = factory.Faker("pystr")
    country = factory.Faker("country_code")
    peakbagger_link = factory.Faker("url")


class PeakWithSlugFactory(PeakInFactory):
    class Meta:
        model = peak_model.PeakWithSlug
Ejemplo n.º 8
0
from factory.random import reseed_random

reseed_random("rocket-args")
Ejemplo n.º 9
0
def fix_random_seed():
    """Make sure tests using Faker will have reproducible results"""
    random.reseed_random("fixed random seed")
Ejemplo n.º 10
0
def set_seed(connection):
    random.reseed_random("nmdc")