예제 #1
0
    def test_actual_set_params(self):
        channel = "1"
        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        response = epi.set_params(channel=channel, params={"publish_type": os.environ["EPI_PUBLISH_TYPE"]})
        response.should.be.ok
예제 #2
0
    def test_actual_get_params(self):
        channel = "1"
        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        response = epi.get_params(channel=channel, params={"publish_type": ""})

        response["publish_type"].should_not.be.different_of(os.environ["EPI_PUBLISH_TYPE"])
예제 #3
0
    def test_live_set_channel_layout(self):
        channel_id = "1"
        layout = '{"video":[{"type":"source","position":{"left":"0%","top":"0%","width":"100%","height":"100%","keep_aspect_ratio":true},"settings":{"source":"D2P280762.sdi-b"}}],"audio":[{"type":"source","settings":{"source":"D2P280762.analog-b"}}],"background":"#000000","nosignal":{"id":"default"}}'

        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        for channel_id in ["1", "2", "3", "4"]:
            response = epi.set_channel_layout(channel_id=channel_id, layout=layout, layout_id="1")

            assert response is not None
            r = json.loads(response)
            assert r["result"]["settings"] == json.loads(layout)
예제 #4
0
 def setup(self):
     p = CaptureAgent('ABCD1111', 'fake1.example.edu')
     p.channels['live']['channel'] = '1'
     p.channels['live']['publish_type'] = '0'
     p.channels['lowBR']['channel'] = '2'
     p.channels['lowBR']['publish_type'] = '0'
     p.client = Epipearl(epiphan_url, 'user', 'passwd')
     self.ca = p
예제 #5
0
class TestWebUiConfig(object):

    def setup_method(self, method):
        self.c = Epipearl(epiphan_url, epiphan_user, epiphan_passwd)


    @httpretty.activate
    def test_set_ntp_ok(self):
        resp_data = resp_datafile('set_date_and_time', 'ok')
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/timesynccfg' % epiphan_url,
                body=resp_data)
        response = self.c.set_ntp(
                server='north-america.pool.ntp.org',
                timezone='US/Alaska')
        assert response


    @httpretty.activate
    def test_set_ntp_invalid_tz(self):
        resp_data = resp_datafile('set_date_and_time', 'invalid_tz')
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/timesynccfg' % epiphan_url,
                body=resp_data)

        with pytest.raises(SettingConfigError) as e:
            self.c.set_ntp(
                    server='north-america.pool.ntp.org',
                    timezone='xuxu')
        assert 'Unsupported time zone' in e.value.message


    @httpretty.activate
    def test_set_ntp_server_did_not_take(self):
        resp_data = resp_datafile('set_date_and_time', 'ok')
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/timesynccfg' % epiphan_url,
                body=resp_data)

        with pytest.raises(SettingConfigError) as e:
            self.c.set_ntp(server='google.com', timezone='US/Alaska')
        assert 'expected ntp server(google.com)' in e.value.message


    @httpretty.activate
    def test_set_ntp_server_error(self):
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/timesynccfg' % epiphan_url,
                body='does not matter',
                status=501)

        with pytest.raises(requests.HTTPError) as e:
            self.c.set_ntp(server='google.com', timezone='US/Alaska')
        assert 'Server Error' in e.value.message
예제 #6
0
def set_epipearl_client(ca):
    ca.client = Epipearl('http://%s' % ca.address,
                         current_app.config['EPIPEARL_USER'],
                         current_app.config['EPIPEARL_PASSWD'])
    ca.sync_live_status()
예제 #7
0
 def setup(self):
     self.c = Epipearl(epiphan_url, epiphan_user, epiphan_passwd)
