|
14 | 14 | from json import dumps |
15 | 15 | import pandas as pd |
16 | 16 | from shutil import rmtree |
17 | | -from pathlib import Path |
18 | 17 |
|
19 | 18 | from qiita_client.qiita_client import (QiitaClient, _format_payload, |
20 | 19 | ArtifactInfo) |
@@ -528,29 +527,29 @@ def test_delete_file_from_central(self): |
528 | 527 | self.assertTrue(exists(fp_deleted)) |
529 | 528 |
|
530 | 529 | def test_fetch_directory(self): |
531 | | - # creating a test directory |
532 | | - fp_test = join('./job', '2_test_folder', 'source') |
533 | | - self._create_test_dir(prefix=fp_test) |
534 | | - |
535 | | - # transmitting test directory into qiita main |
536 | | - self.tester._plugincoupling = 'https' |
537 | | - self.tester.push_file_to_central(fp_test) |
538 | 530 | # a bit hacky, but should work as long as test database does not change |
539 | 531 | ainfo = self.qclient.get('/qiita_db/artifacts/1/') |
540 | 532 | base_data_dir = ainfo['files']['raw_forward_seqs'][0]['filepath'][ |
541 | 533 | :(-1 * len('raw_data/1_s_G1_L001_sequences.fastq.gz'))] |
542 | | - fp_main = join(base_data_dir, join(*Path(fp_test).parts)) |
543 | 534 |
|
544 | | - # fetch test directory from qiita main, this time storing it at |
545 | | - # QIITA_BASE_DIR |
| 535 | + # creating a LOCAL test directory within base_data_dir as the DB entry |
| 536 | + # but no files exist. "job" is the according mountpoint |
| 537 | + fp_test = join(base_data_dir, 'job', '2_test_folder') |
| 538 | + self._create_test_dir(prefix=fp_test) |
| 539 | + |
| 540 | + # transmitting test directory to qiita main (remote) |
| 541 | + self.tester._plugincoupling = 'https' |
| 542 | + self.tester.push_file_to_central(fp_test) |
| 543 | + # fp_main = join(base_data_dir, join(*Path(fp_test).parts)) |
| 544 | + |
| 545 | + # fetch test directory from qiita main to a different location |
| 546 | + # (=prefix) than it was generated |
546 | 547 | prefix = join(expanduser("~"), 'localFetch') |
547 | | - fp_obs = self.tester.fetch_file_from_central( |
548 | | - dirname(fp_main), prefix=prefix) |
| 548 | + fp_obs = self.tester.fetch_file_from_central(fp_test, prefix=prefix) |
549 | 549 |
|
550 | 550 | # test a file of the freshly transferred directory from main has |
551 | 551 | # expected file content |
552 | | - with open(join(fp_obs, 'job/2_test_folder/job/2_test_folder/', |
553 | | - 'source', 'testdir', 'fileA.txt'), 'r') as f: |
| 552 | + with open(join(fp_obs, 'testdir', 'fileA.txt'), 'r') as f: |
554 | 553 | self.assertIn('contentA', '\n'.join(f.readlines())) |
555 | 554 |
|
556 | 555 |
|
|
0 commit comments