コード例 #1
0
ファイル: test_api.py プロジェクト: UWA-FoS/trudat
class MyTardisResourceTestCase(ResourceTestCase):
    '''
    abstract class without tests to combine common settings in one place
    '''
    def setUp(self):
        super(MyTardisResourceTestCase, self).setUp()
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(username=self.username,
                                             password=self.password)
        test_auth_service = AuthService()
        test_auth_service._set_user_from_dict(self.user,
                                              user_dict={
                                                  'first_name': 'Testing',
                                                  'last_name': 'MyTardis API',
                                                  'email':
                                                  '*****@*****.**'
                                              },
                                              auth_method="None")
        self.user.user_permissions.add(
            Permission.objects.get(codename='change_dataset'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='add_datafile'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='add_instrument'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='change_instrument'))
        self.user_profile = self.user.userprofile
        self.testgroup = Group(name="Test Group")
        self.testgroup.save()
        self.testgroup.user_set.add(self.user)
        self.testfacility = Facility(name="Test Facility",
                                     manager_group=self.testgroup)
        self.testfacility.save()
        self.testinstrument = Instrument(name="Test Instrument",
                                         facility=self.testfacility)
        self.testinstrument.save()
        self.testexp = Experiment(title="test exp")
        self.testexp.approved = True
        self.testexp.created_by = self.user
        self.testexp.locked = False
        self.testexp.save()
        testacl = ObjectACL(content_type=self.testexp.get_ct(),
                            object_id=self.testexp.id,
                            pluginId=django_user,
                            entityId=str(self.user.id),
                            canRead=True,
                            canWrite=True,
                            canDelete=True,
                            isOwner=True,
                            aclOwnershipType=ObjectACL.OWNER_OWNED)
        testacl.save()

    def get_credentials(self):
        return self.create_basic(username=self.username,
                                 password=self.password)

    def get_apikey_credentials(self):
        return self.create_apikey(username=self.username,
                                  api_key=self.user.api_key.key)
コード例 #2
0
ファイル: test_api.py プロジェクト: tjdett/mytardis
 def setUp(self):
     super(MyTardisResourceTestCase, self).setUp()
     self.username = '******'
     self.password = '******'
     self.user = User.objects.create_user(username=self.username,
                                          password=self.password)
     test_auth_service = AuthService()
     test_auth_service._set_user_from_dict(self.user,
                                           user_dict={
                                               'first_name': 'Testing',
                                               'last_name': 'MyTardis API',
                                               'email':
                                               '*****@*****.**'
                                           },
                                           auth_method="None")
     self.user.user_permissions.add(
         Permission.objects.get(codename='change_dataset'))
     self.user.user_permissions.add(
         Permission.objects.get(codename='add_dataset_file'))
     self.user_profile = UserProfile(user=self.user).save()
     self.testexp = Experiment(title="test exp")
     self.testexp.approved = True
     self.testexp.created_by = self.user
     self.testexp.locked = False
     self.testexp.save()
     testacl = ObjectACL(content_type=self.testexp.get_ct(),
                         object_id=self.testexp.id,
                         pluginId=django_user,
                         entityId=str(self.user.id),
                         canRead=True,
                         canWrite=True,
                         canDelete=True,
                         isOwner=True,
                         aclOwnershipType=ObjectACL.OWNER_OWNED)
     testacl.save()
コード例 #3
0
ファイル: test_api.py プロジェクト: jasonrig/mytardis
class MyTardisResourceTestCase(ResourceTestCase):
    '''
    abstract class without tests to combine common settings in one place
    '''
    def setUp(self):
        super(MyTardisResourceTestCase, self).setUp()
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(username=self.username,
                                             password=self.password)
        test_auth_service = AuthService()
        test_auth_service._set_user_from_dict(
            self.user,
            user_dict={'first_name': 'Testing',
                       'last_name': 'MyTardis API',
                       'email': '*****@*****.**'},
            auth_method="None")
        self.user.user_permissions.add(
            Permission.objects.get(codename='change_dataset'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='add_datafile'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='add_instrument'))
        self.user.user_permissions.add(
            Permission.objects.get(codename='change_instrument'))
        self.user_profile = self.user.userprofile
        self.testgroup = Group(name="Test Group")
        self.testgroup.save()
        self.testgroup.user_set.add(self.user)
        self.testfacility = Facility(name="Test Facility",
                                     manager_group=self.testgroup)
        self.testfacility.save()
        self.testinstrument = Instrument(name="Test Instrument",
                                         facility=self.testfacility)
        self.testinstrument.save()
        self.testexp = Experiment(title="test exp")
        self.testexp.approved = True
        self.testexp.created_by = self.user
        self.testexp.locked = False
        self.testexp.save()
        testacl = ObjectACL(
            content_type=self.testexp.get_ct(),
            object_id=self.testexp.id,
            pluginId=django_user,
            entityId=str(self.user.id),
            canRead=True,
            canWrite=True,
            canDelete=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED)
        testacl.save()

    def get_credentials(self):
        return self.create_basic(username=self.username,
                                 password=self.password)

    def get_apikey_credentials(self):
        return self.create_apikey(username=self.username,
                                  api_key=self.user.api_key.key)
コード例 #4
0
ファイル: test_api.py プロジェクト: TheGoodRob/mytardis
 def setUp(self):
     super(MyTardisResourceTestCase, self).setUp()
     self.username = '******'
     self.password = '******'
     self.user = User.objects.create_user(username=self.username,
                                          password=self.password)
     test_auth_service = AuthService()
     test_auth_service._set_user_from_dict(
         self.user,
         user_dict={'first_name': 'Testing',
                    'last_name': 'MyTardis API',
                    'email': '*****@*****.**'},
         auth_method="None")
     self.user.user_permissions.add(
         Permission.objects.get(codename='change_dataset'))
     self.user.user_permissions.add(
         Permission.objects.get(codename='add_dataset_file'))
     self.user_profile = UserProfile(user=self.user).save()
     self.testexp = Experiment(title="test exp")
     self.testexp.approved = True
     self.testexp.created_by = self.user
     self.testexp.locked = False
     self.testexp.save()
     testacl = ObjectACL(
         content_type=self.testexp.get_ct(),
         object_id=self.testexp.id,
         pluginId=django_user,
         entityId=str(self.user.id),
         canRead=True,
         canWrite=True,
         canDelete=True,
         isOwner=True,
         aclOwnershipType=ObjectACL.OWNER_OWNED)
     testacl.save()