• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Experiment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tardis.tardis_portal.models.Experiment的典型用法代码示例。如果您正苦于以下问题:Python Experiment类的具体用法?Python Experiment怎么用?Python Experiment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Experiment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        # Create test owner without enough details
        username, email, password = ("testuser", "[email protected]", "password")
        user = User.objects.create_user(username, email, password)
        # Need UserAuthentication
        UserAuthentication(userProfile=user.userprofile, username=username, authenticationMethod="localdb").save()
        # Create staging dir
        from os import path, makedirs

        staging_dir = path.join(settings.STAGING_PATH, username)
        if not path.exists(staging_dir):
            makedirs(staging_dir)
        # Ensure that staging dir is set up properly
        expect(get_full_staging_path(username)).to_be_truthy()

        # Create test experiment and make user the owner of it
        experiment = Experiment(title="Text Experiment", institution_name="Test Uni", created_by=user)
        experiment.save()
        acl = ObjectACL(
            pluginId=django_user,
            entityId=str(user.id),
            content_object=experiment,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED,
        )
        acl.save()

        self.dataset = Dataset(description="dataset description...")
        self.dataset.save()
        self.dataset.experiments.add(experiment)
        self.dataset.save()

        self.username, self.password = (username, password)
开发者ID:grischa,项目名称:mytardis,代码行数:34,代码来源:test_views.py


示例2: testRightsRequireValidOwner

    def testRightsRequireValidOwner(self):
        # Create test owner without enough details
        username, email, password = ("testuser", "[email protected]", "password")
        user = User.objects.create_user(username, email, password)

        # Create test experiment and make user the owner of it
        experiment = Experiment(title="Text Experiment", institution_name="Test Uni", created_by=user)
        experiment.save()
        acl = ObjectACL(
            pluginId=django_user,
            entityId=str(user.id),
            content_object=experiment,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED,
        )
        acl.save()

        # Create client and login as user
        client = Client()
        login = client.login(username=username, password=password)
        self.assertTrue(login)

        # Get "Choose Rights" page, and check that we're forbidden
        rights_url = reverse("tardis.tardis_portal.views.choose_rights", args=[str(experiment.id)])
        response = client.get(rights_url)
        expect(response.status_code).to_equal(403)

        # Fill in remaining details
        user.first_name = "Voltaire"  # Mononymous persons are just fine
        user.save()

        # Get "Choose Rights" page, and check that we're now allowed access
        response = client.get(rights_url)
        expect(response.status_code).to_equal(200)
开发者ID:grischa,项目名称:mytardis,代码行数:35,代码来源:test_views.py


示例3: _create_test_data

def _create_test_data():
    user = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user.save()
    user2 = User(username='otheradmin', email='[email protected]')
    user2.save()
    map(lambda u: UserProfile(user=u).save(), [user, user2])
    license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    acl = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user2.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl.save()
    return (user, experiment)
开发者ID:conkiztador,项目名称:mytardis,代码行数:30,代码来源:test_oai.py


示例4: IntegrityCheckTestCase

class IntegrityCheckTestCase(TestCase):
    def _make_dataset(self, exp, filenames):
        dataset = Dataset(experiment=exp)
        dataset.save()
        for filename in filenames:
            df = Dataset_File(dataset=dataset, size=41, protocol='file')
            df.filename = filename
            df.url = 'file://' + path.join(path.dirname(__file__), 'data', df.filename)
            df.save()

    def setUp(self):
        self.user = User(username='user1', password='password', email='[email protected]')
        self.user.save()
        self.bad_exp = Experiment(
                approved = True,
                title = 'title1',
                institution_name = 'institution1',
                description = 'description1',
                created_by = self.user,
                public_access = Experiment.PUBLIC_ACCESS_FULL
                )
        self.bad_exp.save()
        self.bad_dataset = self._make_dataset(self.bad_exp, [
            'file_that_exists',
            'file_that_exists_too',
            'file_that_exists_but_is_empty',
            'file_that_doesnt_exist',
            ])

        self.good_exp = Experiment(
                approved = True,
                title = 'title1',
                institution_name = 'institution1',
                description = 'description1',
                created_by = self.user,
                public_access = Experiment.PUBLIC_ACCESS_FULL
                )
        self.good_exp.save()
        self.good_dataset = self._make_dataset(self.good_exp, [
            'file_that_exists',
            'file_that_exists_too'
            ])

    def testBadExperimentFails(self):
        result = IntegrityCheck(self.bad_exp).get_datafiles_integrity()
        self.assertEqual(result['files_ok'], 2)
        self.assertEqual(result['files_incomplete'], 1)
        self.assertEqual(result['files_missing'], 1)

        good_or_bad = IntegrityCheck(self.bad_exp).all_files_complete()
        self.assertFalse(good_or_bad)

    def testGoodExperimentPasses(self):
        result = IntegrityCheck(self.good_exp).get_datafiles_integrity()
        self.assertEqual(result['files_ok'], 2)
        self.assertEqual(result['files_incomplete'], 0)
        self.assertEqual(result['files_missing'], 0)

        good_or_bad = IntegrityCheck(self.good_exp).all_files_complete()
        self.assertTrue(good_or_bad)
