Пример #1
0
    def populate_data(self):
        people = AutoFixture(
            Person,
            field_values={
                "anonymised": False,
                "name": generators.FirstNameGenerator()
            },
        ).create(5)

        for person in people:
            AutoFixture(HealthRecord,
                        field_values={
                            "anonymised": False,
                            "person": person
                        }).create(random.randint(1, 3))

            AutoFixture(
                PersonProfile,
                field_values={
                    "anonymised": False,
                    "person": person,
                    "age": generators.IntegerGenerator(5, 55),
                    "address": generators.LoremGenerator(max_length=100),
                },
            ).create(random.randint(1, 3))

            AutoFixture(
                MailingListLog,
                field_values={
                    "anonymised": False,
                    "email": person.email,
                    "sent_at": generators.DateTimeGenerator(),
                },
            ).create(random.randint(1, 3))
Пример #2
0
class ContactoAutoFixture(AutoFixture):
    field_values = {
        'nombre': generators.FirstNameGenerator(),
        'apellidos': generators.LastNameGenerator(),
        'direccion': generators.StringGenerator(),
        'telefono': '+' + str(randint(100000000000, 1000000000000))
    }
Пример #3
0
 class RoleAutoFixture(AutoFixture):
     field_values = {
         'name': RoleNameGenerator(),
         'github_user': generators.FirstNameGenerator(),
         'github_repo': generators.StringGenerator(min_length=6, max_length=10),
         'description': generators.LoremGenerator(max_length=250),
         'readme': generators.LoremHTMLGenerator(),
         'min_ansible_version': generators.StaticGenerator('1.3'),
         'issue_tracker_url': generators.URLGenerator(),
         'license': generators.StaticGenerator(''),
         'company': generators.StaticGenerator(''),
         'is_valid': generators.StaticGenerator(True),
     }
Пример #4
0
 def makePat(self):
     field_values = {
         'Patient_ID':
         generators.IntegerGenerator(min_value=1, max_value=111111),
         'FullName':
         generators.FirstNameGenerator(),
         'FullAddress':
         generators.LoremSentenceGenerator(),
         'Patient_History':
         generators.LoremSentenceGenerator(),
         'RegisterPatientRemoteMonitoring':
         generators.BooleanGenerator(),
         'Credential':
         generators.ImageGenerator(),
         #'DoctorID': generators.IntegerGenerator(min_value=5,max_value=5),
         #'InsuranceCompanyID':generators.IntegerGenerator(min_value=2,max_value=99) ,
     }
     fixture = AutoFixture(Patient, generate_fk=True)
     entries = fixture.create(5)
Пример #5
0
    def handle(self, *args, **options):

        # 1. Users
        AutoFixture(
            User,
            field_values={
                # Generates random birth dates between 7-77 yo
                'birth_date':
                generators.DateGenerator(
                    min_date=dt.date.today() - dt.timedelta(365 * 77),
                    max_date=dt.date.today() - dt.timedelta(365 * 7)),
                # We are a young company so just set join_date to 1-2 years
                'date_joined':
                generators.DateGenerator(
                    min_date=dt.date.today() - dt.timedelta(365 * 2),
                    max_date=dt.date.today() - dt.timedelta(365 * 1)),
                'email':
                generators.EmailGenerator(),
                'first_name':
                generators.FirstNameGenerator(),
                'img':
                generators.ImageGenerator(height=200, width=200,
                                          path='users/'),
                'last_name':
                generators.LastNameGenerator(),
                'oauth_id':
                generators.PositiveIntegerGenerator()
            }).create(10)

        # 2. Items
        AutoFixture(Item,
                    field_values={
                        'name':
                        ItemNameGenerator(),
                        'img':
                        generators.ImageGenerator(height=200,
                                                  width=200,
                                                  path='items/')
                    }).create(80)
Пример #6
0
class AuthorFixture(AutoFixture):
    field_values = {
        'user': UserGenerator(),
        'name': generators.FirstNameGenerator(),
        'age': generators.PositiveIntegerGenerator(min_value=20, max_value=80)
    }
Пример #7
0
class CategoriesFixture(AutoFixture):
    field_values = {
        'name': generators.FirstNameGenerator(),
        'description': generators.LoremGenerator(),
        #'picture' : generators.ImageGenerator()
    }
Пример #8
0
    def handle(self, *args, **options):

        fixture = AutoFixture(User,
                              field_values={
                                  'username':
                                  generators.StringGenerator(max_length=10),
                                  'first_name':
                                  generators.FirstNameGenerator(),
                                  'last_name':
                                  generators.LastNameGenerator(),
                                  'email':
                                  generators.EmailGenerator(),
                                  'password':
                                  UNUSABLE_PASSWORD
                              })
        entries = fixture.create(50)

        for us in User.objects.all():
            if us.username != 'alberto':
                us.set_password('pass')
                us.save()

        fixture = AutoFixture(
            auction,
            field_values={
                'min_price':
                generators.PositiveSmallIntegerGenerator(max_value=1000),
                'lock':
                False
            })
        entries = fixture.create(50)

        fixture = AutoFixture(bid,
                              field_values={
                                  'amount':
                                  generators.IntegerGenerator(min_value=0),
                                  'status':
                                  'W'
                              })
        entries = fixture.create(20)

        auct = auction.objects.all()
        for auc in auct:
            if (auc.deadline > timezone.make_aware(
                    datetime.now(), timezone.get_default_timezone())):
                auc.lifecycle = 'A'
                auc.save()
            if (auc.deadline < timezone.make_aware(
                    datetime.now(), timezone.get_default_timezone())
                    and auc.lifecycle == 'A'):
                auc.lifecycle = 'D'
                auc.save()

        bids = bid.objects.all()
        for b in bids:
            for a in bids:
                if (b.auct == a.auct and a != b):
                    if (b.status == 'W' and a.status == 'W'):
                        if (b.amount > a.amount):
                            a.status = 'L'
                            a.save()
                        else:
                            b.status = 'L'
                            b.save()
            if (b.amount < b.auct.min_price):
                b.amount = b.auct.min_price + 1
                b.save()
            if (b.user == b.auct.seller):
                b.delete()