def setUp(self): self.resource_quota_user = ResourceQuota( codename='test_user_codename', name='test_name', description='test_description', default=1.21, units='GW', applies_to='django.contrib.auth.models.User', impose_default=True, help='Exceeded quota', _handler='tethys_quotas.handlers.workspace.WorkspaceQuotaHandler' ) self.resource_quota_user.save() self.resource_quota_app = ResourceQuota( codename='test_app_codename', name='test_name', description='test_description', default=1.21, units='GW', applies_to='tethys_apps.models.TethysApp', impose_default=True, help='Exceeded quota', _handler='tethys_quotas.handlers.workspace.WorkspaceQuotaHandler' ) self.resource_quota_app.save()
def setUp(self): user = User.objects.create_user(username="******", email="*****@*****.**", password="******") self.resource_quota_handler = WorkspaceQuotaHandler(user) self.resource_quota_user = ResourceQuota( codename='test_user_codename', name='test_name', description='test_description', default=1.21, units='gb', applies_to='django.contrib.auth.models.User', impose_default=False, help='Exceeded quota', _handler='tethys_quotas.handlers.workspace.WorkspaceQuotaHandler') self.resource_quota_user.save() self.entity_quota_user = UserQuota( resource_quota=self.resource_quota_user, entity=user, value=100, ) self.entity_quota_user.save() self.resource_quota_app = ResourceQuota( codename='test_app_codename', name='test_name', description='test_description', default=1.21, units='gb', applies_to='tethys_apps.models.TethysApp', impose_default=True, help='Exceeded quota', _handler='tethys_quotas.handlers.workspace.WorkspaceQuotaHandler') self.resource_quota_app.save() self.app_model = TethysApp(name='Test App') self.app_model.save() self.entity_quota_app = TethysAppQuota( resource_quota=self.resource_quota_app, entity=self.app_model, value=200, ) self.entity_quota_app.save()
def test_codename_unique(self): duplicate_rq = ResourceQuota( codename='test_user_codename', name='test_name', description='test_description', default=1.21, units='GW', applies_to='django.contrib.auth.models.User', impose_default=True, help='Exceeded quota', _handler='tethys_quotas.handlers.WorkspaceQuotaHandler') with transaction.atomic(): self.assertRaises(IntegrityError, duplicate_rq.save)