Пример #1
0
    def setUp(self):
        super(TestGoogleDriveUpload, self).setUp()

        _ = Field('en')
        schema_desc = (lambda: {
            'name': _('person.name'),
            'street': _('street_name'),
            'city': _('city'),
            'email': _('person.email'),
            'zip': _('zip_code'),
            'region': _('region'),
            'state': _('state'),
            'date_time': _('formatted_datetime'),
            'company_name': _('company')
        })
        schema = Schema(schema=schema_desc)
        result = schema.create(iterations=1000)
        pd.DataFrame.from_dict(result).to_csv(_data_path)

        self.blob = self.env['odoo_file_export.blob'].create({
            'name':
            'Prueba',
            'file':
            _data_path,
            'storage_account_url':
            'https://pruebasdigitalhigh.blob.core.windows.net/',
            'container':
            'octupuscontainer',
            'blob_name':
            'test_blob_odoo',
            'credential':
            'xwbdS/I9ZYt062FyP8dNIKU8Fac7otp5URvVlhJo/8vGEVEGU6O+N03Bjiu6Y+np85Qe0QPU2b5xkiY9NcJePA=='
        })
Пример #2
0
    def setUp(self):
        super(TestGoogleDriveUpload, self).setUp()

        _ = Field('en')
        schema_desc = (
            lambda: {
                'name': _('person.name'),
                'street': _('street_name'),
                'city': _('city'),
                'email': _('person.email'),
                'zip': _('zip_code'),
                'region': _('region'),
                'state': _('state'),
                'date_time': _('formatted_datetime'),
                'company_name': _('company')

            })
        schema = Schema(schema=schema_desc)
        result = schema.create(iterations=1000)     
        pd.DataFrame.from_dict(result).to_csv(_data_path)

        self.cc = self.env['res.config.settings'].create({
            'google_drive_client_id': '321350850398-ub1vd55bmrjmh2oh96oosi0hn1cliufh.apps.googleusercontent.com',
            'google_drive_client_secret': '0jRNrUmCGlZaJQoTSicZ0OcA'
        })
        
        self.cc.set_values()

        self.gdrive = self.env['odoo_file_export.google_drive'].create({
            'name': 'Prueba',
            'file': _data_path,
            #'target_folder_id': "1JU6WrdUUfJR66x3Ct4mgn0ReUWRGDDDd",
            'target_file_name': "pruebatestoddogoogledrive"
        })
Пример #3
0
def generate_survey_responses(directory, file_date, records, participant_ids,
                              school_ids):
    """
    Generate survey responses file. Depends on survey participants and schools files.
    """
    survey_responses_description = (lambda: {
        'participant_id':
        _('choice', items=list(participant_ids)),
        'question_id':
        _('random.custom_code', mask='Q#####', digit='#'),
        'question_response_text':
        _('text.sentence'),
        'last_change_datetime':
        _('datetime.formatted_datetime',
          fmt="%d/%m/%Y %H:%M:%S",
          start=1800,
          end=1802),
        'record_created_datetime':
        _('datetime.formatted_datetime',
          fmt="%d/%m/%Y %H:%M:%S",
          start=1800,
          end=1802)
    })

    schema = Schema(schema=survey_responses_description)
    survey_responses = pd.DataFrame(schema.create(iterations=records))
    survey_responses.to_csv(directory / f"survey_responses_{file_date}.csv",
                            index=False)
    return survey_responses
Пример #4
0
class SonataJsonDataGen():
    def __init__(
            self,
            gen_file_dir='C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_sonata_plugin\\resources_sonata\\sonata_test_data_gen.json',
            gen_file_name='sonata_gen_data.json',
            num_of_msgs=3,
            seq_num_tcase=1,
            test_case_name="test",
            test_case_msg_id="message"):

        self.gen_file_dir = gen_file_dir

        if test_case_name != None and test_case_msg_id != None:
            self.test_case_name = test_case_name
            self.test_case_msg_id = test_case_msg_id
        else:
            raise Exception(
                "test case or test message name or both is not provided")

        self.g_provider = Generic('en')

        self.generate_sonata_json(num_of_msgs=num_of_msgs)

    def generate_sonata_json(self, num_of_msgs=3, seq_num_tcase=1):

        gt = json_gen_tools(test_case_name=self.test_case_name,
                            test_case_msg_id=self.test_case_msg_id)
        a = 1

        sonata_msg_json = lambda: {
            lambda: gt.build_test_case_id(seq_num_tcase),
            lambda: gt.build_test_msg_id(num_of_msgs),
        }

        self.sonata_schema = Schema(schema=gt.build_sonata_obj())
        sonata_obj = self.sonata_schema.create(iterations=num_of_msgs)
        msgs_lngth = sonata_obj.__len__()
        msg_dict = {}
        for i in sonata_obj:

            name = gt.build_test_msg_id(msgs_lngth)
            msgs_lngth = msgs_lngth - 1
            msg_dict[name] = i

        t_case_dict = {}
        tcase_name = gt.build_test_case_id(seq_num_tcase)
        t_case_dict[tcase_name] = msg_dict
        sonata_json = json.dumps(t_case_dict)

        with open(self.gen_file_dir, "w") as write_file:
            json.dump(t_case_dict, write_file)

        return t_case_dict

    def generate_msgs_set(self):
        return

    def generate_tcase_set(self):
        return