开发者ID:conkiztador,项目名称:mytardis,代码行数:60,代码来源:test_integrity.py


示例5: setUp

    def setUp(self):
        self.user = User(username='user1', password='password', email='[email protected]')
        self.user.save()
        self.bad_exp = Experiment(
                approved = True,
                title = 'title1',
                institution_name = 'institution1',
                description = 'description1',
                created_by = self.user,
                public_access = Experiment.PUBLIC_ACCESS_FULL
                )
        self.bad_exp.save()
        self.bad_dataset = self._make_dataset(self.bad_exp, [
            'file_that_exists',
            'file_that_exists_too',
            'file_that_exists_but_is_empty',
            'file_that_doesnt_exist',
            ])

        self.good_exp = Experiment(
                approved = True,
                title = 'title1',
                institution_name = 'institution1',
                description = 'description1',
                created_by = self.user,
                public_access = Experiment.PUBLIC_ACCESS_FULL
                )
        self.good_exp.save()
        self.good_dataset = self._make_dataset(self.good_exp, [
            'file_that_exists',
            'file_that_exists_too'
            ])
开发者ID:JMSS-IT-11-2012,项目名称:mytardis,代码行数:32,代码来源:test_integrity.py


示例6: setUp

 def setUp(self):
     self.client = Client()
     # old_user
     user_old_username = 'tardis_user1'
     # new_user
     user_new_username = 'tardis_user2'
     pwd = 'secret'
     email = '[email protected]'
     self.user_new = User.objects.create_user(user_new_username, email, pwd)
     self.user_old = User.objects.create_user(user_old_username, email, pwd)
     # create group
     self.group = Group.objects.create(name='test group')
     # add old user to group
     self.group.user_set.add(self.user_old)
     # add user auth
     user_auth = UserAuthentication(userProfile=UserProfile.objects.get(user=self.user_old),
                        username= self.user_old.username,
                        authenticationMethod='localdb')
     user_auth.save()
     # add experiments
     experiment = Experiment(title='Text Experiment',
                             institution_name='Test Uni',
                             created_by=self.user_old)
     experiment.save()
     acl = ObjectACL(
         pluginId='django_user',
         entityId=str(self.user_old.id),
         content_object=experiment,
         canRead=True,
         isOwner=True,
         aclOwnershipType=ObjectACL.OWNER_OWNED,
     )
     acl.save()
开发者ID:mytardis,项目名称:mytardis,代码行数:33,代码来源:test_migration.py


