def test_handle_bq_export_task_state(self, mock_export, mock_project_id):
        """Tests that the export is called for a given table and module when
        the /export_manager/export endpoint is hit for a table in the STATE
        module."""
        mock_export.return_value = True
        self.mock_export_config.STATE_BASE_TABLES_BQ_DATASET.return_value = 'state'

        mock_project_id.return_value = 'test-project'
        self.mock_client.dataset_ref_for_id.return_value = \
            DatasetReference.from_string('dataset', 'test-project')

        table = 'fake_table'
        module = 'STATE'
        route = '/export'
        data = {"table_name": table, "schema_type": module}

        response = self.mock_flask_client.post(
            route,
            data=json.dumps(data),
            content_type='application/json',
            headers={'X-Appengine-Inbound-Appid': 'test-project'})
        assert response.status_code == HTTPStatus.OK
        mock_export.assert_called_with(
            self.mock_client, table,
            DatasetReference.from_string('dataset', 'test-project'),
            SchemaType.STATE)
    def test_handle_bq_export_task_county(self, mock_export, mock_project_id):
        """Tests that the export is called for a given table and module when
        the /export_manager/export endpoint is hit for a table in the COUNTY
        module."""
        mock_export.return_value = True

        mock_project_id.return_value = 'test-project'
        self.mock_client.dataset_ref_for_id.return_value = DatasetReference(
            mock_project_id.return_value, self.mock_dataset_name)
        table = 'fake_table'
        module = 'JAILS'
        route = '/export'
        data = {"table_name": table, "schema_type": module}

        response = self.mock_flask_client.post(
            route,
            data=json.dumps(data),
            content_type='application/json',
            headers={'X-Appengine-Inbound-Appid': 'test-project'})
        assert response.status_code == HTTPStatus.OK
        mock_export.assert_called_with(
            self.mock_client, table,
            DatasetReference.from_string(self.mock_dataset_name,
                                         mock_project_id.return_value),
            SchemaType.JAILS)