-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_11_ves.py
More file actions
98 lines (73 loc) · 2.77 KB
/
test_11_ves.py
File metadata and controls
98 lines (73 loc) · 2.77 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
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020 Nokia
import pytest
import logging
import os
import requests
from onapsdk.configuration import settings
from onapsdk.utils.jinja import jinja_env
from onapsdk.ves.ves import Ves
from onapsdk.dmaap.dmaap import Dmaap
logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"))
def reset_dmaap_mock():
requests.get("{}/reset".format(settings.DMAAP_URL))
@pytest.mark.integration
def test_should_send_event_to_ves():
# given
requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
event: str = jinja_env().get_template("ves_stnd_event.json.j2").render()
# when
response = Ves.send_event(
basic_auth={'username': 'sample1', 'password': 'sample1'},
json_event=event,
version="v7"
)
# then
assert response.status_code == 202
@pytest.mark.integration
def test_should_send_batch_event_to_ves():
# given
requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
event: str = jinja_env().get_template("ves7_batch_with_stndDefined_valid.json.j2").render()
# when
response = Ves.send_batch_event(
basic_auth={'username': 'sample1', 'password': 'sample1'},
json_event=event,
version="v7"
)
# then
assert response.status_code == 202
@pytest.mark.integration
def test_should_send_event_to_ves_and_dmaap():
# given
requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
event: str = jinja_env().get_template("ves_stnd_event.json.j2").render()
# when
reset_dmaap_mock()
response = Ves.send_event(
basic_auth={'username': 'sample1', 'password': 'sample1'},
json_event=event,
version="v7"
)
# then
assert response.status_code == 202
events = Dmaap.get_events_for_topic("fault",
basic_auth={'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'})
assert len(events) == 1
@pytest.mark.integration
def test_should_send_batch_event_to_ves_and_dmaap():
# given
requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
event: str = jinja_env().get_template("ves7_batch_with_stndDefined_valid.json.j2").render()
# when
reset_dmaap_mock()
response = Ves.send_batch_event(
basic_auth={'username': 'sample1', 'password': 'sample1'},
json_event=event,
version="v7"
)
# then
assert response.status_code == 202
events = Dmaap.get_events_for_topic("fault",
basic_auth={'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'})
assert len(events) == 2