示例7: setUp

    def setUp(self):
        # create a test user
        self.user = User.objects.create_user(username='DownloadTestUser',
                                             email='',
                                             password='secret')

        # create a public experiment
        self.experiment1 = Experiment(
            title='Experiment 1',
            created_by=self.user,
            public_access=Experiment.PUBLIC_ACCESS_FULL)
        self.experiment1.save()

        # create a non-public experiment
        self.experiment2 = Experiment(
            title='Experiment 2',
            created_by=self.user,
            public_access=Experiment.PUBLIC_ACCESS_NONE)
        self.experiment2.save()

        # dataset1 belongs to experiment1
        self.dataset1 = Dataset()
        self.dataset1.save()
        self.dataset1.experiments.add(self.experiment1)
        self.dataset1.save()

        # dataset2 belongs to experiment2
        self.dataset2 = Dataset()
        self.dataset2.save()
        self.dataset2.experiments.add(self.experiment2)
        self.dataset2.save()

        # absolute path first
        filename1 = 'testfile.txt'
        filename2 = 'testfile.tiff'
        self.dest1 = abspath(join(settings.FILE_STORE_PATH, '%s/%s/'
                                  % (self.experiment1.id,
                                     self.dataset1.id)))
        self.dest2 = abspath(join(settings.FILE_STORE_PATH,
                                  '%s/%s/'
                                  % (self.experiment2.id,
                                     self.dataset2.id)))
        if not exists(self.dest1):
            makedirs(self.dest1)
        if not exists(self.dest2):
            makedirs(self.dest2)

        testfile1 = abspath(join(self.dest1, filename1))
        f = open(testfile1, 'w')
        f.write("Hello World!\n")
        f.close()

        testfile2 = abspath(join(self.dest2, filename2))
        _generate_test_image(testfile2)

        self.datafile1 = self._build_datafile(testfile1, filename1,
                                              self.dataset1)

        self.datafile2 = self._build_datafile(testfile2, filename2,
                                              self.dataset2)
开发者ID:jasonrig,项目名称:mytardis,代码行数:60,代码来源:test_download.py


示例8: _create_test_experiment

def _create_test_experiment(user, license_):
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    experiment.experimentauthor_set.create(
        order=0,
        author="John Cleese",
        url="http://nla.gov.au/nla.party-1")
    experiment.experimentauthor_set.create(
        order=1,
        author="Michael Palin",
        url="http://nla.gov.au/nla.party-2")
    acl = ObjectACL(content_object=experiment,
                    pluginId='django_user',
                    entityId=str(user.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ObjectACL.OWNER_OWNED)
    acl.save()
    return experiment
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:25,代码来源:test_rmexperiment.py


示例9: MRtaskTestCase

class MRtaskTestCase(TestCase):

    def setUp(self):
        from django.contrib.auth.models import User
        from tardis.tardis_portal.models import Experiment
        from tardis.tardis_portal.models import ExperimentACL
        from tardis.tardis_portal.models import Dataset
        from tardis.apps.mrtardis.mrtask import MRtask
        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)
        self.experiment = Experiment(approved=True,
                                     title="Test Experiment",
                                     institution_name="Test Institution",
                                     created_by=self.user,
                                     public=False)
        self.experiment.save()
        acl = ExperimentACL(pluginId="django_user",
                            entityId="1",
                            experiment=self.experiment,
                            canRead=True,
                            canWrite=True,
                            canDelete=True,
                            isOwner=True)
        acl.save()
        self.test_dataset = Dataset(experiment=self.experiment,
                                    description="test dataset")
        self.test_dataset.save()
        self.test_mrtask = MRtask(dataset=self.test_dataset)

    def test_mrtask(self):
        self.assertEqual(len(self.test_mrtask.parameters), 0)
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:33,代码来源:tests.py


示例10: _get_experiment

 def _get_experiment(self, entry, user):
     experimentId, title, public_access = \
         self._get_experiment_details(entry, user)
     try:
         try:
             param_name = ParameterName.objects.\
                 get(name=self.PARAM_EXPERIMENT_ID, \
                     schema=AtomImportSchemas.get_schema(Schema.EXPERIMENT))
             parameter = ExperimentParameter.objects.\
                 get(name=param_name, string_value=experimentId)
         except ExperimentParameter.DoesNotExist:
             raise Experiment.DoesNotExist
         return parameter.parameterset.experiment
     except Experiment.DoesNotExist:
         experiment = Experiment(title=title,
                                 created_by=user,
                                 public_access=public_access)
         experiment.save()
         self._create_experiment_id_parameter_set(experiment, experimentId)
         acl = ObjectACL(content_object=experiment,
                 pluginId=django_user,
                 entityId=user.id,
                 canRead=True,
                 canWrite=True,
                 canDelete=True,
                 isOwner=True,
                 aclOwnershipType=ObjectACL.OWNER_OWNED)
         acl.save()
         return experiment
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-atom,代码行数:29,代码来源:atom_ingest.py


