예제 #1
0
    def _test_import_file(self, args, DatasetImportCreate, DatasetCreate,
                          ObjectCreate, ObjectAll, VaultAll, VaultLookup,
                          UploadPath):
        DatasetImportCreate.side_effect = fake_dataset_import_create
        DatasetCreate.side_effect = fake_dataset_create
        ObjectAll.side_effect = fake_object_all
        ObjectCreate.side_effect = fake_object_create
        VaultAll.side_effect = fake_vault_all
        UploadPath.side_effect = upload_path
        VaultLookup.side_effect = fake_vault_create

        main.main(args)
예제 #2
0
    def _test_upload_command(self, args, ObjectUpload, ObjectCreate, ObjectAll,
                             VaultAll, VaultLookup, RetrieveHelper, **kwargs):

        ObjectUpload.side_effect = fake_object_create
        ObjectAll.side_effect = fake_object_all
        ObjectCreate.side_effect = fake_object_create
        VaultAll.side_effect = fake_vault_all
        VaultLookup.side_effect = fake_vault_create

        if 'fail_lookup' in kwargs:
            RetrieveHelper.side_effect = raise_not_found
        else:
            RetrieveHelper.side_effect = fake_object_retrieve

        main.main(args)
예제 #3
0
 def _test_create_dataset(self, args, TmplRetrieve, TmplCreate,
                          DatasetCreate, ObjectAll, VaultAll):
     TmplRetrieve.side_effect = fake_dataset_tmpl_retrieve
     TmplCreate.side_effect = fake_dataset_tmpl_create
     DatasetCreate.side_effect = fake_dataset_get_or_create
     ObjectAll.side_effect = fake_object_all
     VaultAll.side_effect = fake_vault_all
     return main.main(args)
예제 #4
0
 def test_create_dataset(self, DatasetCreate, ObjectAll, VaultAll):
     DatasetCreate.side_effect = fake_dataset_create
     ObjectAll.side_effect = fake_object_all
     VaultAll.side_effect = fake_vault_all
     args = ['create-dataset', 'solvebio:test_vault:/test-dataset',
             '--capacity', 'small']
     ds = main.main(args)
     self.assertEqual(ds.name, 'test-dataset')
     self.assertEqual(ds.path, '/test-dataset')
예제 #5
0
    def _test_download_file(self, args, Download, ObjectAll,
                            download_success=True):
        ObjectAll.side_effect = fake_object_all

        if download_success:
            Download.side_effect = lambda x: True
        else:
            Download.side_effect = Exception('Mock Download Fail')

        # returns (imports_list, dataset)
        return main.main(args)
예제 #6
0
 def test_create_dataset(self, DatasetCreate, ObjectAll, VaultAll):
     DatasetCreate.side_effect = fake_dataset_create
     ObjectAll.side_effect = fake_object_all
     VaultAll.side_effect = fake_vault_all
     args = [
         'create-dataset', 'solvebio:test_vault:/test-dataset',
         '--capacity', 'small'
     ]
     ds = main.main(args)
     self.assertEqual(ds.name, 'test-dataset')
     self.assertEqual(ds.path, '/test-dataset')
예제 #7
0
    def _test_import_file(self, args, DatasetImportCreate, DatasetCreate,
                          ObjectCreate, ObjectAll, VaultAll, VaultLookup,
                          UploadPath, TmplCreate, TmplRetrieve):
        DatasetImportCreate.side_effect = fake_dataset_import_create
        DatasetCreate.side_effect = fake_dataset_create
        ObjectAll.side_effect = fake_object_all
        ObjectCreate.side_effect = fake_object_create
        VaultAll.side_effect = fake_vault_all
        UploadPath.side_effect = upload_path
        VaultLookup.side_effect = fake_vault_create
        TmplRetrieve.side_effect = fake_dataset_tmpl_retrieve
        TmplCreate.side_effect = fake_dataset_tmpl_create

        # returns (imports_list, dataset)
        return main.main(args)