def schema_to_dataframe(session: SparkSession, schema_definition: Callable,
                        num_records: int):
    """Get PySpark DataFrame from a mimesis schema."""
    schema = Schema(schema=schema_definition)
    data = schema.create(iterations=num_records)
    pd_df = pd.DataFrame(data)
    ps_df = session.createDataFrame(pd_df)
    return ps_df
Пример #6
0
def _generate_mimesis(field, schema_description, records_per_partition, seed):
    """ Generate data for a single partition of a dask bag

    See Also
    --------
    _make_mimesis
    """
    from mimesis.schema import Schema, Field
    field = Field(seed=seed, **field)
    schema = Schema(schema=lambda: schema_description(field))
    for i in range(records_per_partition):
        yield schema.create(iterations=1)[0]
Пример #7
0
def profile(request):
    schema = Schema(
        schema=lambda: {
            "email": _("person.email", domains=["test.com"], key=str.lower),
            "first_name": _("person.name"),
            "last_name": _("person.surname"),
            "image_url": _("person.avatar"),
            "date_joined": _("timestamp", posix=False),
        })

    data = schema.create()
    return Response(data, status=status.HTTP_200_OK)
Пример #8
0
def _generate_mimesis(field, schema_description, records_per_partition, seed):
    """Generate data for a single partition of a dask bag

    See Also
    --------
    _make_mimesis
    """
    from mimesis.schema import Field, Schema

    field = Field(seed=seed, **field)
    schema = Schema(schema=lambda: schema_description(field))
    return [schema.create(iterations=1)[0] for i in range(records_per_partition)]
Пример #9
0
    def _generate_people(self):
        people_count = self.similar_people_count * self.max_repeat_count
        ids = iter(range(people_count))
        description_female = (lambda: {
            'id_person': next(ids),
            'full_name': self.person.full_name(Gender.FEMALE),
            'gender': 'F',
        })
        description_male = (lambda: {
            'id_person': next(ids),
            'full_name': self.person.full_name(Gender.MALE),
            'gender': 'M',
        })

        female_count = people_count // 2
        male_count = people_count - female_count
        schema_female = Schema(schema=description_female)
        females = schema_female.create(iterations=female_count)

        schema_male = Schema(schema=description_male)
        males = schema_male.create(iterations=male_count)
        return pd.DataFrame(females + males)
Пример #10
0
def generate():
    _ = Field('en')
    description = (lambda: {
        'timestamp': _('timestamp', posix=False),
        'id': _('uuid'),
        'name': _('text.word'),
        'owner': {
            'token': _('token')
        },
    })
    schema = Schema(schema=description)
    r = schema.create(iterations=1)
    print(r)
    return r
Пример #11
0
def saved_listings(request):
    schema = Schema(
        schema=lambda: {
            "id":
            _("uuid"),
            "name":
            _("text.sentence"),
            "description":
            _("text"),
            "lounges":
            _("numbers.integer_number", start=0, end=8),
            "is_new":
            _("development.boolean"),
            "bedrooms":
            _("numbers.integer_number", start=0, end=6),
            "bathrooms":
            _("numbers.integer_number", start=0, end=8),
            "no_of_likes":
            _("numbers.integer_number", start=0, end=100),
            "location":
            _("address"),
            "listing_images": [
                {
                    "image_url": _("person.avatar")
                },
                {
                    "image_url": _("person.avatar")
                },
                {
                    "image_url": _("person.avatar")
                },
            ],
            "created_on":
            _("timestamp", posix=False),
            "agent": {
                "user": {
                    "email": _(
                        "person.email", domains=["test.com"], key=str.lower),
                    "first_name": _("person.name"),
                    "last_name": _("person.surname"),
                    "image_url": _("person.avatar"),
                    "date_joined": _("timestamp", posix=False),
                },
                "phone_number": _("person.telephone"),
                "agent_display_name": _("business.company"),
            },
        })

    data = schema.create(iterations=int(request.query_params.get("l", 5)))
    return Response(data, status=status.HTTP_200_OK)