示例11: _create_test_data

def _create_test_data():
    user = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user.save()
    license_ = License(name='Creative Commons Attribution-NoDerivs 2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    experiment.experimentauthor_set.create(order=0,
                                           author="John Cleese",
                                           url="http://nla.gov.au/nla.party-1")
    experiment.experimentauthor_set.create(order=1,
                                           author="Michael Palin",
                                           url="http://nla.gov.au/nla.party-2")
    acl = ObjectACL(content_object=experiment,
                    pluginId='django_user',
                    entityId=str(user.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ObjectACL.OWNER_OWNED)
    acl.save()
    return user, experiment
开发者ID:mytardis,项目名称:mytardis,代码行数:33,代码来源:test_oai.py


示例12: setUp

    def setUp(self):
        # Create test owner without enough details
        username, email, password = ('testuser',
                                     '[email protected]',
                                     'password')
        user = User.objects.create_user(username, email, password)
        profile = UserProfile(user=user, isDjangoAccount=True)
        profile.save()

        Location.force_initialize()

        # Create test experiment and make user the owner of it
        experiment = Experiment(title='Text Experiment',
                                institution_name='Test Uni',
                                created_by=user)
        experiment.save()
        acl = ObjectACL(
            pluginId='django_user',
            entityId=str(user.id),
            content_object=experiment,
            canRead=True,
            canWrite=True,
            canDelete=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED)
        acl.save()

        dataset = Dataset(description='dataset description...')
        dataset.save()
        dataset.experiments.add(experiment)
        dataset.save()

        def create_datafile(filename):
            testfile = path.join(path.dirname(__file__), 'fixtures',
                                 filename)

            size, sha512sum = get_size_and_sha512sum(testfile)

            datafile = Dataset_File(dataset=dataset,
                                    filename=path.basename(testfile),
                                    size=size,
                                    sha512sum=sha512sum)
            datafile.save()
            base_url = 'file://' + path.abspath(path.dirname(testfile))
            location = Location.load_location({
                'name': 'test-grabber', 'url': base_url, 'type': 'external',
                'priority': 10, 'transfer_provider': 'local'})
            replica = Replica(datafile=datafile,
                              url='file://'+path.abspath(testfile),
                              protocol='file',
                              location=location)
            replica.verify()
            replica.save()
            return Dataset_File.objects.get(pk=datafile.pk)

        self.dataset = dataset
        self.datafiles = [create_datafile('data_grabber_test1.admin'),
                          create_datafile('testfile.txt')
                         ] 
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-datagrabber,代码行数:59,代码来源:test_datagrabber.py


示例13: createhpcexperiment

def createhpcexperiment(request, user, dl):

    from django.contrib.auth.models import User
    from tardis.tardis_portal.views import _registerExperimentDocument
    import os
    import tempfile

    # TODO
    temp = tempfile.TemporaryFile()
    for chunk in dl.chunks():
        temp.write(chunk)
    temp.seek(0)

    metadata = {}

    for line in temp:
        key, value = line.split("~")
        metadata[key] = value
    temp.close()

    author = metadata["Name"]
    title = metadata["Experiment"]
    ds_desc = metadata["Facility"]
    desc = metadata["Description"]
    fname = metadata["FolderName"]
    counter = metadata["Counter"]
    package = metadata["Package"]

    exp = Experiment(
        title=title, institution_name="RMIT University", description=desc, created_by=User.objects.get(id=user.pk)
    )
    exp.save()
    eid = exp.id
    # Store the author for the dataset
    ae = models.Author_Experiment(experiment=exp, author=author, order="1")
    ae.save()

    auth_key = settings.DEFAULT_AUTH

    try:
        e = Experiment.objects.get(pk=eid)
    except Experiment.DoesNotExist:
        logger.exception("Experiment for eid %i in CreateHPCExperiment does not exist" % eid)

    acl = ExperimentACL(
        experiment=e,
        pluginId=django_user,
        entityId=str(user.id),
        canRead=True,
        canWrite=True,
        canDelete=True,
        isOwner=True,
        aclOwnershipType=ExperimentACL.OWNER_OWNED,
    )
    acl.save()

    folder_desc = "%s.%s.%s.%s" % (ds_desc.strip(), package.strip(), fname.strip(), counter.strip())
    logger.debug("folder_desc = %s" % folder_desc)
    return eid, exp, folder_desc
开发者ID:aaryani,项目名称:CoreTardis,代码行数:59,代码来源:views.py


示例14: TarDownloadTestCase

class TarDownloadTestCase(TestCase):
    def setUp(self):
        # create user
        self.testuser = User(username="testuser")
        self.testuser.save()

        # create test experiment
        self.exp = Experiment(
            title="tar download test" * 15, created_by=self.testuser, public_access=Experiment.PUBLIC_ACCESS_FULL
        )
        self.exp.save()

        # create test dataset
        self.ds = self.exp.datasets.create(description="testing tar download dataset")

        datafile_content = "\n".join(["some data %d" % i for i in range(1000)])
        filesize = len(datafile_content)
        md5sum = hashlib.md5(datafile_content).hexdigest()
        # create test datafiles and datafile objects
        self.dfs = []
        for i in range(20):
            df = self.ds.datafile_set.create(
                filename="testfile%d.txt" % i,
                mimetype="text/plain",
                size=filesize,
                md5sum=md5sum,
                directory="/".join(["testdir%d" % i for i in range(i, i + 4)]),
            )
            df.file_object = StringIO(datafile_content)
            df.refresh_from_db()
            self.dfs.append(df)

        # mock client
        self.client = Client()

    def tearDown(self):
        # delete created objects and files

        [ds.delete() for ds in self.exp.datasets.all()]
        self.exp.delete()

    def test_tar_experiment_download(self):
        self.assertTrue(all(df.verified for df in self.dfs))
        response = self.client.get(
            reverse("tardis.tardis_portal.download.streaming_download_experiment", args=(self.exp.id, "tar"))
        )
        with NamedTemporaryFile("w") as tarfile:
            for c in response.streaming_content:
                tarfile.write(c)
            tarfile.flush()
            self.assertEqual(int(response["Content-Length"]), os.stat(tarfile.name).st_size)
            tf = TarFile(tarfile.name)
            for df in self.dfs:
                full_path = os.path.join(
                    self.exp.title.replace(" ", "_"), self.ds.description, df.directory, df.filename
                )
                tf.extract(full_path, "/tmp")
                self.assertEqual(os.stat(os.path.join("/tmp", full_path)).st_size, int(df.size))
开发者ID:jasonrig,项目名称:mytardis,代码行数:58,代码来源:test_tar_download.py


示例15: _create_test_data

def _create_test_data():
    """
    Create Single experiment with two owners
    """
    user1 = User(username='tom',
                first_name='Thomas',
                last_name='Atkins',
                email='[email protected]')
    user1.save()
    UserProfile(user=user1).save()

    user2 = User(username='joe',
                first_name='Joe',
                last_name='Bloggs',
                email='[email protected]')
    user2.save()
    UserProfile(user=user2).save()

    license_ = License(name='Creative Commons Attribution-NoDerivs '
                            + '2.5 Australia',
                       url='http://creativecommons.org/licenses/by-nd/2.5/au/',
                       internal_description='CC BY 2.5 AU',
                       allows_distribution=True)
    license_.save()
    experiment = Experiment(title='Norwegian Blue',
                            description='Parrot + 40kV',
                            created_by=user1)
    experiment.public_access = Experiment.PUBLIC_ACCESS_FULL
    experiment.license = license_
    experiment.save()
    experiment.author_experiment_set.create(order=0,
                                        author="John Cleese",
                                        url="http://nla.gov.au/nla.party-1")
    experiment.author_experiment_set.create(order=1,
                                        author="Michael Palin",
                                        url="http://nla.gov.au/nla.party-2")

    acl1 = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user1.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl1.save()

    acl2 = ExperimentACL(experiment=experiment,
                    pluginId='django_user',
                    entityId=str(user2.id),
                    isOwner=True,
                    canRead=True,
                    canWrite=True,
                    canDelete=True,
                    aclOwnershipType=ExperimentACL.OWNER_OWNED)
    acl2.save()

    return (user1, user2, experiment)
开发者ID:ianedwardthomas,项目名称:mytardis-app-repos-consumer,代码行数:58,代码来源:test_ingest.py


示例16: setUp

    def setUp(self):
        # create a test user
        self.user = User.objects.create_user(username='DownloadTestUser',
                                             email='',
                                             password='secret')

        # create a public experiment
        self.experiment1 = Experiment(title='Experiment 1',
                                      created_by=self.user,
                                      public=True)
        self.experiment1.save()

        # create a non-public experiment
        self.experiment2 = Experiment(title='Experiment 2',
                                      created_by=self.user,
                                      public=False)
        self.experiment2.save()

        # dataset1 belongs to experiment1
        self.dataset1 = Dataset(experiment=self.experiment1)
        self.dataset1.save()

        # dataset2 belongs to experiment2
        self.dataset2 = Dataset(experiment=self.experiment2)
        self.dataset2.save()

        # absolute path first
        filename = 'testfile.txt'
        self.dest1 = abspath(join(settings.FILE_STORE_PATH, '%s'
                                  % self.experiment1.id))
        self.dest2 = abspath(join(settings.FILE_STORE_PATH, '%s'
                                  % self.experiment2.id))
        if not exists(self.dest1):
            mkdir(self.dest1)
        if not exists(self.dest2):
            mkdir(self.dest2)

        testfile1 = abspath(join(self.dest1, filename))
        f = open(testfile1, 'w')
        f.write("Hello World!\n")
        f.close()

        testfile2 = abspath(join(self.dest2, filename))
        f = open(testfile2, 'w')
        f.write("Hello World!\n")
        f.close()

        self.dataset_file1 = Dataset_File(dataset=self.dataset1,
                                          filename=filename,
                                          protocol='tardis',
                                          url='tardis://%s' % filename)
        self.dataset_file1.save()

        self.dataset_file2 = Dataset_File(dataset=self.dataset2,
                                          filename=basename(filename),
                                          protocol='tardis',
                                          url='tardis://%s' % filename)
        self.dataset_file2.save()
开发者ID:grischa,项目名称:mytardis-mrtardis,代码行数:58,代码来源:test_download.py


示例17: testNeverExpire

    def testNeverExpire(self):
        experiment = Experiment(created_by=self.user, end_time=dt.datetime(1999,4,3))
        experiment.save()

        eh = EmbargoHandler(experiment.id, True)
        self.assertFalse(eh.never_expires())

        eh.prevent_expiry()
        self.assertTrue(eh.never_expires())
        self.assertFalse(eh.because_no_end_date())
开发者ID:ANSTO,项目名称:mecat-ansto,代码行数:10,代码来源:test_embargo.py


示例18: setUp

    def setUp(self):
        raise SkipTest  # temporarily disabling this feature, needs coding
        from tempfile import mkdtemp, mktemp
        from django.conf import settings
        import os

        # Disconnect post_save signal
        from django.db.models.signals import post_save
        from tardis.tardis_portal.models import Experiment, \
            staging_hook, Dataset, DataFile, DataFileObject, StorageBox
        post_save.disconnect(staging_hook, sender=DataFileObject)

        from django.contrib.auth.models import User
        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)

        try:
            os.makedirs(settings.GET_FULL_STAGING_PATH_TEST)
        except OSError:
            pass
        self.temp = mkdtemp(dir=settings.GET_FULL_STAGING_PATH_TEST)

        self.filepath = mktemp(dir=self.temp)
        content = 'test file'
        with open(self.filepath, "w+b") as f:
            f.write(content)

        # make datafile
        exp = Experiment(title='test exp1',
                         institution_name='monash',
                         created_by=self.user)
        exp.save()

        # make dataset
        dataset = Dataset(description="dataset description...")
        dataset.save()
        dataset.experiments.add(exp)
        dataset.save()

        # create datafile
        df = DataFile(dataset=dataset, size=len(content),
                      filename=path.basename(self.file),
                      md5sum='f20d9f2072bbeb6691c0f9c5099b01f3')
        df.save()

        # create replica
        base_url = settings.GET_FULL_STAGING_PATH_TEST
        s_box = StorageBox.get_default_storage(location=base_url)
        dfo = DataFileObject(datafile=df,
                             uri=self.filepath,
                             storage_box=s_box)
        dfo.save()
        self.dfo = dfo
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:55,代码来源:test_staging.py


