def test_get_subscriptions_for_user(self): tenant1 = create_test_tenant(user=self.user1, name="DL1") tenant2 = create_test_tenant(user=self.user1, name="DL2") subscriptions = UserTenantSubscription.get_subscriptions_for_user( self.user1) self.assertEqual(len(subscriptions), 2) self.assertEqual(subscriptions[0].user.id, self.user1.id) self.assertEqual(subscriptions[0].tenant.id, tenant1.id) self.assertTrue(subscriptions[0].is_admin) self.assertEqual(subscriptions[1].user.id, self.user1.id) self.assertEqual(subscriptions[1].tenant.id, tenant2.id) self.assertTrue(subscriptions[1].is_admin)
def setUp(self): self.now = now_utc() self.user = create_test_user(name="testuser") self.tenant = create_test_tenant(user=self.user) self.dataset = self.tenant.create_dataset("test-name", "1.0", 1, "test-description", self.user, "test-team") self.data_repo = self.tenant.create_data_repo("main-repo", "data-repo-description", DataRepo.RepoType.HDFS, "{}") self.application = self.tenant.create_application( self.user, "demoapp", "demoapp description", "admin", "s3://bucket/demoapp") self.other_asset = self.dataset.create_asset( "asset-other", 10, self.now, [ LOC("parquet", "/data/foo1.parquet", 100, "main-repo"), LOC("json", "/data/foo2.json", 150, "main-repo") ], loader='{"type": "union"}', application=self.application, application_args="{}")
def setUp(self): # we have a tenant created # we have an application added to the tenant # we have a repo added to tenant # we have a dataset added to tenant # we have an asset added to the dataset self.now = now_utc() self.user = create_test_user(name='testuser',) self.tenant = create_test_tenant(user=self.user, name="datalake name", description="datalake description") self.tenant.create_data_repo("main-repo", "data-repo-description", DataRepo.RepoType.HDFS, "{}") self.application = self.tenant.create_application( self.user, "test-app", "test-app-description", "admins", "s3://data-manager-apps/test/1.0.0.0" ) self.dataset = self.tenant.create_dataset( "test-name", "1.0", 1, "test-description", self.user, "test-team" ) self.other_asset = self.dataset.create_asset( "asset-other", 10, self.now, [ LOC("parquet", "/data/foo1.parquet", 100, "main-repo"), LOC("json", "/data/foo2.json", 150, "main-repo"), ], loader='{"type": "union"}', application=self.application, application_args="{}" )
def test_create_asset_bad_application(self): # Try to create asset and claim it is created by an application not belong # to the dataset's tenant tenant2 = create_test_tenant(user=self.user, name="DL2") application = tenant2.create_application(self.user, "fooapp", "fooapp description", "admin", "s3://bucket/name") with self.assertRaises(ValidationError) as cm: self.dataset.create_asset("asset-name", 10, self.now, [], application=application) self.assertEqual(cm.exception.message, "Application not in the tenant")
def test_uniqueness(self): tenant = create_test_tenant(user=self.user1) subscription1 = UserTenantSubscription(user=self.user2, tenant=tenant, is_admin=True) subscription1.save() with self.assertRaises(IntegrityError) as cm: subscription2 = UserTenantSubscription(user=self.user2, tenant=tenant, is_admin=True) subscription2.save() self.assertRegex(cm.exception.args[1], r"^Duplicate entry.*$")
def setUp(self): # simple setup, we have a tenant created # we have self.user1 subscribed to the tenant as admin # self.user2 not subscribed to the tenant # self.user3 subscribed to the tenant as non-admin self.now = now_utc() self.user = create_test_user(name="testuser") self.tenant = create_test_tenant( user=self.user, name="DL", ) self.user2 = create_test_user(name='testuser2') self.user3 = create_test_user(name='testuser3') self.tenant.subscribe_user(self.user3, is_admin=False)
def test_attach_bad_pipeline(self): tenant2 = create_test_tenant(user=self.user, name="DL2") pipeline_group = PipelineGroup( tenant=self.tenant, name="test-pipeline-group", created_time=self.now, category="test-category", context="{}", finished=True, due=datetime(2021, 1, 1).replace(tzinfo=pytz.UTC)) pipeline_group.save() pipeline = tenant2.create_pipeline(self.user, "foo-pipeline", "blah...", "admins", "test-category", "{}") # it should fail since pipeline belongs to a different tenant with self.assertRaises(ValidationError) as cm: pipeline_group.attach(pipeline) self.assertEqual(cm.exception.message, "Invalid tenant")
def setUp(self): self.user = create_test_user(name='testuser') self.tenant = create_test_tenant(user=self.user)
def setUp(self): self.now = now_utc() self.user = create_test_user(name="testuser") self.user2 = create_test_user(name="testuser2") self.tenant = create_test_tenant(user=self.user) self.tenant.subscribe_user(self.user2)
def setUp(self): # we have a tenant created # we have a pipeline created self.now = now_utc() self.user = create_test_user(name='testuser') self.tenant = create_test_tenant(user=self.user)
def setUp(self): self.now = now_utc() self.user = create_test_user(name='testuser') self.tenant = create_test_tenant(user=self.user, name="DL") self.user2 = create_test_user(name='testuser2') self.tenant.subscribe_user(self.user2)
def setUp(self): self.now = now_utc() self.user = create_test_user(name='testuser') self.tenant = create_test_tenant(user=self.user, name="DL") self.tenant2 = create_test_tenant(user=self.user, name="DL2")