How to use generate_default_name method in localstack

Best Python code snippet using localstack_python

test_sharing.py

Source:test_sharing.py Github

copy

Full Screen

...5 def test_share_project_personal_workspace(self, client, client_2, email_2):6 """7 User 1 share a project in personal workspace to user 2.8 """9 project_name = _utils.generate_default_name()10 project = client.create_project(project_name)11 project._add_collaborator(email=email_2)12 assert client_2.get_project(id=project.id)13 assert client_2.get_project(name=project.name)14 def test_org_public_project(self, client, organization, client_2, email_2):15 """16 User 2 tries to access a org-public project created by a user in the same organization.17 """18 project_name = _utils.generate_default_name()19 project = client.create_project(project_name, workspace=organization.name, public_within_org=True)20 organization.add_member(email_2)21 assert client_2.get_project(id=project.id)22 assert client_2.get_project(name=project.name, workspace=organization.name)23 def test_non_org_public_project_access_error(self, client, organization, client_2, email_2):24 """25 User 2 tries to access a non-org-public project created by a user in the same organization.26 """27 project_name = _utils.generate_default_name()28 project = client.create_project(project_name, workspace=organization.name, public_within_org=False)29 organization.add_member(email_2)30 # Shouldn't be able to access:31 with pytest.raises(ValueError, match="not found"):32 client_2.get_project(id=project.id)33 def test_share_org_project(self, client, organization, client_2, email_2):34 """35 User 2 tries to access a non-org-public project created by another user, but has been shared to user 2.36 """37 project_name = _utils.generate_default_name()38 project = client.create_project(project_name, workspace=organization.name, public_within_org=False)39 organization.add_member(email_2)40 project._add_collaborator(email=email_2)41 assert client_2.get_project(id=project.id)42 assert client_2.get_project(name=project.name, workspace=organization.name)43class TestDataset:44 def test_org_public_dataset(self, client, organization, client_2, email_2):45 """46 User 2 tries to access a org-public dataset created by a user in the same organization.47 """48 dataset_name = _utils.generate_default_name()49 dataset = client.create_dataset(dataset_name, workspace=organization.name, public_within_org=True)50 organization.add_member(email_2)51 assert client_2.get_dataset(id=dataset.id)52 assert client_2.get_dataset(name=dataset.name, workspace=organization.name)53 dataset.delete()54 def test_non_org_public_dataset_access_error(self, client, organization, client_2, email_2):55 """56 User 2 tries to access a non-org-public dataset created by a user in the same organization.57 """58 dataset_name = _utils.generate_default_name()59 dataset = client.create_dataset(dataset_name, workspace=organization.name, public_within_org=False)60 organization.add_member(email_2)61 # Shouldn't be able to access:62 with pytest.raises(ValueError, match="not found"):63 client_2.get_dataset(id=dataset.id)64 dataset.delete()65class TestRegisteredModel:66 def test_org_public_registered_model(self, client, organization, client_2, email_2):67 """68 User 2 tries to access a org-public registered_model created by a user in the same organization.69 """70 registered_model_name = _utils.generate_default_name()71 registered_model = client.create_registered_model(registered_model_name, workspace=organization.name, public_within_org=True)72 organization.add_member(email_2)73 assert client_2.get_registered_model(id=registered_model.id)74 assert client_2.get_registered_model(name=registered_model.name, workspace=organization.name)75 registered_model.delete()76 def test_non_org_public_registered_model_access_error(self, client, organization, client_2, email_2):77 """78 User 2 tries to access a non-org-public registered_model created by a user in the same organization.79 """80 registered_model_name = _utils.generate_default_name()81 registered_model = client.create_registered_model(registered_model_name, workspace=organization.name, public_within_org=False)82 organization.add_member(email_2)83 # Shouldn't be able to access:84 with pytest.raises(ValueError, match="not found"):85 client_2.get_registered_model(id=registered_model.id)86 registered_model.delete()87class TestRepository:88 def test_org_public_repository(self, client, organization, client_2, email_2):89 """90 User 2 tries to access a org-public repository created by a user in the same organization.91 """92 repository_name = _utils.generate_default_name()93 repository = client.set_repository(repository_name, workspace=organization.name, public_within_org=True)94 organization.add_member(email_2)95 assert client_2.get_or_create_repository(id=repository.id)96 assert client_2.get_or_create_repository(name=repository.name, workspace=organization.name).id == repository.id97 repository.delete()98 def test_non_org_public_repository_access_error(self, client, organization, client_2, email_2):99 """100 User 2 tries to access a non-org-public repository created by a user in the same organization.101 """102 repository_name = _utils.generate_default_name()103 repository = client.set_repository(repository_name, workspace=organization.name, public_within_org=False)104 organization.add_member(email_2)105 # Shouldn't be able to access:106 with pytest.raises(ValueError, match="no Repository found"):107 client_2.get_or_create_repository(id=repository.id)108 repository.delete()109class TestEndpoint:110 def test_org_endpoint(self, client, organization, client_2, email_2):111 """112 Non-owner access to org-public endpoint and private endpoint within an org.113 """114 organization.add_member(email_2)115 path = _utils.generate_default_name()116 # ORG_SCOPED_PUBLIC117 public_path = "public-{}".format(path)118 endpoint = client.create_endpoint(public_path, workspace=organization.name, public_within_org=True)119 client_2.get_endpoint(public_path, workspace=organization.name)120 endpoint.delete()121 # PRIVATE122 private_path = "private-{}".format(path)123 endpoint = client.create_endpoint(private_path, workspace=organization.name)124 with pytest.raises(ValueError, match="Endpoint not found"):125 client_2.get_endpoint(private_path, workspace=organization.name)...

