Example #1
0
// test Create / POST functionality
func creates(edImageBatch, crVideoBatch espsdk.Batch) {
	makeBomb("create_batch", "POST", espsdk.BatchesEndpoint, espsdk.Batch{
		SubmissionName:        appID + ": " + fake.FullName(),
		SubmissionType:        "getty_editorial_still",
		SaveExtractedMetadata: false,
	})

	edImage := espsdk.Contribution{
		// reference time: Mon Jan 2 15:04:05 -0700 MST 2006
		CameraShotDate:       time.Now().Format("01/02/2006 15:04:05 -0700"),
		ContentProviderName:  "SHERER, John",
		ContentProviderTitle: "Contributor",
		CountryOfShoot:       "United Kingdom",
		CreditLine:           "John Sherer",
		ExternalFileLocation: "https://c2.staticflickr.com/4/3747/11235643633_60b8701616_o.jpg",
		FileName:             "11235643633_60b8701616_o.jpg",
		Headline:             fake.Sentence(),
		IPTCCategory:         "S",
		SiteDestination:      []string{"Editorial", "WireImage.com"},
		Source:               "AFP",
		SubmissionBatchID:    edImageBatch.ID,
	}
	makeBomb("create_photo", "POST", edImage.Path(), edImage)
	makeMissile("create_and_submit_photo", edImage.CreateAndSubmit)

	release := espsdk.Release{
		FileName:          "some_property.jpg",
		FilePath:          "submission/releases/batch_86572/24780225369200015_some_property.jpg",
		MimeType:          "image/jpeg",
		ReleaseType:       "Property",
		SubmissionBatchID: crVideoBatch.ID,
	}
	makeBomb("create_release", "POST", release.Path(), release)
}
Example #2
0
func main() {
	cfg := NewConfig()

	if err := cfg.Load("config.json"); err != nil {
		log.Printf("[ERROR] %+v", err)
		return
	}
	defer func() {
		if err := cfg.Save(); err != nil {
			log.Printf("[ERROR] %+v", err)
			return
		}
	}()

	if len(cfg.Ips) > 100 {
		for k, v := range cfg.Ips {
			cfg.DeleteIp(k)
			log.Printf("Delete IP %s: %s", k, v)
			break
		}
	}

	fake.SetLang("ru")
	ipParams := cfg.SetIp(fake.IPv4(), true)
	ipParams.Description = fake.FullName()
	ipParams.SetExpire(time.Now().Add(time.Minute))

	pp.Println(cfg.AllowIp("181.113.250.128"))
	pp.Println(cfg.AllowIp("89.155.206.159"))
}
Example #3
0
// TestConcurrentSafety runs fake methods in multiple go routines concurrently.
// This test should be run with the race detector enabled.
func TestConcurrentSafety(t *testing.T) {
	workerCount := 10
	doneChan := make(chan struct{})

	for i := 0; i < workerCount; i++ {
		go func() {
			for j := 0; j < 1000; j++ {
				fake.FirstName()
				fake.LastName()
				fake.Gender()
				fake.FullName()
				fake.Day()
				fake.Country()
				fake.Company()
				fake.Industry()
				fake.Street()
			}
			doneChan <- struct{}{}
		}()
	}

	for i := 0; i < workerCount; i++ {
		<-doneChan
	}
}
Example #4
0
func genFakeData(v *Value) interface{} {
	if len(v.Tags) == 0 {
		return v.Data
	}

	typ, ok := v.Tags.Get("type")
	if !ok {
		return v.Data
	}
	switch typ {
	case fieldTags.Brand:
		return fake.Brand()
	case fieldTags.Character:
		return fake.Character()
	case fieldTags.Characters:
		return fieldTags.Characters
	case fieldTags.CharactersN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.CharactersN(max)
	case fieldTags.City:
		return fake.City()
	case fieldTags.Color:
		return fake.Color()
	case fieldTags.Company:
		return fake.Company()
	case fieldTags.Continent:
		return fake.Continent()
	case fieldTags.Country:
		return fake.Country()
	case fieldTags.CreditCardNum:
		vendor, _ := v.Tags.Get("vendor")
		fake.CreditCardNum(vendor)
	case fieldTags.Currency:
		fake.Currency()
	case fieldTags.CurrencyCode:
		fake.CurrencyCode()
	case fieldTags.Day:
		return fake.Day()
	case fieldTags.Digits:
		return fake.Digits()
	case fieldTags.DigitsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.DigitsN(max)
	case fieldTags.DomainName:
		return fake.DomainName()
	case fieldTags.DomainZone:
		return fake.DomainZone()
	case fieldTags.EmailAddress:
		return fake.EmailAddress()
	case fieldTags.EmailBody:
		return fake.EmailBody()
	case fieldTags.FemaleFirstName:
		return fake.FemaleFirstName()
	case fieldTags.FemaleFullName:
		return fake.FemaleFullName()
	case fieldTags.FemaleFullNameWithPrefix:
		return fake.FemaleFullNameWithPrefix()
	case fieldTags.FemaleFullNameWithSuffix:
		return fake.FemaleFullNameWithSuffix()
	case fieldTags.FemaleLastName:
		return fake.FemaleLastName()
	case fieldTags.FemaleLastNamePratronymic:
		return fake.FemalePatronymic()
	case fieldTags.FirstName:
		return fake.FirstName()
	case fieldTags.FullName:
		return fake.FullName()
	case fieldTags.FullNameWithPrefix:
		return fake.FullNameWithPrefix()
	case fieldTags.FullNameWithSuffix:
		return fake.FullNameWithSuffix()
	case fieldTags.Gender:
		return fake.Gender()
	case fieldTags.GenderAbrev:
		return fake.GenderAbbrev()
	case fieldTags.HexColor:
		return fake.HexColor()
	case fieldTags.HexColorShort:
		return fake.HexColorShort()
	case fieldTags.IPv4:
		return fake.IPv4()
	case fieldTags.Industry:
		return fake.Industry()
	case fieldTags.JobTitle:
		return fake.JobTitle()
	case fieldTags.Language:
		return fake.Language()
	case fieldTags.LastName:
		return fake.LastName()
	case fieldTags.LatitudeDegrees:
		return fake.LatitudeDegress()
	case fieldTags.LatitudeDirection:
		return fake.LatitudeDirection()
	case fieldTags.LatitudeMinutes:
		return fake.LatitudeMinutes()
	case fieldTags.LatitudeSeconds:
		return fake.LatitudeSeconds()
	case fieldTags.Latitude:
		return fake.Latitute()
	case fieldTags.LongitudeDegrees:
		return fake.LongitudeDegrees()
	case fieldTags.LongitudeDirection:
		return fake.LongitudeDirection()
	case fieldTags.LongitudeMinutes:
		return fake.LongitudeMinutes()
	case fieldTags.LongitudeSeconds:
		return fake.LongitudeSeconds()
	case fieldTags.MaleFirstName:
		return fake.MaleFirstName()
	case fieldTags.MaleFullNameWithPrefix:
		return fake.MaleFullNameWithPrefix()
	case fieldTags.MaleFullNameWithSuffix:
		return fake.MaleFullNameWithSuffix()
	case fieldTags.MaleLastName:
		return fake.MaleLastName()
	case fieldTags.MalePratronymic:
		return fake.MalePatronymic()
	case fieldTags.Model:
		return fake.Model()
	case fieldTags.Month:
		return fake.Month()
	case fieldTags.MonthNum:
		return fake.MonthNum()
	case fieldTags.MonthShort:
		return fake.MonthShort()
	case fieldTags.Paragraph:
		return fake.Paragraph()
	case fieldTags.Patagraphs:
		return fake.Paragraphs()
	case fieldTags.PatagraphsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.ParagraphsN(max)
	case fieldTags.Password:
		var (
			atLeast                                = 5
			atMost                                 = 8
			allowUpper, allowNumeric, allowSpecial = true, true, true
		)
		if least, err := v.Tags.Int("at_least"); err == nil {
			atLeast = least
		}
		if most, err := v.Tags.Int("at_most"); err == nil {
			atMost = most
		}
		if upper, err := v.Tags.Bool("upper"); err == nil {
			allowUpper = upper
		}
		if numeric, err := v.Tags.Bool("numeric"); err == nil {
			allowNumeric = numeric
		}
		if special, err := v.Tags.Bool("special"); err == nil {
			allowSpecial = special
		}
		return fake.Password(atLeast, atMost, allowUpper, allowNumeric, allowSpecial)
	case fieldTags.Patronymic:
		return fake.Patronymic()
	case fieldTags.Phone:
		return fake.Phone()
	case fieldTags.Product:
		return fake.Product()
	case fieldTags.ProductName:
		return fake.ProductName()
	case fieldTags.Sentence:
		return fake.Sentence()
	case fieldTags.Sentences:
		return fake.Sentence()
	case fieldTags.SentencesN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.SentencesN(max)
	case fieldTags.SimplePassWord:
		return fake.SimplePassword()
	case fieldTags.State:
		return fake.State()
	case fieldTags.StateAbbrev:
		return fake.StateAbbrev()
	case fieldTags.Street:
		return fake.Street()
	case fieldTags.StreetAddress:
		return fake.StreetAddress()
	case fieldTags.Title:
		return fake.Title()
	case fieldTags.TopLevelDomain:
		return fake.TopLevelDomain()
	case fieldTags.UserName:
		return fake.UserName()
	case fieldTags.WeekDay:
		return fake.WeekDay()
	case fieldTags.WeekDayNum:
		return fake.WeekdayNum()
	case fieldTags.WeekDayShort:
		return fake.WeekDayShort()
	case fieldTags.Word:
		return fake.Word()
	case fieldTags.Words:
		return fake.Words()
	case fieldTags.WordsN:
		max := 5
		if m, err := v.Tags.Int("max"); err == nil {
			max = m
		}
		return fake.WordsN(max)
	case fieldTags.Year:
	//return fake.Year()
	case fieldTags.Zip:
		return fake.Zip()
	}

	return v.Data
}
Example #5
0
// FullName generates full name it can occasionally include prefix
// or suffix
func (s *Stabber) FullName(lang string) string {
	setLang(lang)
	return fake.FullName()
}
Example #6
0
func genFakeData(v *Value, kind string) interface{} {
	if len(v.Tags) == 0 {
		return v.Data
	}

	typ, ok := v.Tags["type"]
	if !ok {
		return v.Data
	}
	switch typ {
	case fieldTags.Brand:
		return fake.Brand()
	case fieldTags.Character:
		return fake.Character()
	case fieldTags.Characters:
		return fieldTags.Characters
	case fieldTags.CharactersN:
		return fake.CharactersN(5)
	case fieldTags.City:
		return fake.City()
	case fieldTags.Color:
		return fake.Color()
	case fieldTags.Company:
		return fake.Company()
	case fieldTags.Continent:
		return fake.Continent()
	case fieldTags.Country:
		return fake.Country()
	case fieldTags.CreditCardNum:
		fake.CreditCardNum("vendor")
	case fieldTags.Currency:
		fake.Currency()
	case fieldTags.CurrencyCode:
		fake.CurrencyCode()
	case fieldTags.Day:
		return fake.Day()
	case fieldTags.Digits:
		return fake.Digits()
	case fieldTags.DigitsN:
		return fake.DigitsN(5)
	case fieldTags.DomainName:
		return fake.DomainName()
	case fieldTags.DomainZone:
		return fake.DomainZone()
	case fieldTags.EmailAddress:
		return fake.EmailAddress()
	case fieldTags.EmailBody:
		return fake.EmailBody()
	case fieldTags.FemaleFirstName:
		return fake.FemaleFirstName()
	case fieldTags.FemaleFullName:
		return fake.FemaleFullName()
	case fieldTags.FemaleFullNameWithPrefix:
		return fake.FemaleFullNameWithPrefix()
	case fieldTags.FemaleFullNameWithSuffix:
		return fake.FemaleFullNameWithSuffix()
	case fieldTags.FemaleLastName:
		return fake.FemaleLastName()
	case fieldTags.FemaleLastNamePratronymic:
		return fake.FemalePatronymic()
	case fieldTags.FirstName:
		return fake.FirstName()
	case fieldTags.FullName:
		return fake.FullName()
	case fieldTags.FullNameWithPrefix:
		return fake.FullNameWithPrefix()
	case fieldTags.FullNameWithSuffix:
		return fake.FullNameWithSuffix()
	case fieldTags.Gender:
		return fake.Gender()
	case fieldTags.GenderAbrev:
		return fake.GenderAbbrev()
	case fieldTags.HexColor:
		return fake.HexColor()
	case fieldTags.HexColorShort:
		return fake.HexColorShort()
	case fieldTags.IPv4:
		return fake.IPv4()
	case fieldTags.Industry:
		return fake.Industry()
	case fieldTags.JobTitle:
		return fake.JobTitle()
	case fieldTags.Language:
		return fake.Language()
	case fieldTags.LastName:
		return fake.LastName()
	case fieldTags.LatitudeDegrees:
		return fake.LatitudeDegress()
	case fieldTags.LatitudeDirection:
		return fake.LatitudeDirection()
	case fieldTags.LatitudeMinutes:
		return fake.LatitudeMinutes()
	case fieldTags.LatitudeSeconds:
		return fake.LatitudeSeconds()
	case fieldTags.Latitude:
		return fake.Latitute()
	case fieldTags.LongitudeDegrees:
		return fake.LongitudeDegrees()
	case fieldTags.LongitudeDirection:
		return fake.LongitudeDirection()
	case fieldTags.LongitudeMinutes:
		return fake.LongitudeMinutes()
	case fieldTags.LongitudeSeconds:
		return fake.LongitudeSeconds()
	case fieldTags.MaleFirstName:
		return fake.MaleFirstName()
	case fieldTags.MaleFullNameWithPrefix:
		return fake.MaleFullNameWithPrefix()
	case fieldTags.MaleFullNameWithSuffix:
		return fake.MaleFullNameWithSuffix()
	case fieldTags.MaleLastName:
		return fake.MaleLastName()
	case fieldTags.MalePratronymic:
		return fake.MalePatronymic()
	case fieldTags.Model:
		return fake.Model()
	case fieldTags.Month:
		return fake.Month()
	case fieldTags.MonthNum:
		return fake.MonthNum()
	case fieldTags.MonthShort:
		return fake.MonthShort()
	case fieldTags.Paragraph:
		return fake.Paragraph()
	case fieldTags.Patagraphs:
		return fake.Paragraphs()
	case fieldTags.PatagraphsN:
		return fake.ParagraphsN(4)
	case fieldTags.Password:
	//return fake.Password()
	case fieldTags.Patronymic:
		return fake.Patronymic()
	case fieldTags.Phone:
		return fake.Phone()
	case fieldTags.Product:
		return fake.Product()
	case fieldTags.ProductName:
		return fake.ProductName()
	case fieldTags.Sentence:
		return fake.Sentence()
	case fieldTags.Sentences:
		return fake.Sentence()
	case fieldTags.SentencesN:
		return fake.SentencesN(4)
	case fieldTags.SimplePassWord:
		return fake.SimplePassword()
	case fieldTags.State:
		return fake.State()
	case fieldTags.StateAbbrev:
		return fake.StateAbbrev()
	case fieldTags.Street:
		return fake.Street()
	case fieldTags.StreetAddress:
		return fake.StreetAddress()
	case fieldTags.Title:
		return fake.Title()
	case fieldTags.TopLevelDomain:
		return fake.TopLevelDomain()
	case fieldTags.UserName:
		return fake.UserName()
	case fieldTags.WeekDay:
		return fake.WeekDay()
	case fieldTags.WeekDayNum:
		return fake.WeekdayNum()
	case fieldTags.WeekDayShort:
		return fake.WeekDayShort()
	case fieldTags.Word:
		return fake.Word()
	case fieldTags.Words:
		return fake.Words()
	case fieldTags.WordsN:
		return fake.WordsN(4)
	case fieldTags.Year:
	//return fake.Year()
	case fieldTags.Zip:
		return fake.Zip()
	}

	return v.Data
}
Example #7
0
func TestNames(t *testing.T) {
	for _, lang := range fake.GetLangs() {
		fake.SetLang(lang)

		v := fake.MaleFirstName()
		if v == "" {
			t.Errorf("MaleFirstName failed with lang %s", lang)
		}

		v = fake.FemaleFirstName()
		if v == "" {
			t.Errorf("FemaleFirstName failed with lang %s", lang)
		}

		v = fake.FirstName()
		if v == "" {
			t.Errorf("FirstName failed with lang %s", lang)
		}

		v = fake.MaleLastName()
		if v == "" {
			t.Errorf("MaleLastName failed with lang %s", lang)
		}

		v = fake.FemaleLastName()
		if v == "" {
			t.Errorf("FemaleLastName failed with lang %s", lang)
		}

		v = fake.LastName()
		if v == "" {
			t.Errorf("LastName failed with lang %s", lang)
		}

		v = fake.MalePatronymic()
		if v == "" {
			t.Errorf("MalePatronymic failed with lang %s", lang)
		}

		v = fake.FemalePatronymic()
		if v == "" {
			t.Errorf("FemalePatronymic failed with lang %s", lang)
		}

		v = fake.Patronymic()
		if v == "" {
			t.Errorf("Patronymic failed with lang %s", lang)
		}

		v = fake.MaleFullNameWithPrefix()
		if v == "" {
			t.Errorf("MaleFullNameWithPrefix failed with lang %s", lang)
		}

		v = fake.FemaleFullNameWithPrefix()
		if v == "" {
			t.Errorf("FemaleFullNameWithPrefix failed with lang %s", lang)
		}

		v = fake.FullNameWithPrefix()
		if v == "" {
			t.Errorf("FullNameWithPrefix failed with lang %s", lang)
		}

		v = fake.MaleFullNameWithSuffix()
		if v == "" {
			t.Errorf("MaleFullNameWithSuffix failed with lang %s", lang)
		}

		v = fake.FemaleFullNameWithSuffix()
		if v == "" {
			t.Errorf("FemaleFullNameWithSuffix failed with lang %s", lang)
		}

		v = fake.FullNameWithSuffix()
		if v == "" {
			t.Errorf("FullNameWithSuffix failed with lang %s", lang)
		}

		v = fake.MaleFullName()
		if v == "" {
			t.Errorf("MaleFullName failed with lang %s", lang)
		}

		v = fake.FemaleFullName()
		if v == "" {
			t.Errorf("FemaleFullName failed with lang %s", lang)
		}

		v = fake.FullName()
		if v == "" {
			t.Errorf("FullName failed with lang %s", lang)
		}
	}
}
Example #8
0
func (this FakeAdapter) FullName() string {
	return fake.FullName()
}