예제 #8
0
class TestEpipearl(object):
    def setup(self):
        self.c = Epipearl(epiphan_url, epiphan_user, epiphan_passwd)

    @httpretty.activate
    def test_livestream_active(self):
        channel = "1"

        httpretty.register_uri(
            httpretty.GET, "%s/admin/channel%s/get_params.cgi" % (epiphan_url, channel), body="publish_type = 6"
        )

        response = self.c.get_params(channel=channel, params={"publish_type": ""})
        response["publish_type"].should_not.be.different_of("6")

    @httpretty.activate
    def test_get_multi_params(self):
        channel = "m1"

        httpretty.register_uri(
            httpretty.GET,
            "%s/admin/channel%s/get_params.cgi" % (epiphan_url, channel),
            body="""\
publish_type = 6
videosource = D2P280084.sdi-a:0x0/50x100;D2P280084.sdi-b:50x0/50x100
streamport = 8000
product_name = Matterhorn
vendor = Epiphan Systems Inc.""",
        )

        response = self.c.get_params(
            channel=channel,
            params={"publish_type": "", "videosource": "", "streamport": "", "product_name": "", "vendor": ""},
        )

        response["publish_type"].should_not.be.different_of("6")
        response["streamport"].should_not.be.different_of("8000")
        response["product_name"].should_not.be.different_of("Matterhorn")
        response["vendor"].should_not.be.different_of("Epiphan Systems Inc.")

    @httpretty.activate
    def test_set_multi_params(self):
        channel = "m1"

        httpretty.register_uri(
            httpretty.GET, "%s/admin/channel%s/set_params.cgi" % (epiphan_url, channel), body="", status=201
        )

        response = self.c.set_params(
            channel=channel,
            params={
                "publish_type": "0",
                "streamport": "8000",
                "product_name": "Matterhorn",
                "vendor": "Epiphan Systems Inc.",
            },
        )
        assert response

    @httpretty.activate
    def test_get_infocfg_ok(self):
        resp_data = resp_datafile("get_infocfg", "ok", "html")
        httpretty.register_uri(httpretty.GET, "%s/admin/infocfg" % epiphan_url, body=resp_data, status=200)

        response = self.c.get_infocfg()
        infocfg = {
            "channels": [
                {"id": "1", "name": "dce_pr"},
                {"id": "2", "name": "dce_live_lowbr"},
                {"id": "3", "name": "dce_live"},
                {"id": "4", "name": "dce_pn"},
            ],
            "recorders": [{"id": "1", "name": "dce_prpn"}],
            "sources": [
                {"id": "D2P280762.hdmi-a", "name": "HDMI-A"},
                {"id": "D2P280762.hdmi-b", "name": "HDMI-B"},
                {"id": "D2P280762.sdi-a", "name": "SDI-A"},
                {"id": "D2P280762.sdi-b", "name": "SDI-B"},
                {"id": "D2P280762.vga-a", "name": "VGA-A"},
                {"id": "D2P280762.vga-b", "name": "VGA-B"},
                {"id": "D2P280762.analog-a", "name": "Analog-A Audio"},
                {"id": "D2P280762.analog-b", "name": "Analog-B Audio"},
                {"id": "D2P280762.hdmi-a-audio", "name": "HDMI-A Audio"},
                {"id": "D2P280762.hdmi-b-audio", "name": "HDMI-B Audio"},
                {"id": "D2P280762.sdi-a-audio", "name": "SDI-A Audio"},
                {"id": "D2P280762.sdi-b-audio", "name": "SDI-B Audio"},
            ],
        }
        assert response == infocfg

    @livetest
    def test_actual_set_params(self):
        channel = "1"
        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        response = epi.set_params(channel=channel, params={"publish_type": os.environ["EPI_PUBLISH_TYPE"]})
        response.should.be.ok

    @livetest
    def test_actual_get_params(self):
        channel = "1"
        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        response = epi.get_params(channel=channel, params={"publish_type": ""})

        response["publish_type"].should_not.be.different_of(os.environ["EPI_PUBLISH_TYPE"])

    @livetest
    def test_live_set_channel_layout(self):
        channel_id = "1"
        layout = '{"video":[{"type":"source","position":{"left":"0%","top":"0%","width":"100%","height":"100%","keep_aspect_ratio":true},"settings":{"source":"D2P280762.sdi-b"}}],"audio":[{"type":"source","settings":{"source":"D2P280762.analog-b"}}],"background":"#000000","nosignal":{"id":"default"}}'

        ca_url = os.environ["EPI_URL"]
        epi = Epipearl(ca_url, os.environ["EPI_USER"], os.environ["EPI_PASSWD"])

        for channel_id in ["1", "2", "3", "4"]:
            response = epi.set_channel_layout(channel_id=channel_id, layout=layout, layout_id="1")

            assert response is not None
            r = json.loads(response)
            assert r["result"]["settings"] == json.loads(layout)
