Ejemplo n.º 1
0
    def test_current_tenant_value_single(self):
        from .models import Project, Account

        projects = self.projects
        account = projects[0].account
        set_current_tenant(account)

        self.assertEqual(get_current_tenant_value(), account.id)

        unset_current_tenant()
Ejemplo n.º 2
0
    def test_current_tenant_value_queryset(self):
        from .models import Project, Account

        projects = self.projects
        accounts = Account.objects.all().order_by('id')
        set_current_tenant(accounts)

        value = get_current_tenant_value()

        self.assertEqual(get_tenant_filters(Project),
                         {'account_id__in': list(accounts.values_list('id', flat=True))})
        unset_current_tenant()
Ejemplo n.º 3
0
    def test_current_tenant_value_queryset(self):
        from .models import Project, Account

        projects = self.projects
        accounts = Account.objects.all().order_by("id")
        set_current_tenant(accounts)

        value = get_current_tenant_value()

        self.assertTrue(isinstance(value, list))
        self.assertEqual(value, accounts.values_list("id", flat=True))

        unset_current_tenant()
Ejemplo n.º 4
0
    def test_current_tenant_value_list(self):
        from .models import Project, Account

        projects = self.projects
        accounts = [projects[0].account, projects[1].account]
        set_current_tenant(accounts)

        value = get_current_tenant_value()

        self.assertTrue(isinstance(value, list))
        self.assertEqual(value, [accounts[0].id, accounts[1].id])

        unset_current_tenant()