Ejemplo n.º 1
0
    def test_update_changeset_running(self):
        """
        Verifies that changeset publish status is updated based on the dataflow api.
        """
        OrgChangeset(id='test', publish_job_running=True).put()

        response = self.app.get('/orchestrator/update_changesets')
        self.assertEqual(response.status_code, 204)

        # changeset has been marked as completed
        changeset = OrgChangeset.get_by_id('test')
        self.assertFalse(changeset.publish_job_finished)
        self.assertTrue(changeset.publish_job_running)
        self.assertFalse(changeset.publish_job_failed)
        self.assertEqual(changeset.publish_job_status, 'JOB_STATE_RUNNING')
Ejemplo n.º 2
0
    def test_create_publish_job_task(self, dataflow_mock, publish_mock):
        """
        Verifies that the correct changesets are being published.

        Args:
            dataflow_mock(Mock): mock for kicking off dataflow publish job
            publish_mock(Mock): mock of the changeset publish function
        """
        dataflow_mock.return_value = {'id': 'job_1'}

        OrgChangeset(
            id='test0',
            org_uid='test0',
            changeset=0,
            publish_job_running=False,
            publish_job_count=0
        ).put()

        response = self.app.post(
            '/orchestrator/create_publish_job_task',
            data=json.dumps({
                'job_params': {
                    'org_changeset_ids': ['test0']
                }
            })
        )
        self.assertEqual(response.status_code, 204)

        job_params = {"orgChangesets": "test0:0"}
        dataflow_mock.assert_called_once()
        dataflow_mock.assert_called_once_with('sync', ANY, job_params)

        # fields for published org are updated
        changeset = OrgChangeset.get_by_id('test0')
        self.assertTrue(changeset.publish_job_running)
        self.assertFalse(changeset.publish_job_finished)
        self.assertFalse(changeset.publish_job_failed)
        self.assertEqual(changeset.publish_job_id, "job_1")
        self.assertIsNone(changeset.publish_job_status)
        self.assertEqual(changeset.publish_job_count, 1)

        # and changeset status is published
        publish_mock.assert_called_once_with('test0', 0, 'syncing')
Ejemplo n.º 3
0
    def test_update_changeset_failure(self, publish_mock):
        """
        Verifies that changeset publish status is updated based on the dataflow api.

        Args:
            publish_mock(Mock): mock of the changeset publish function
        """
        OrgChangeset(id='test', org_uid='test', changeset=0, publish_job_running=True).put()

        response = self.app.get('/orchestrator/update_changesets')
        self.assertEqual(response.status_code, 204)

        # changeset has been marked as completed
        changeset = OrgChangeset.get_by_id('test')
        self.assertTrue(changeset.publish_job_finished)
        self.assertFalse(changeset.publish_job_running)
        self.assertTrue(changeset.publish_job_failed)
        self.assertEqual(changeset.publish_job_status, 'JOB_STATE_FAILED')

        # and changeset status is published
        publish_mock.assert_called_once_with('test', 0, 'error')