예제 #9
0
class TestEpipearl(object):

    def setup(self):
        self.c = Epipearl(epiphan_url, epiphan_user, epiphan_passwd)


    @httpretty.activate
    def test_create_channel_ok(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_channel.cgi' % epiphan_url,
                status=302,
                location='/admin/channel57/mediasources')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/channel57/mediasources' % epiphan_url, status=200)
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/ajax/rename_channel.cgi' % epiphan_url,
                status=200)

        response = self.c.create_channel('channel_blah')
        assert response == '57'


    @httpretty.activate
    def test_create_channel_failed_create(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_channel.cgi' % epiphan_url,
                status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.create_channel('channel_blah')
        assert '500 Server Error' in e.value.message


    @httpretty.activate
    def test_create_channel_failed_rename(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_channel.cgi' % epiphan_url,
                status=302,
                location='/admin/channel57/mediasources')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/channel57/mediasources' % epiphan_url, status=200)
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/ajax/rename_channel.cgi' % epiphan_url,
                status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.create_channel('channel_blah')
        assert '500 Server Error' in e.value.message


    @httpretty.activate
    def test_set_channel_layout_ok(self):
        layout = '{"video":[{"type":"source","position":{"left":"0%","top":"0%","width":"100%","height":"100%","keep_aspect_ratio":true},"settings":{"source":"D2P280762.hdmi-b"}}],"audio":[{"type":"source","settings":{"source":"D2P280762.sdi-a"}}],"background":"#000000","nosignal":{"id":"default"}}'
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/channel57/layouts/1' % epiphan_url,
                body=layout, status=200)

        response = self.c.set_channel_layout(channel_id=57, layout=layout)
        assert response


    @httpretty.activate
    def test_set_channel_layout_error500(self):
        layout = '{"video":[{"type":"source","position":{"left":"0%","top":"0%","width":"100%","height":"100%","keep_aspect_ratio":true},"settings":{"source":"D2P280762.hdmi-b"}}],"audio":[{"type":"source","settings":{"source":"D2P280762.sdi-a"}}],"background":"#000000","nosignal":{"id":"default"}}'
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/channel57/layouts/1' % epiphan_url,
                body=layout, status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.set_channel_layout(channel_id=57, layout=layout)
        assert '500 Server Error' in e.value.message


    @httpretty.activate
    def test_create_recorder_ok(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_recorder.cgi' % epiphan_url,
                status=302,
                location='/admin/recorder57/archive')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/recorder57/archive' % epiphan_url, status=200)
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/ajax/rename_channel.cgi' % epiphan_url,
                status=200)
        response = self.c.create_recorder(recorder_name='recorder_xablau')
        assert response == '57'


    @httpretty.activate
    def test_create_recorder_failed_create(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_recorder.cgi' % epiphan_url,
                status=502,
                location='/admin/recorder57/archive')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/recorder57/archive' % epiphan_url, status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.create_recorder(recorder_name='recorder_xablau')
        assert '502 Server Error' in e.value.message


    @httpretty.activate
    def test_create_recorder_failed_rename(self):
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/add_recorder.cgi' % epiphan_url,
                status=302,
                location='/admin/recorder57/archive')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/recorder57/archive' % epiphan_url, status=200)
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/ajax/rename_channel.cgi' % epiphan_url,
                status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.create_recorder(recorder_name='recorder_xablau')
        assert '500 Server Error' in e.value.message


    @httpretty.activate
    def test_set_recorder_channels_ok(self):
        resp_data = resp_datafile('set_recorder_channels', 'ok')
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/recorder57/archive' % epiphan_url,
                body=resp_data,
                status=200)
        response = self.c.set_recorder_channels(
                recorder_id='57',
                channel_list=['3', '2'])
        assert response
        assert httpretty.last_request().parsed_body['rc[]'] == ['3', '2']

    @httpretty.activate
    def test_set_recorder_channels_error500(self):
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/recorder57/archive' % epiphan_url,
                status=500)

        with pytest.raises(requests.HTTPError) as e:
            response = self.c.set_recorder_channels(
                    recorder_id='57',
                    channel_list=['3', '2'])
        assert '500 Server Error' in e.value.message


    @httpretty.activate
    def test_delete_channel_or_recorder_by_name_ok(self):
        resp_data = resp_datafile(
                'get_infocfg', 'ok', ext='html')
        httpretty.register_uri(
                httpretty.GET,
                '%s/admin/infocfg' % epiphan_url,
                body=resp_data,
                status=200)
        resp_data = resp_datafile('delete_channel', 'ok')
        httpretty.register_uri(
                httpretty.POST,
                '%s/admin/channel39/status' % epiphan_url,
                body=resp_data,
                status=200)
        response = self.c.delete_channel_or_recorder_by_name('channel_blah')
        assert response is True
예제 #10
0
 def setup_method(self, method):
     self.c = Epipearl(epiphan_url, epiphan_user, epiphan_passwd)