Full Screen

Full Screen

test_organization.py

Source:test_organization.py Github

copy

Full Screen

...23 default_repo_collaborator_type="READ_WRITET",24 default_endpoint_collaborator_type="READ_ONLY"), True)25class TestOrganization:26 def test_create(self, client):27 name = _utils.generate_default_name()28 org = client._create_organization(name)29 assert org30 assert org.id == client._get_organization(name).id31 org.delete()32 def test_create_same_name_diff_workspace(self, client, organization, created_entities):33 # creating some entities:34 project_name = _utils.generate_default_name()35 exp_name = _utils.generate_default_name()36 run_name = _utils.generate_default_name()37 dataset_name = _utils.generate_default_name()38 repository_name = _utils.generate_default_name()39 model_name = _utils.generate_default_name()40 version_name = _utils.generate_default_name()41 endpoint_path = _utils.generate_default_name()42 project = client.create_project(project_name)43 exp = client.create_experiment(exp_name)44 run = client.create_experiment_run(run_name)45 repository = client.get_or_create_repository(name=repository_name)46 dataset = client.create_dataset(dataset_name)47 created_entities.append(dataset)48 model = client.create_registered_model(name=model_name)49 version = model.create_version(name=version_name)50 created_entities.append(model)51 endpoint = client.create_endpoint(path=endpoint_path)52 created_entities.append(endpoint)53 # create entities with same name, but different workspace:54 new_model = client.create_registered_model(name=model_name, workspace=organization.name)55 new_version = new_model.create_version(name=version_name)...

Full Screen

Full Screen

0021_code_name.py

Source:0021_code_name.py Github

copy

Full Screen

1# Generated by Django 3.1.5 on 2021-01-07 18:372from django.db import migrations, models3def generate_default_name(apps, schema_editor):4 upload_model = apps.get_model('backend', 'Code')5 i = 06 for model_instance in upload_model.objects.all():7 model_instance.name = f'default_name_{i}'8 i += 19 model_instance.save(update_fields=['name'])10class Migration(migrations.Migration):11 dependencies = [12 ('backend', '0020_auto_20210104_2257'),13 ]14 operations = [15 migrations.AddField(16 model_name='code',17 name='name',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful