Bin
2025-12-17 d616898802dfe7e5dd648bcf53c6d1f86b6d3642
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.test import TestCase
from ml_model_providers.models import ModelProviderConnection
from organizations.tests.factories import OrganizationFactory
 
 
class TestModelProviderConnection(TestCase):
    @classmethod
    def setUpTestData(cls):
        cls.organization = OrganizationFactory()
 
    def test_has_reached_budget_limit(self):
        mpc = ModelProviderConnection.objects.create(
            organization=self.organization,
            created_by=self.organization.created_by,
        )
        # Not internal
        assert not mpc.has_reached_budget_limit()
        mpc.is_internal = True
        mpc.save()
        # No budget_total_spent
        assert not mpc.has_reached_budget_limit()
        mpc.budget_total_spent = 1000
        mpc.save()
        # No budget_limit
        assert not mpc.has_reached_budget_limit()
        mpc.budget_limit = 2000
        mpc.save()
        # Not reached
        assert not mpc.has_reached_budget_limit()
        mpc.budget_total_spent = 2001
        # Reached
        assert mpc.has_reached_budget_limit()