示例19: create_draft_publication

def create_draft_publication(user, publication_title, publication_description):
    # Note: Maybe this logic can be taken from the tardis_portal/views.py?

    experiment = Experiment(created_by=user,
                            title=publication_title,
                            description=publication_description)
    experiment.save()

    ObjectACL(content_object=experiment,
              pluginId=django_user,
              entityId=str(user.id),
              canRead=True,
              canWrite=False,
              canDelete=False,
              isOwner=True,
              aclOwnershipType=ObjectACL.OWNER_OWNED).save()

    ObjectACL(content_object=experiment,
              pluginId=django_group,
              entityId=str(
                  Group.objects.get_or_create(
                      name=getattr(
                          settings, 'PUBLICATION_OWNER_GROUP',
                          default_settings.PUBLICATION_OWNER_GROUP))[0].id),
              canRead=True,
              canWrite=True,
              canDelete=True,
              isOwner=True,
              aclOwnershipType=ObjectACL.OWNER_OWNED).save()

    publication_schema = Schema.objects.get(
        namespace=getattr(settings, 'PUBLICATION_SCHEMA_ROOT',
                          default_settings.PUBLICATION_SCHEMA_ROOT))

    # Attach draft schema
    draft_publication_schema = Schema.objects.get(
        namespace=getattr(settings, 'PUBLICATION_DRAFT_SCHEMA',
                          default_settings.PUBLICATION_DRAFT_SCHEMA))
    ExperimentParameterSet(schema=draft_publication_schema,
                           experiment=experiment).save()

    # Attach root schema and blank form_state parameter
    publication_root_schema = Schema.objects.get(
        namespace=getattr(settings, 'PUBLICATION_SCHEMA_ROOT',
                          default_settings.PUBLICATION_SCHEMA_ROOT))
    publication_root_parameter_set = ExperimentParameterSet(
        schema=publication_schema,
        experiment=experiment)
    publication_root_parameter_set.save()
    form_state_param_name = ParameterName.objects.get(
        schema=publication_root_schema, name='form_state')
    ExperimentParameter(name=form_state_param_name,
                        parameterset=publication_root_parameter_set).save()

    return experiment
