Esempio n. 1
0
 def test_instance(self):
     wf_data = json_fixture(response_data={
         "workflow": { "id": "123456" }
     })
     with HTTMock(wf_data):
         wf = WorkflowEndpoint.instance(self.c, 123456)
     self.assertTrue(isinstance(wf, dict))
Esempio n. 2
0
    def test_agent(self):
        ag_data = json_fixture(response_data={
            "agent-state-update": {
                "name": "epiphan01"
            }
        })

        with HTTMock(ag_data):
            agent = CaptureEndpoint.agent(self.c, "epiphan01")
        self.assertTrue(isinstance(agent, dict))
        self.assertEqual(agent['name'], "epiphan01")
Esempio n. 3
0
 def test_service_host(self):
     services_data = json_fixture(response_data={
         'services': {
             'service': [
                 { "type": "foo", "host": "http://foo.example.edu" },
                 { "type": "bar", "host": "http://foo.example.edu" }
             ]
         }
     })
     host = ServiceHost({ 'base_url': 'http://foo.example.edu' }, self.c)
     with HTTMock(services_data):
         self.assertEqual(len(host.services), 2)
         self.assertEqual(host.services[0].type, "foo")
Esempio n. 4
0
 def test_actions(self):
     ua_data = json_fixture(response_data={
         "actions": {
             "action": [
                 {"id": 1},
                 {"id": 2}
             ]
         }
     })
     with HTTMock(ua_data):
         actions = UserTrackingEndpoint.user_actions(self.c)
     self.assertTrue(isinstance(actions, list))
     self.assertTrue(isinstance(actions[0], dict))
Esempio n. 5
0
 def test_instances(self):
     wfs_data = json_fixture(response_data={
         "workflows": {
             "workflow": [
                 { "id": "1" },
                 { "id": "2" },
             ]
         }
     })
     with HTTMock(wfs_data):
         wfs = WorkflowEndpoint.instances(self.c)
     self.assertTrue(isinstance(wfs, list))
     self.assertTrue(isinstance(wfs[0], dict))
Esempio n. 6
0
    def test_services(self):

        stat_data = json_fixture(response_data={
            "services": {
                "service": [
                    { "type": "foo" },
                    { "type": "bar" }
                ]
            }
        })

        with HTTMock(stat_data):
            services = ServicesEndpoint.services(self.c)
            self.assertTrue(isinstance(services, list))
Esempio n. 7
0
    def test_agents(self):
        ag_data = json_fixture(response_data={
            "agents": {
                "agent": [
                    { "name": "ncast01" },
                    { "name": "ewave01" }
                ]
            }
        })

        with HTTMock(ag_data):
            agents = CaptureEndpoint.agents(self.c)
        self.assertTrue(isinstance(agents, list))

        # check that return is still a list even if only one result
        ag_data = json_fixture(response_data={
            "agents": {
                "agent": { "name": "ewave01" }
            }
        })

        with HTTMock(ag_data):
            agents = CaptureEndpoint.agents(self.c)
        self.assertTrue(isinstance(agents, list))
Esempio n. 8
0
    def test_episode_mp_workflow(self):

        wfs_data = json_fixture(response_data={
            "workflows": {
                "workflow": [
                    { "id": "123456" },
                ]
            }
        })
        mp = Mediapackage({"id": "efgh-1234"}, self.c)

        with HTTMock(wfs_data):
            mp_wf = mp.workflow

        self.assertEqual(mp_wf.id, '123456')
Esempio n. 9
0
    def test_components(self):
        comp_data = json_fixture(response_data={
            "ui": [],
            "rest": [
                { "path": "/ingest" },
                { "path": "/mediapackage" },
                { "path": "/workflow" }
            ]
        })

        with HTTMock(comp_data):
            data = InfoEndpoint.components(self.c)
        self.assertTrue(isinstance(data, dict))
        self.assertTrue(isinstance(data['rest'], list))
        self.assertEqual([x['path'] for x in data['rest']], ['/ingest', '/mediapackage', '/workflow'])
Esempio n. 10
0
    def test_statistics(self):

        stat_data = json_fixture(response_data={
            "statistics": {
                "service": [
                    { "queued": "0" },
                    { "queued": "1" }
                ]
            }
        })

        with HTTMock(stat_data):
            stats = ServicesEndpoint.statistics(self.c)
            self.assertTrue(isinstance(stats, dict))
            stats_obj = self.c.statistics()
            self.assertTrue(isinstance(stats_obj, ServiceStatistics))
Esempio n. 11
0
    def test_action_episode(self):

        ep_data = json_fixture(r'/search/', {
            "search-results": {
                "result": [
                    { "id": "abcd-1234" },
                    ]
            }
        })

        ua = UserAction({
            "mediapackageId": "abcd=1234"
        }, self.c)

        with HTTMock(ep_data):
            episode = ua.episode
        self.assertEqual(episode.id, "abcd-1234")
Esempio n. 12
0
    def test_workflow_op_job(self):
        """
        Test that the workflow op correctly fetches its associated job
        """
        job_data = json_fixture(r'/services/job/', {
            "job": {
                "id": "34567"
            }
        })

        op = WorkflowOperation({
            "job": "34567"
        }, self.c)

        with HTTMock(job_data):
            job = op.job
        self.assertEqual(job.id, "34567")
Esempio n. 13
0
    def test_workflow_job(self):
        """
        Test that the workflow correctly fetches its associated job
        """
        job_data = json_fixture(r'/services/job/', {
            "job": {
                "id": "99999"
            }
        })

        wf = Workflow({
            "id": "99999"
        }, self.c)

        with HTTMock(job_data):
            job = wf.job
        self.assertEqual(job.id, "99999")
Esempio n. 14
0
    def test_episodes(self):
        ep_data = json_fixture(response_data={
            "search-results": {
                "result": [
                    { "id": "abcd-1234" },
                    { "id": "efgh-1234" }
                ]
            }
        })
        with HTTMock(ep_data):
            episodes = EpisodeEndpoint.episodes(self.c)
        self.assertEqual(len(episodes), 2)

        # both the plural and singular epidsode methods use the same endpoint,
        # the singular just sends back result[0]
        with HTTMock(ep_data):
            episode = EpisodeEndpoint.episode(self.c, 'abcd-1234')
        self.assertTrue(isinstance(episode, dict))
Esempio n. 15
0
    def test_workflow_episode(self):
        """
        Test that the workflow correctly fetches its associated episode
        """
        ep_data = json_fixture(r'/episode/', {
            "search-results": {
                "result": [
                    { "id": "abcd-1234" },
                ]
            }
        })

        wf = Workflow({
            "mediapackage": {
                "id": "abcd-1234",
            }
        }, self.c)

        with HTTMock(ep_data):
            episode = wf.episode
        self.assertEqual(episode.id, "abcd-1234")