Beispiel #1
0
def test_pull_exists_replace(mock_api, mock_tmp_dir, create_test_file,
                             mock_input, project_response,
                             page_search_paginated, language_response,
                             page_details_response, lang_ru):
    mock_input.side_effect = (2, )

    mock_api.get_languages.return_value = language_response
    mock_api.get_project.return_value = project_response
    mock_api.page_search.return_value = page_search_paginated
    mock_api.get_page_details.return_value = page_details_response
    mock_api.download_file.return_value.raw = StringIO(b'test')

    pull_command(mock_tmp_dir, {}, languages=('ru-ru', ))

    mock_api.get_project.assert_called_once()

    mock_api.page_search.assert_called_once()
    mock_api.page_search.assert_called_with(lang_ru.id,
                                            status=[
                                                PageStatus.completed,
                                            ])

    mock_api.get_page_details.assert_called_once()
    mock_api.get_page_details.assert_called_with(lang_ru.id,
                                                 page_details_response['id'])

    mock_api.download_file.assert_called_once()
    mock_api.download_file.assert_called_with(page_details_response['id'],
                                              lang_ru.id,
                                              milestone=None)

    assert os.path.exists(os.path.join(mock_tmp_dir, 'ru-ru.json'))
Beispiel #2
0
 def main(self):
     config = self.load_settings()
     languages = []
     files = []
     if isinstance(self.languages, (list, tuple, set)):
         languages.extend(self.languages)
     if isinstance(self.files, (list, tuple, set)):
         files.extend(self.files)
     pull_command(self._curdir,
                  config,
                  languages=set(itertools.chain(*languages)),
                  in_progress=self.in_progress,
                  update_action=self.get_update_action(),
                  force=self.force,
                  bulk=self.bulk,
                  files=set(itertools.chain(*files)))
Beispiel #3
0
    def main(self):
        log.info('Loading Qordoba config...')
        config = self.load_settings()
        languages = []
        if isinstance(self.languages, (list, tuple, set)):
            languages.extend(self.languages)

        pull_command(self._curdir,
                     config,
                     files=self.files,
                     languages=set(itertools.chain(*languages)),
                     in_progress=self.in_progress,
                     update_action=self.get_update_action(),
                     force=self.force,
                     custom=self.custom,
                     bulk=self.bulk,
                     version=self.version,
                     workflow=self.workflow,
                     workflow_all=self.workflow_all,
                     distinct=self.distinct)