Example #1
0
 def test_upload_file(self):
     with tempfile.TemporaryDirectory() as tmp_dir:
         uploader = file_uploader.LocalFileUploader(tmp_dir)
         src = os.path.join(os.getcwd(),
                            'test/data/COVIDTracking_States.csv')
         uploader.upload_file(src, 'foo/bar/data.csv')
         self.assertTrue(
             utils.compare_lines(src,
                                 os.path.join(tmp_dir, 'foo/bar/data.csv'),
                                 integration_test.NUM_LINES_TO_CHECK))
Example #2
0
def main(_):
    """Runs the local executor."""
    config = configs.ExecutorConfig(
        github_repo_name=FLAGS.repo_name,
        github_repo_owner_username=FLAGS.owner_username,
        github_auth_username=FLAGS.username,
        github_auth_access_token=FLAGS.access_token)
    executor = import_executor.ImportExecutor(
        uploader=file_uploader.LocalFileUploader(output_dir=FLAGS.output_dir),
        github=github_api.GitHubRepoAPI(config.github_repo_owner_username,
                                        config.github_repo_name),
        config=config)
    results = executor.execute_imports_on_update(FLAGS.import_name)
    print(results)
Example #3
0
 def test_invalid_string_args(self):
     uploader = file_uploader.LocalFileUploader()
     self.assertRaises(ValueError, uploader.upload_file, 'src', '')
     self.assertRaises(ValueError, uploader.upload_file, '   ', 'dest')
     self.assertRaises(ValueError, uploader.upload_string, 'string', '')
Example #4
0
 def test_upload_string(self):
     with tempfile.TemporaryDirectory() as tmp_dir:
         uploader = file_uploader.LocalFileUploader(tmp_dir)
         uploader.upload_string('12345', 'foo/bar/file')
         with open(os.path.join(tmp_dir, 'foo/bar/file')) as file:
             self.assertEqual('12345', file.read())