Пример #12
0
def generate_question_lookup(directory, file_date, records, question_ids):
    """
    Generate question id to name lookup. Depends on survey responses file.
    """
    question_lookup_description = (
        lambda: {
            'question_id': _('choice', items=question_ids),
            'new_variables_names': "_".join(_('text.words', quantity=4)).lower(
            )
        })

    schema = Schema(schema=question_lookup_description)
    question_lookup = pd.DataFrame(schema.create(iterations=records))
    question_lookup.to_csv(directory / f"question_lookup_{file_date}.csv",
                           index=False)
    return question_lookup
Пример #13
0
def generate_lab_saliva(directory, file_date, records):
    """
    Generate lab saliva file.
    """
    lab_saliva_description = (
        lambda: {
            'ORDPATNAME': _(
                'random.custom_code', mask='SIS########', digit='#'),
            'SAMPLEID': _('random.custom_code', mask='H#########', digit='#'),
            'IgG Capture Result': _('choice', items=['#r', '#n', '#e'])
        })

    schema = Schema(schema=lab_saliva_description)
    lab_saliva = pd.DataFrame(schema.create(iterations=records))
    lab_saliva.to_csv(directory / f"lab_saliva_{file_date}.csv", index=False)
    return lab_saliva
Пример #14
0
def generate_survey_schools(directory, file_date, records):
    """
    Generate survey schools file.
    """
    survey_schools_description = (
        lambda: {
            'schl_nm':
            " ".join(_('text.words', quantity=4)).title(),
            'schl_post_cde':
            _('address.postal_code'),
            'schl_urn':
            _('random.custom_code', mask='######', digit='#'),
            'studyconsent':
            _('numbers.integer_number', start=0, end=1),
            'schl_child_cnt':
            _('numbers.integer_number', start=50, end=100),
            # Don't think we use individual year counts in the pipeline
            'head_teacher_nm':
            _('full_name'),
            'school_telephone_number':
            _('person.telephone'),
            'school_contact_email':
            _('person.email', domains=['gsnail.ac.uk']),
            'information_consent':
            _('numbers.integer_number', start=0, end=1),
            'schl_la_nm':
            _('address.state'),
            'change_indicator':
            _('numbers.integer_number', start=0, end=1),
            'last_change_datetime':
            _('datetime.formatted_datetime',
              fmt="%d/%m/%Y %H:%M:%S",
              start=1800,
              end=1802),
            'record_created_date':
            _('datetime.formatted_datetime',
              fmt="%d/%m/%Y %H:%M:%S",
              start=1800,
              end=1802),
        })

    schema = Schema(schema=survey_schools_description)
    survey_schools = pd.DataFrame(schema.create(iterations=records))
    survey_schools.to_csv(directory / f"survey_schools_{file_date}.csv",
                          index=False)
    return survey_schools
Пример #15
0
def agent_profile(request):
    schema = Schema(
        schema=lambda: {
            "user": {
                "email": _("person.email", domains=["test.com"], key=str.lower
                           ),
                "first_name": _("person.name"),
                "last_name": _("person.surname"),
                "image_url": _("person.avatar"),
                "date_joined": _("timestamp", posix=False),
            },
            "phone_number": _("person.telephone"),
            "agent_display_name": _("business.company"),
        })

    data = schema.create()
    return Response(data, status=status.HTTP_200_OK)
Пример #16
0
def generate_survey_participants(directory, file_date, records, school_urns):
    """
    Generate survey participants file. Depends on survey schools file.
    """
    survey_participants_description = (
        lambda: {
            'participant_type':
            _('choice', items=['type_1', 'type_2']),
            # Assume we don't need real types, but do need enrolment questions per type
            'participant_id':
            _('random.custom_code', mask='P#########', digit='#'),
            'parent_participant_id':
            _('random.custom_code', mask='P#########', digit='#'),
            'participant_first_nm':
            _('person.first_name'),
            'participant_family_name':
            _('person.last_name'),
            'email_addrs':
            _('person.email', domains=['gsnail.ac.uk']),
            'schl_urn':
            _('choice', items=list(school_urns)),
            'consent':
            _('numbers.integer_number', start=0, end=1),
            'change_date':
            _('datetime.formatted_datetime',
              fmt="%d/%m/%Y %H:%M:%S",
              start=1800,
              end=1802),
            'record_created_date':
            _('datetime.formatted_datetime',
              fmt="%d/%m/%Y %H:%M:%S",
              start=1800,
              end=1802),
        })

    schema = Schema(schema=survey_participants_description)
    survey_participants = pd.DataFrame(schema.create(iterations=records))

    # Type 2 doesn't have registered parents
    survey_participants.loc[survey_participants["participant_type"] ==
                            "type_2", "parent_participant_id"] = pd.NA

    survey_participants.to_csv(directory /
                               f"survey_participants_{file_date}.csv",
                               index=False)
    return survey_participants
