func MakePremisEvent() *models.PremisEvent { _uuid := uuid.NewV4() return &models.PremisEvent{ Id: rand.Intn(50000) + 1, Identifier: _uuid.String(), EventType: RandomEventType(), DateTime: RandomDateTime(), Detail: fake.Words(), Outcome: fake.Word(), OutcomeDetail: fake.Sentence(), Object: fake.Words(), Agent: fake.MaleFullName(), OutcomeInformation: fake.Sentence(), } }
// 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) }
func MakeChecksum() *models.Checksum { return &models.Checksum{ Id: rand.Intn(50000) + 1, GenericFileId: rand.Intn(50000) + 1, Algorithm: RandomAlgorithm(), DateTime: RandomDateTime(), Digest: fake.Sentence(), } }
func MakeWorkItem() *models.WorkItem { return &models.WorkItem{ Id: rand.Intn(50000) + 1, ObjectIdentifier: RandomObjectIdentifier(), GenericFileIdentifier: "", Name: fake.Word(), Bucket: "aptrust.receiving.virginia.edu", ETag: fake.Word(), BagDate: RandomDateTime(), InstitutionId: rand.Intn(50000) + 1, User: fake.EmailAddress(), Date: RandomDateTime(), Note: fake.Sentence(), Action: RandomAction(), Stage: RandomStage(), Status: RandomStatus(), Outcome: fake.Sentence(), Retry: true, Node: fake.Word(), Pid: rand.Intn(50000) + 1, NeedsAdminReview: false, } }
// test Update / PUT functionality func updates(batch espsdk.Batch, photo espsdk.Contribution) { newBatchData := espsdk.Batch{ ID: batch.ID, Note: "updated note", SubmissionName: "updated headline", } makeBomb("update_a_batch", "PUT", "", newBatchData) contributionUpdate := espsdk.Contribution{ ID: photo.ID, SubmissionBatchID: batch.ID, Headline: fake.Sentence(), } makeBomb("update_a_contribution", "PUT", "", contributionUpdate) }
func MakeDPNWorkItem() *models.DPNWorkItem { _uuid := uuid.NewV4() queuedAt := RandomDateTime() createdAt := RandomDateTime() note := fake.Sentence() return &models.DPNWorkItem{ Id: rand.Intn(50000) + 1, RemoteNode: fake.Word(), Task: RandomFromList(constants.DPNTaskTypes), Identifier: _uuid.String(), QueuedAt: &queuedAt, CompletedAt: nil, Note: ¬e, CreatedAt: createdAt, UpdatedAt: createdAt, } }
func MakeIntellectualObject(fileCount, eventCount, checksumCount, tagCount int) *models.IntellectualObject { objIdentifier := RandomObjectIdentifier() objIdParts := strings.Split(objIdentifier, "/") inst := objIdParts[0] objName := objIdParts[1] files := make([]*models.GenericFile, fileCount) events := make([]*models.PremisEvent, eventCount) tags := make([]*models.Tag, tagCount) for i := 0; i < fileCount; i++ { files[i] = MakeGenericFile(eventCount, checksumCount, objIdentifier) } for i := 0; i < eventCount; i++ { events[i] = MakePremisEvent() } for i := 0; i < tagCount; i++ { tags[i] = MakeTag() } return &models.IntellectualObject{ Id: rand.Intn(50000) + 1, Identifier: objIdentifier, BagName: objName, Institution: inst, InstitutionId: rand.Intn(50000) + 1, Title: fake.Words(), Description: fake.Sentence(), Access: RandomAccess(), AltIdentifier: fake.Word(), GenericFiles: files, PremisEvents: events, CreatedAt: RandomDateTime(), UpdatedAt: RandomDateTime(), IngestS3Bucket: fmt.Sprintf("%s.%s", constants.ReceiveTestBucketPrefix, inst), IngestS3Key: fmt.Sprintf("%s.tar", objName), IngestTarFilePath: fmt.Sprintf("/mnt/aptrust/data/%s/%s.tar", inst, objName), IngestUntarredPath: fmt.Sprintf("/mnt/aptrust/data/%s/%s/", inst, objName), IngestRemoteMd5: fake.Word(), IngestLocalMd5: fake.Word(), IngestMd5Verified: false, IngestMd5Verifiable: false, IngestFilesIgnored: make([]string, 0), IngestTags: tags, IngestErrorMessage: "", } }
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 }
// Sentence generates random sentence func (s *Stabber) Sentence(lang string) string { setLang(lang) return fake.Sentence() }
func MakeTag() *models.Tag { return &models.Tag{ Label: fake.Word(), Value: fake.Sentence(), } }
func TestLoremIpsum(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.Character() if v == "" { t.Errorf("Character failed with lang %s", lang) } v = fake.CharactersN(2) if v == "" { t.Errorf("CharactersN failed with lang %s", lang) } v = fake.Characters() if v == "" { t.Errorf("Characters failed with lang %s", lang) } v = fake.Word() if v == "" { t.Errorf("Word failed with lang %s", lang) } v = fake.WordsN(2) if v == "" { t.Errorf("WordsN failed with lang %s", lang) } v = fake.Words() if v == "" { t.Errorf("Words failed with lang %s", lang) } v = fake.Title() if v == "" { t.Errorf("Title failed with lang %s", lang) } v = fake.Sentence() if v == "" { t.Errorf("Sentence failed with lang %s", lang) } v = fake.SentencesN(2) if v == "" { t.Errorf("SentencesN failed with lang %s", lang) } v = fake.Sentences() if v == "" { t.Errorf("Sentences failed with lang %s", lang) } v = fake.Paragraph() if v == "" { t.Errorf("Paragraph failed with lang %s", lang) } v = fake.ParagraphsN(2) if v == "" { t.Errorf("ParagraphsN failed with lang %s", lang) } v = fake.Paragraphs() if v == "" { t.Errorf("Paragraphs failed with lang %s", lang) } } }
func TestLoremIpsum(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.Character() if v == "" { t.Errorf("Character failed with lang %s", lang) } v = fake.CharactersN(2) if v == "" { t.Errorf("CharactersN failed with lang %s", lang) } v = fake.Characters() if v == "" { t.Errorf("Characters failed with lang %s", lang) } v = fake.Word() if v == "" { t.Errorf("Word failed with lang %s", lang) } v = fake.WordsN(2) if v == "" { t.Errorf("WordsN failed with lang %s", lang) } v = fake.Words() if v == "" { t.Errorf("Words failed with lang %s", lang) } v = fake.Title() if v == "" { t.Errorf("Title failed with lang %s", lang) } v = fake.Sentence() if v == "" { t.Errorf("Sentence failed with lang %s", lang) } v = fake.SentencesN(2) if v == "" { t.Errorf("SentencesN failed with lang %s", lang) } v = fake.Sentences() if v == "" { t.Errorf("Sentences failed with lang %s", lang) } v = fake.Paragraph() if v == "" { t.Errorf("Paragraph failed with lang %s", lang) } v = fake.ParagraphsN(2) if v == "" { t.Errorf("ParagraphsN failed with lang %s", lang) } v = fake.Paragraphs() if v == "" { t.Errorf("Paragraphs failed with lang %s", lang) } vs := fake.WordsNUnique(251) if len(vs) != 251 { t.Errorf("WordsNUnique failed with lang %s", lang) } lw := "" for n, w := range vs { if w == lw { t.Errorf("Duplicate words found") } if w == "" { t.Errorf("Word %d is empty", n) continue } lw = w } } }
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 }
func (this FakeAdapter) Sentence() string { return fake.Sentence() }