Skip to content

Commit fc91c10

Browse files
authored
Fix notes tests and minor API fixes (#213)
1 parent 0091033 commit fc91c10

6 files changed

Lines changed: 22 additions & 10 deletions

File tree

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ lint: $(PYLINT) $(MYPY) $(BLACK)
6868
hooks: $(PRE_COMMIT)
6969
$(PRE_COMMIT) run -a
7070

71-
## test - Run unit tests.
72-
test: $(TOX) $(PYTEST)
71+
## test.unit - Run unit tests.
72+
test.unit: $(TOX) $(PYTEST)
7373
$(TOX) $(toxparams)
7474

75+
## test.integration - Run integration tests.
76+
test.integration: $(TOX) $(PYTEST)
77+
docker-compose -f docker-compose.ci.yaml build sut
78+
docker-compose -f docker-compose.ci.yaml up --exit-code-from sut
79+
docker-compose -f docker-compose.ci.yaml rm --stop --force
80+
7581
## run - Run application.
7682
run:
7783
alertad

alertaclient/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def get_tags(self, query=None):
144144
r = self.http.get('/alerts/tags', query)
145145
return r['tags']
146146

147-
def alert_note(self, id, note):
147+
def alert_note(self, id, text):
148148
data = {
149-
'note': note
149+
'text': text
150150
}
151151
return self.http.put('/alert/%s/note' % id, data)
152152

alertaclient/commands/cmd_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def cli(obj, ids, alert_ids, query, filters, text, delete):
2929

3030
with click.progressbar(alert_ids, label='Add note to {} alerts'.format(total)) as bar:
3131
for id in bar:
32-
client.alert_note(id, note=text)
32+
client.alert_note(id, text=text)

docker-compose.ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
depends_on:
99
- db
1010
environment:
11-
- DEBUG=1 # remove this line to turn DEBUG off
11+
# - DEBUG=1 # remove this line to turn DEBUG off
1212
- DATABASE_URL=postgres://postgres:postgres@db:5432/monitoring
1313
- AUTH_REQUIRED=True
1414
- ADMIN_USERS=admin@alerta.io,devops@alerta.io #default password: alerta
@@ -21,6 +21,8 @@ services:
2121

2222
db:
2323
image: postgres:9.6
24+
volumes:
25+
- /var/lib/postgresql/data
2426
environment:
2527
- POSTGRES_DB=monitoring
2628
- POSTGRES_USER=postgres

tests/integration/test_sdk.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ def test_key(self):
5858
self.assertEqual(api_key.user, 'johndoe@example.com')
5959
self.assertEqual(sorted(api_key.scopes), sorted(['write:alerts', 'admin:keys']))
6060

61-
# def test_note(self):
62-
# n = self.client.alert_note(id='e7020428-5dad-4a41-9bfe-78e9d55cda06', note='this is a test note')
63-
# self.assertEqual(n.text, 'this is a test note')
61+
def test_note(self):
62+
id, alert, message = self.client.send_alert(
63+
environment='Production', resource='web02', event='node_down', correlated=['node_up', 'node_down'],
64+
service=['Web', 'App'], severity='critical', tags=['london', 'linux'], value=4
65+
)
66+
n = self.client.alert_note(id, text='this is a test note')
67+
self.assertEqual(n.text, 'this is a test note')
6468

6569
def test_permission(self):
6670
perm = self.client.create_perm(role='websys', scopes=['admin:users', 'admin:keys', 'write'])

tests/unit/test_notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def setUp(self):
1919
@requests_mock.mock()
2020
def test_add_note(self, m):
2121
m.put('http://localhost:8080/alert/e7020428-5dad-4a41-9bfe-78e9d55cda06/note', text=self.note)
22-
r = self.client.alert_note(id='e7020428-5dad-4a41-9bfe-78e9d55cda06', note='this is a test note')
22+
r = self.client.alert_note(id='e7020428-5dad-4a41-9bfe-78e9d55cda06', text='this is a test note')
2323
self.assertEqual(r['status'], 'ok')

0 commit comments

Comments
 (0)