Пример #17
0
 def generate_purchases(self, size=10000):
     fake = self.fake
     _ = self._
     end_date = datetime.fromisoformat('2021-01-01')
     start_date = end_date - timedelta(days=100)
     purchases = (lambda: {
         'purchaseId':
         fake.uuid4(),
         'purchaseTime':
         fake.date_time_between(start_date=start_date, end_date=end_date).
         strftime("%Y-%m-%d %H:%M:%S"),
         'billingCost':
         _('price')[1:],
         'isConfirmed':
         _('boolean')
     })
     schema = Schema(schema=purchases)
     return schema.create(iterations=size)
Пример #18
0
    def _generate_cards(self):
        person_ids = iter(self._generate_ids())
        int_loans = np.random.randint(1, 101, self.records_count)
        float_loans = np.array(int_loans * 1000, np.float64)
        loans = iter(float_loans)

        description_c = (lambda: {
            'id_person':
            next(person_ids),
            'credit_card_num':
            self.payment.credit_card_number(card_type=CardType.VISA),
            'credit_card_exp_date':
            self.payment.credit_card_expiration_date(maximum=21, minimum=19),
            'loan':
            next(loans),
        })
        schema_card = Schema(schema=description_c)
        cards = schema_card.create(iterations=self.records_count)
        return pd.DataFrame(cards)
Пример #19
0
def generate_lab_bloods(directory, file_date, records):
    """
    Generate lab bloods file.
    """
    lab_bloods_description = (lambda: {
        'specimenId':
        _('random.custom_code', mask='#########THR', digit='#'),
        'specimenProcessedDate':
        _('datetime.formatted_datetime',
          fmt="%Y-%m-%dT%H:%M:%SZ",
          start=1800,
          end=1802),
        'testResult':
        _('choice', items=['Positive', 'Negative'])
    })

    schema = Schema(schema=lab_bloods_description)
    lab_bloods = pd.DataFrame(schema.create(iterations=records))
    lab_bloods.to_csv(directory / f"lab_bloods_{file_date}.csv", index=False)
    return lab_bloods
Пример #20
0
    def handle(self, *args, **options):
        User.objects.all().delete()
        _ = Field('en')
        description = (lambda: {
            'uuid': _('uuid'),
            'username': _('text.word'),
            'password': _('person.password', length=12),
            'first_name': _('person.first_name'),
            'last_name': _('person.last_name'),
            'email': _('person.email', unique=True)
        })
        schema = Schema(schema=description)
        data_list = list(schema.create(iterations=options['iterations']))
        for obj in data_list:
            User.objects.create(**obj)

        User.objects.create_superuser(username='******',
                                      email='super@localhost',
                                      password='******',
                                      first_name='super',
                                      last_name='admin')
Пример #21
0
async def echo(random: str):

    locales = ["en", "cs", "da", "en-au", "en-ca", "et", "es", "it", "ja", "ko", "nl"]

    _ = Field(choice(locales))
    description = lambda: {
        "id": _("uuid"),
        "name": _("text.word"),
        "version": _("version", pre_release=True),
        "timestamp": _("timestamp", posix=False),
        "owner": {
            "email": _("person.email", domains=["google.com", "yahoo.com"], key=str.lower),
            "token": _("token_hex"),
            "creator": _("full_name", gender=Gender.FEMALE),
        },
        "filename": f"/{random}",
    }
    schema = Schema(schema=description)

    message = {"message": schema.create(iterations=1)}
    print(message)
    return message
