GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — go-lytics/content_test.go at master · lytics/go-lytics Expand file tree/ Copy pathcontent_test.goMore file actions 116 lines (92 loc) · 3.25 KB / Copy pathcontent_test.goFile metadata and controls116 lines (92 loc) · 3.25 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 package lytics import ( "testing" "github.com/stretchr/testify/assert" "github.com/jarcoal/httpmock" "github.com/lytics/go-lytics/mock" ) func TestGetUserContentRecommendation(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() filter := &RecommendationFilter{ Limit: 1, Shuffle: false, Topics: []string{"mock", "test"}, Visited: false, } client := NewLytics(mock.MockApiKey, nil) recs, err := client.GetUserContentRecommendation("user_id", mock.MockUserID, filter) assert.Equal(t, err, nil) assert.Equal(t, len(recs), 1) assert.Equal(t, recs[0].Url, "www.testwebsite.com/some/url") assert.Equal(t, recs[0].Confidence, 0.8328074038765564) } func TestGetSegmentContentRecommendation(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() filter := &RecommendationFilter{ Limit: 1, Rank: "popular", } client := NewLytics(mock.MockApiKey, nil) recs, err := client.GetSegmentContentRecommendation(mock.MockSegmentID1, filter) assert.Equal(t, err, nil) assert.Equal(t, len(recs), 1) assert.Equal(t, recs[0].Url, "www.testwebsite.com/some/url") assert.Equal(t, recs[0].Confidence, 0.8328074038765564) } func TestGetDocuments(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() client := NewLytics(mock.MockApiKey, nil) docs, err := client.GetDocuments([]string{}, 1) assert.Equal(t, err, nil) assert.Equal(t, len(docs.Urls), 1) assert.Equal(t, docs.Total, 5000) assert.Equal(t, docs.Urls[0].Url, "www.testwebsite.com/some/url") urls := []string{"www.testwebsite.com/some/url", "www.testwebsite.com/path/to/my-article"} docs, err = client.GetDocuments(urls, 0) assert.Equal(t, err, nil) assert.Equal(t, len(docs.Urls), 2) assert.Equal(t, docs.Urls[0].Url, "www.testwebsite.com/some/url") assert.Equal(t, docs.Urls[1].Url, "www.testwebsite.com/path/to/my-article") } func TestGetTopicSummary(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() client := NewLytics(mock.MockApiKey, nil) topicSummary, err := client.GetTopicSummary(mock.MockTopicID, 0) assert.Equal(t, err, nil) assert.Equal(t, topicSummary.Docs.Total, 1) assert.Equal(t, topicSummary.Topics.Present, 7890) assert.Equal(t, topicSummary.Topics.HighBucket, 351) } func TestGetContentTaxonomy(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() client := NewLytics(mock.MockApiKey, nil) taxonomy, err := client.GetContentTaxonomy() assert.Equal(t, err, nil) assert.Equal(t, taxonomy.DocCount, 438) assert.Equal(t, taxonomy.Nodes[0].Name, "marketing technology") assert.Equal(t, taxonomy.Nodes[1].Count, 1) } func TestGetTopicRollups(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() mock.RegisterContentMocks() client := NewLytics(mock.MockApiKey, nil) rollups, err := client.GetTopicRollups() assert.Equal(t, err, nil) assert.Equal(t, len(rollups), 2) assert.Equal(t, rollups[0].Label, "Marketing") assert.Equal(t, len(rollups[0].Topics), 3) assert.Equal(t, rollups[0].AcctId, mock.MockAccountID) assert.Equal(t, rollups[1].Label, "Data science") assert.Equal(t, rollups[1].Topics[0].Label, "Data") } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |