def test_create_demo_org(self, mock_generate_name): owner = User.objects.create(email=org_owner_email) create_demo_org() demo_org = DemoOrganization.objects.get( organization__name=org_name, status=DemoOrgStatus.PENDING ) org = demo_org.organization assert OrganizationMember.objects.filter( user=owner, organization=org, role="owner" ).exists() assert len(Project.objects.filter(organization=org)) == 2 assert not ProjectKey.objects.filter(project__organization=org).exists()
def test_create_demo_org(self, mock_generate_name, mock_handle_scenario): owner = User.objects.create(email=org_owner_email) create_demo_org() demo_org = DemoOrganization.objects.get(organization__name=org_name, status=DemoOrgStatus.PENDING) org = demo_org.organization assert OrganizationMember.objects.filter(user=owner, organization=org, role="owner").exists() assert len(Project.objects.filter(organization=org)) == 2 mock_handle_scenario.assert_called_once_with(mock.ANY, mock.ANY, quick=False)
def test_no_owner(self, mock_generate_name): with pytest.raises(User.DoesNotExist): create_demo_org() # verify we are using atomic transactions assert not Organization.objects.filter(name=org_name).exists()