예제 #8
0
    def test_create_dataset_upload_template(self, TmplCreate, DatasetCreate,
                                            ObjectAll, VaultAll):
        TmplCreate.side_effect = fake_dataset_tmpl_create
        DatasetCreate.side_effect = fake_dataset_create
        ObjectAll.side_effect = fake_object_all
        VaultAll.side_effect = fake_vault_all

        template_path = os.path.join(os.path.dirname(__file__),
                                     "data/template.json")
        args = [
            'create-dataset', 'solvebio:test_vault:/test-dataset',
            '--template-file', template_path, '--capacity', 'medium'
        ]  # noqa

        ds = main.main(args)
        self.assertEqual(ds.description, 'Created with dataset template: 100')
예제 #9
0
    def test_create_dataset_upload_template(self, TmplCreate,
                                            DatasetCreate, ObjectAll,
                                            VaultAll):
        TmplCreate.side_effect = fake_dataset_tmpl_create
        DatasetCreate.side_effect = fake_dataset_create
        ObjectAll.side_effect = fake_object_all
        VaultAll.side_effect = fake_vault_all

        template_path = os.path.join(os.path.dirname(__file__),
                                     "data/template.json")
        args = ['create-dataset', 'solvebio:test_vault:/test-dataset',
                   '--template-file', template_path,
                   '--capacity', 'medium']  # noqa

        ds = main.main(args)
        self.assertEqual(ds.description,
                         'Created with dataset template: 100')
예제 #10
0
    def test_create_dataset_template_id(self, TmplRetrieve, DatasetCreate,
                                        ObjectAll, VaultAll):
        VaultAll.side_effect = fake_vault_all
        ObjectAll.side_effect = fake_object_all
        DatasetCreate.side_effect = fake_dataset_create
        TmplRetrieve.side_effect = fake_dataset_tmpl_retrieve

        # create template
        template_path = os.path.join(os.path.dirname(__file__),
                                     "data/template.json")
        with open(template_path, 'r') as fp:
            tpl_json = json.load(fp)

        tpl = DatasetTemplate.create(**tpl_json)
        args = ['create-dataset', 'solvebio:test_vault:/test-dataset',
                   '--template-id', str(tpl.id),
                   '--capacity', 'small']  # noqa

        ds = main.main(args)
        self.assertEqual(ds.description,
                         'Created with dataset template: {0}'.format(tpl.id))
예제 #11
0
 def test_create_dataset_by_filename(self, DatasetCreate, ObjectAll,
                                     VaultAll):
     DatasetCreate.side_effect = fake_dataset_create
     ObjectAll.side_effect = fake_object_all
     VaultAll.side_effect = fake_vault_all
     args = [
         'create-dataset',
         'solvebio:test_vault:/test-dataset-filename',
         '--capacity',
         'small',
         '--tag',
         'tag_test',
         '--metadata',
         'TEST=tag',
         '--metadata',
         'TEST2=tag2',
     ]
     ds = main.main(args)
     self.assertEqual(ds.name, 'test-dataset-filename')
     self.assertEqual(ds.path, '/test-dataset-filename')
     self.assertEqual(ds.capacity, 'small')
     self.assertEqual(ds.tags, ['tag_test'])
     self.assertEqual(ds.metadata, dict(TEST='tag', TEST2='tag2'))
예제 #12
0
    def test_create_dataset_template_id(self, TmplCreate, TmplRetrieve,
                                        DatasetCreate, ObjectAll, VaultAll):
        VaultAll.side_effect = fake_vault_all
        ObjectAll.side_effect = fake_object_all
        DatasetCreate.side_effect = fake_dataset_create
        TmplRetrieve.side_effect = fake_dataset_tmpl_retrieve
        TmplCreate.side_effect = fake_dataset_tmpl_create

        # create template
        template_path = os.path.join(os.path.dirname(__file__),
                                     "data/template.json")
        with open(template_path, 'r') as fp:
            tpl_json = json.load(fp)

        tpl = DatasetTemplate.create(**tpl_json)
        args = [
            'create-dataset', 'solvebio:test_vault:/test-dataset',
            '--template-id',
            str(tpl.id), '--capacity', 'small'
        ]  # noqa

        ds = main.main(args)
        self.assertEqual(ds.description,
                         'Created with dataset template: {0}'.format(tpl.id))
예제 #13
0
 def test_show_queue(self):
     """Simple test to print the queue"""
     main.main(['queue'])