开发者ID:keithschulze,项目名称:mytardis,代码行数:55,代码来源:views.py


示例20: setUp

    def setUp(self):
        # Create test owner without enough details
        username, email, password = ('testuser',
                                     '[email protected]',
                                     'password')
        user = User.objects.create_user(username, email, password)

        # Create test experiment and make user the owner of it
        experiment = Experiment(title='Text Experiment',
                                institution_name='Test Uni',
                                created_by=user)
        experiment.save()
        acl = ObjectACL(
            pluginId='django_user',
            entityId=str(user.id),
            content_object=experiment,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED,
        )
        acl.save()

        dataset = Dataset(description='dataset description...')
        dataset.save()
        dataset.experiments.add(experiment)
        dataset.save()

        base_path = path.join(path.dirname(__file__), 'fixtures')
        s_box = StorageBox.get_default_storage(location=base_path)

        def create_datafile(index):
            testfile = path.join(base_path, 'middleware_test%d.txt' % index)

            size, sha512sum = get_size_and_sha512sum(testfile)

            datafile = DataFile(dataset=dataset,
                                filename=path.basename(testfile),
                                size=size,
                                sha512sum=sha512sum)
            datafile.save()
            dfo = DataFileObject(
                datafile=datafile,
                storage_box=s_box,
                uri=path.basename(testfile))
            dfo.save()

            if index != 1:
                dfo.verified = False
                dfo.save(update_fields=['verified'])
            return DataFile.objects.get(pk=datafile.pk)

        self.dataset = dataset
        self.datafiles = [create_datafile(i) for i in (1, 2)]
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:53,代码来源:test_middleware.py



注:本文中的tardis.tardis_portal.models.Experiment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.ExperimentACL类代码示例发布时间:2022-05-27
下一篇:
Python models.Dataset_File类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap