1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
# |
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
# |
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
# limitations under the License. |
15
|
|
|
|
16
|
|
|
import mock |
17
|
|
|
import pecan |
18
|
|
|
|
19
|
|
|
from st2stream.controllers.v1 import stream |
20
|
|
|
from st2stream import listener |
21
|
|
|
from base import FunctionalTest |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
@mock.patch.object(pecan, 'request', type('request', (object,), {'environ': {}})) |
25
|
|
|
@mock.patch.object(pecan, 'response', mock.MagicMock()) |
26
|
|
|
class TestStreamController(FunctionalTest): |
27
|
|
|
|
28
|
|
|
@mock.patch.object(stream, 'format', mock.Mock()) |
29
|
|
|
@mock.patch.object(listener, 'get_listener', mock.Mock()) |
30
|
|
|
def test_get_all(self): |
31
|
|
|
resp = stream.StreamController().get_all() |
32
|
|
|
self.assertIsInstance(resp._app_iter, mock.Mock) |
33
|
|
|
self.assertEqual(resp._status, '200 OK') |
34
|
|
|
self.assertIn(('Content-Type', 'text/event-stream; charset=UTF-8'), resp._headerlist) |
35
|
|
|
|