Пример #22
0
def generate_survey_visits(directory, file_date, records, participant_ids,
                           swab_barcodes, blood_barcodes, saliva_barcodes):
    """
    Generate survey visits file. Depends on survey participants and schools files.
    """
    survey_visits_description = (lambda: {
        'participant_id':
        _('choice', items=list(participant_ids)),
        'visit_date':
        _('datetime.formatted_datetime',
          fmt="%Y-%m-%d %H:%M:%S UTC",
          start=1800,
          end=1802),
        'swab_Sample_barcode':
        _('choice', items=list(swab_barcodes) + [pd.NA]),
        'blood_thriva_barcode':
        _('choice', items=list(blood_barcodes) + [pd.NA]),
        'oral_swab_barcode':
        _('choice', items=list(saliva_barcodes) + [pd.NA]),
        'last_change_datetime':
        _('datetime.formatted_datetime',
          fmt="%d/%m/%Y %H:%M:%S",
          start=1800,
          end=1802),
        'record_created_datetime':
        _('datetime.formatted_datetime',
          fmt="%d/%m/%Y %H:%M:%S",
          start=1800,
          end=1802)
    })

    schema = Schema(schema=survey_visits_description)
    survey_visits = pd.DataFrame(schema.create(iterations=records))
    survey_visits.to_csv(directory / f"survey_visits_{file_date}.csv",
                         index=False)
    return survey_visits
Пример #23
0
def generate_lab_swabs(directory, file_date, records):
    """
    Generate lab swabs file.
    """
    lab_swabs_description = (lambda: {
        'Sample':
        _('random.custom_code', mask='SIS########', digit='#'),
        'Result':
        _('choice', items=["Positive", "Negative"]),
        'Date Tested':
        _('datetime.formatted_datetime',
          fmt="%Y-%m-%d %H:%M:%S UTC",
          start=1800,
          end=1802),
        'Seq-Target':
        "A gene",
        'Seq-Result':
        _('choice', items=["Positive", "Negative"])
    })

    schema = Schema(schema=lab_swabs_description)
    lab_swabs = pd.DataFrame(schema.create(iterations=records))
    lab_swabs.to_csv(directory / f"lab_swabs_{file_date}.csv", index=False)
    return lab_swabs
Пример #24
0
from mimesis import Person 
from mimesis.schema import Field, Schema
from mimesis.enums import Gender
_ = Field('en')
description = (
     lambda: {
         'id': _('uuid'),
         'name': _('text.word'),
         'version': _('version', pre_release=True),
         'timestamp': _('timestamp', posix=False),
         'owner': {
             'email': _('person.email', key=str.lower),
             'token': _('token_hex'),
             'creator': _('full_name', gender=Gender.FEMALE),
         },
     }
 )
schema = Schema(schema=description)
data = schema.create(iterations=1)

print("LOGIN:\n{}".format(data[0]["owner"]["email"]))
print("PASSWORD:\n{}".format(data[0]["owner"]["token"]))
Пример #25
0
def test_none_schema():
    with pytest.raises(UndefinedSchema):
        schema = Schema(schema=None)  # type: ignore
        schema.create()
Пример #26
0
from mimesis.schema import Field, Schema
from mimesis.enums import Gender
_ = Field('en')
description = (
	nam = _('full_name')
	print(nam[2:-5])
     lambda: {
        'id': _('uuid'),
        'name': _('text.word'),
        'version': _('version', pre_release=True),
        'timestamp': _('timestamp', posix=False),
        'Doctor': {
            'name': _('full_name'),
            'doc_id': _('uuid')
        },
    }
)
schema = Schema(schema=description)
print(schema.create(iterations=5))
Пример #27
0
                    description = (lambda: {
                        d[0][int(opt[-1])][0]:
                        field(d[0][int(opt[-1])][1]),
                        d[1][int(opt[-2])][0]:
                        field(d[1][int(opt[-2])][1]),
                        d[2][int(opt[-3])][0]:
                        field(d[2][int(opt[-3])][1]),
                        d[3][int(opt[-4])][0]:
                        field(d[3][int(opt[-4])][1]),
                        d[4][int(opt[-5])][0]:
                        field(d[4][int(opt[-5])][1]),
                        d[5][int(opt[-6])][0]:
                        field(d[5][int(opt[-6])][1]),
                        d[6][int(opt[-7])][0]:
                        field(d[6][int(opt[-7])][1]),
                        d[7][int(opt[-8])][0]:
                        field(d[7][int(opt[-8])][1]),
                        d[8][int(opt[-9])][0]:
                        field(d[8][int(opt[-9])][1]),
                    })
                    schema = Schema(schema=description)
                    res = schema.create(iterations=1)
                    json.dump(res[0], f, ensure_ascii=False)
                    if i < args.count - 1:
                        f.write(",\n")
                    else:
                        f.write("\n")
                f.write("]")
    else:
        print("Выходной каталог не существует.")