Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 4, 2020
1 parent 8f42f4d commit de3c263
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 217 deletions.
4 changes: 2 additions & 2 deletions tasks/broadcasts/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestBroadcastEvents(t *testing.T) {
// add an extra URN fo cathy
db.MustExec(
`INSERT INTO contacts_contacturn(org_id, contact_id, scheme, path, identity, priority)
VALUES(1, $1, 'tel', '+12065551212', 'tel:+12065551212', 100)`, models.CathyID)
VALUES(1, $1, 'tel', '+12065551212', 'tel:+12065551212', 1001)`, models.CathyID)

// change george's URN to an invalid twitter URN so it can't be sent
db.MustExec(
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestBroadcastTask(t *testing.T) {
// add an extra URN fo cathy
db.MustExec(
`INSERT INTO contacts_contacturn(org_id, contact_id, scheme, path, identity, priority)
VALUES(1, $1, 'tel', '+12065551212', 'tel:+12065551212', 100)`, models.CathyID)
VALUES(1, $1, 'tel', '+12065551212', 'tel:+12065551212', 1001)`, models.CathyID)

tcs := []struct {
BroadcastID models.BroadcastID
Expand Down
16 changes: 10 additions & 6 deletions web/org/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,45 @@ func TestMetrics(t *testing.T) {
URL string
Username string
Password string
Response string
Contains []string
}{
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org1UUID),
Username: "",
Password: "",
Contains: []string{`{"error": "invalid authentication"}`},
Response: `{"error": "invalid authentication"}`,
},
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org1UUID),
Username: "metrics",
Password: "invalid",
Contains: []string{`{"error": "invalid authentication"}`},
Response: `{"error": "invalid authentication"}`,
},
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org1UUID),
Username: "invalid",
Password: promToken,
Contains: []string{`{"error": "invalid authentication"}`},
Response: `{"error": "invalid authentication"}`,
},
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org2UUID),
Username: "metrics",
Password: promToken,
Contains: []string{`{"error": "invalid authentication"}`},
Response: `{"error": "invalid authentication"}`,
},
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org1UUID),
Username: "metrics",
Password: adminToken,
Contains: []string{`{"error": "invalid authentication"}`},
Response: `{"error": "invalid authentication"}`,
},
{
URL: fmt.Sprintf("http://localhost:8090/mr/org/%s/metrics", models.Org1UUID),
Username: "metrics",
Password: promToken,
Contains: []string{
`rapidpro_group_contact_count{group_name="All Contacts",group_uuid="d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008",group_type="system",org="UNICEF"} 124`,
`rapidpro_group_contact_count{group_name="Active",group_uuid="d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008",group_type="system",org="UNICEF"} 124`,
`rapidpro_group_contact_count{group_name="Doctors",group_uuid="c153e265-f7c9-4539-9dbc-9b358714b638",group_type="user",org="UNICEF"} 121`,
`rapidpro_channel_msg_count{channel_name="Nexmo",channel_uuid="19012bfd-3ce3-4cae-9bb9-76cf92c73d49",channel_type="NX",msg_direction="out",msg_type="message",org="UNICEF"} 0`,
},
Expand All @@ -88,6 +89,9 @@ func TestMetrics(t *testing.T) {

body, _ := ioutil.ReadAll(resp.Body)

if tc.Response != "" {
assert.Equal(t, string(body), tc.Response, "%d: response mismatch", i)
}
for _, contains := range tc.Contains {
assert.Contains(t, string(body), contains, "%d does not contain: %s", i, contains)
}
Expand Down
56 changes: 28 additions & 28 deletions web/po/testdata/favorites.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,88 @@ msgstr ""
"Language-3: \n"
"Source-Flows: 9de3663f-c5c5-4c92-9f45-ecbc09abcc85\n"

#: Favorites/e87aeeab-8ede-4173-bc76-8f5583ea7207/name:0
#: Favorites/491f3ed1-9154-4acb-8fdd-0a37567e0574/name:0
msgid "All Responses"
msgstr ""

#: Favorites/34a421ac-34cb-49d8-a2a5-534f52c60851/arguments:0
#: Favorites/c102acfc-8cc5-41fa-89ed-41cbfa362ba6/name:0
#: Favorites/34a421ac-34cb-49d8-a2a5-534f52c60851/name:0
#: Favorites/baf07ebb-8a2a-4e63-aa08-d19aa408cd45/arguments:0
msgid "Blue"
msgstr ""

#: Favorites/3b400f91-db69-42b9-9fe2-24ad556b067a/arguments:0
#: Favorites/8d2e259c-bc3c-464f-8c15-985bc736e212/name:0
#: Favorites/3b400f91-db69-42b9-9fe2-24ad556b067a/name:0
#: Favorites/6e367c0c-65ab-479a-82e3-c597d8e35eef/arguments:0
msgid "Cyan"
msgstr ""

#: Favorites/3e2dcf45-ffc0-4197-b5ab-25ed974ea612/text:0
#: Favorites/7624633a-01a9-48f0-abca-957e7290df0a/text:0
msgid "Good choice, I like @results.color.category_localized too! What is your favorite beer?"
msgstr ""

#: Favorites/58284598-805a-4740-8966-dcb09e3b670a/name:0
#: Favorites/b0c29972-6fd4-485e-83c2-057a3f7a04da/arguments:0
#: Favorites/b0c29972-6fd4-485e-83c2-057a3f7a04da/name:0
#: Favorites/c102acfc-8cc5-41fa-89ed-41cbfa362ba6/arguments:0
msgid "Green"
msgstr ""

#: Favorites/943f85bb-50bc-40c3-8d6f-57dbe34c87f7/text:0
#: Favorites/9631dddf-0dd7-4310-b263-5f7cad4795e0/text:0
msgid "I don't know that color. Try again."
msgstr ""

#: Favorites/4cadf512-1299-468f-85e4-26af9edec193/text:0
#: Favorites/aac779a9-e2a6-4a11-9efa-9670e081a33a/text:0
msgid "I don't know that one, try again please."
msgstr ""

#: Favorites/52d7a9ab-52b7-4e82-ba7f-672fb8d6ec91/text:0
#: Favorites/ada3d96a-a1a2-41eb-aac7-febdb98a9b4c/text:0
msgid "Mmmmm... delicious @results.beer.category_localized. If only they made @(lower(results.color)) @results.beer.category_localized! Lastly, what is your name?"
msgstr ""

#: Favorites/87b850ff-ddc5-4add-8a4f-c395c3a9ac38/name:0
#: Favorites/a813de57-c92a-4128-804d-56e80b332142/arguments:0
#: Favorites/a813de57-c92a-4128-804d-56e80b332142/name:0
#: Favorites/b9d718d3-b5e0-4d26-998e-2da31b24f2f9/arguments:0
msgid "Mutzig"
msgstr ""

#: Favorites/baf07ebb-8a2a-4e63-aa08-d19aa408cd45/arguments:0
#: Favorites/8d2e259c-bc3c-464f-8c15-985bc736e212/arguments:0
msgid "Navy"
msgstr ""

#: Favorites/6e367c0c-65ab-479a-82e3-c597d8e35eef/name:0
#: Favorites/3e2dcf45-ffc0-4197-b5ab-25ed974ea612/name:0
msgid "No Response"
msgstr ""

#: Favorites/c169352e-1944-4451-8d32-eb39c41cb3ae/name:0
#: Favorites/e0ec2076-2746-43b4-a410-c3af47d6a121/name:0
#: Favorites/5563a722-9680-419c-a792-b1fa9df92e06/name:0
#: Favorites/87b850ff-ddc5-4add-8a4f-c395c3a9ac38/name:0
msgid "Other"
msgstr ""

#: Favorites/a03dceb1-7ac1-491d-93ef-23d3e099633b/arguments:0
#: Favorites/b9d718d3-b5e0-4d26-998e-2da31b24f2f9/name:0
#: Favorites/a03dceb1-7ac1-491d-93ef-23d3e099633b/name:0
#: Favorites/f1ca9ac8-d0aa-4758-a969-195be7330267/arguments:0
msgid "Primus"
msgstr ""

#: Favorites/3ffb6f24-2ed8-4fd5-bcc0-b2e2668672a8/arguments:0
#: Favorites/5563a722-9680-419c-a792-b1fa9df92e06/name:0
#: Favorites/3ffb6f24-2ed8-4fd5-bcc0-b2e2668672a8/name:0
#: Favorites/58284598-805a-4740-8966-dcb09e3b670a/arguments:0
msgid "Red"
msgstr ""

#: Favorites/2ba89eb6-6981-4c0d-a19d-3cf1fde52a43/arguments:0
#: Favorites/dbc3b9d2-e6ce-4ebe-9552-8ddce482c1d1/name:0
#: Favorites/2ba89eb6-6981-4c0d-a19d-3cf1fde52a43/name:0
#: Favorites/52d7a9ab-52b7-4e82-ba7f-672fb8d6ec91/arguments:0
msgid "Skol"
msgstr ""

#: Favorites/e92b12c5-1817-468e-aa2f-8791fb6247e9/text:0
#: Favorites/cb6fc9b4-d6e9-4ed3-8a11-3f4d19654a48/text:0
msgid "Sorry you can't participate right now, I'll try again later."
msgstr ""

#: Favorites/491f3ed1-9154-4acb-8fdd-0a37567e0574/text:0
#: Favorites/a602e75e-0814-4034-bb95-770906ddfe34/text:0
msgid "Thanks @results.name, we are all done!"
msgstr ""

#: Favorites/58119801-ed31-4538-888d-23779a01707f/arguments:0
#: Favorites/f1ca9ac8-d0aa-4758-a969-195be7330267/name:0
#: Favorites/58119801-ed31-4538-888d-23779a01707f/name:0
#: Favorites/dbc3b9d2-e6ce-4ebe-9552-8ddce482c1d1/arguments:0
msgid "Turbo King"
msgstr ""

#: Favorites/8c2504ef-0acc-405f-9efe-d5fc2c434a93/text:0
#: Favorites/f4495f19-37ee-4e51-a7d5-d99ef6be147a/text:0
msgid "What is your favorite color?"
msgstr ""

Loading

0 comments on commit de3c263

Please sign in to comment.