class AddressBaseTest(TestCase): def setUp(self): self.address = Address() def tearDown(self): del self.address def test_str(self): self.assertTrue(re.match(STR_REGEX, self.address.__str__())) def test_street_number(self): result = self.address.street_number() self.assertTrue(re.match(r'[0-9]{1,5}$', result)) def test_latitude(self): result = self.address.latitude() self.assertLessEqual(result, 90) def test_longitude(self): result = self.address.longitude() self.assertLessEqual(result, 180) def test_coordinates(self): result = self.address.coordinates() self.assertIsInstance(result, dict) latitude = result['latitude'] self.assertTrue(latitude <= 90) longitude = result['longitude'] self.assertTrue(longitude <= 180)
def product_add_to_db(request): person_data = Personal('ru') person_address = Address('ru') busines = Business('ru') date = Datetime('ru') text = Text('ru') for _ in range(301): Products.objects.create( product_name=text.title(), product_slug=person_data.cid(), product_description=text.text(quantity=5), product_price=random_price(), product_created_at=date.date(start=2017, end=2017, fmt='%Y-%m-%d %H:%M:%S'), product_modified_at=date.date(start=2017, end=2017, fmt='%Y-%m-%d %H:%M:%S'), ) for _ in range(127): user = User.objects.create(username='******'.format( str(datetime.datetime.now().microsecond)), password='******') Consumers.objects.create( user=user, full_name=person_data.full_name(), banned=true_or_false(), gender=person_data.gender(), )
def get_user_data(test_locale='en'): person = {} user = Personal(test_locale) address = Address(test_locale) person['first_name'], person['last_name'] = user.full_name(gender='male').split() common.success("Generated user name '%s %s'" % (person['first_name'], person['last_name'])) person['email'] = user.email(gender='male') common.success("Generated email '%s'" % person['email']) person['street'] = address.address() person['city'] = address.city() person['state'] = address.state() person['postcode'] = address.postal_code() common.success("Generated address '%s %s, %s, %s'" % (person['postcode'], person['state'], person['city'], person['street'])) person['password'] = ''.join(random.SystemRandom().choice(string.digits + string.ascii_letters) for _ in range(10)) common.success("Generated password '%s'" % person['password']) if (test_locale == 'en'): person['country_code'] = 'US' person['country'] = 'United States' person['state_code'] = 'IA' person['state'] = 'Iowa' elif (test_locale == 'ru'): person['country_code'] = 'RU' person['country'] = 'Russian Federation' person['state_code'] = None person['state'] = None else: person['country_code'] = None person['country'] = None person['state_code'] = None person['state'] = None common.success("Generated country '%s' and state '%s'" % (person['country'], person['state'])) return person
def setUp(self): self.address = Address()
from EventClass import Event import random from elizabeth import Text, Address import datetime if (len(sys.argv) == 2): # action with given argument print("Custom Behavior: Saving to ", sys.argv[1]) db = boto3.resource('dynamodb') table = db.Table(sys.argv[1]) else: # default action print("Default Behavior: Saving to Development Databasee") db = boto3.resource('dynamodb') table = db.Table('ColoradoFunDevTable') text = Text('en') address = Address('en') now = datetime.datetime.now() def random_date(start, end): """Generate a random datetime between `start` and `end`""" return start + datetime.timedelta( # Get a random amount of seconds between `start` and `end` seconds=random.randint(0, int((end - start).total_seconds())), ) for i in range(50): event = Event() myID = "" for i in range(14):
# for work with Active Directry from ldap3 import Server, Connection, ALL, NTLM from ldap3.extend.microsoft.addMembersToGroups import ad_add_members_to_groups as addUsersInGroups # data generator from elizabeth import Personal, Address,Text import random # define constans serverName='lsd-dc1.stand.lsd' connUser="******" connUserPwd="" # enter pwd here usersOU = 'ou=test-ou,dc=stand,dc=lsd' # ou for generated users groupsOU = 'ou=test-groups,dc=stand,dc=lsd'# ou for generated groups address = Address('en') # generate data for OU name person = Personal('en') # generate data for users usersDnList = [] # global list DN of generated users groupsDnList = [] # global list DN of generated groups # let's connect server = Server(serverName, get_info=ALL) conn = Connection(server, user=connUser, password=connUserPwd, authentication=NTLM) conn.bind() #must be TRUE if OK conn.add(usersOU, 'organizationalUnit') # add test-ou for users conn.add(groupsOU, 'organizationalUnit') # add test-ou for groups # generate groups