text2sql / core /test_models.py
ns-devel
Text2SQL app
38171fa
from django.test import TestCase
from core.models import MutualFund
class TestMutualFund(TestCase):
def test_model_creation(self):
# Create a new MutualFund instance
mutual_fund1 = MutualFund(
fund_name="Test Fund 1",
isin_number="123456789012",
security_id="MST01234",
data={
"details": {
"legalName": "Test Fund 1",
"isin": "123456789012",
"secId": "MST01234",
}
},
)
# Save the MutualFund instance to the database
mutual_fund1.save()
# Check if the MutualFund instance was saved successfully
self.assertEqual(MutualFund.objects.count(), 1)
mutual_fund2 = MutualFund(
fund_name="Test Fund 2",
isin_number="9876543210",
security_id="MST56789",
data={
"details": {
"legalName": "Test Fund 2",
"isin": "9876543210",
"secId": "MST56789",
}
},
)
mutual_fund2.save()
self.assertNotEqual(mutual_fund1.id, mutual_fund2.id)
self.assertEqual(MutualFund.objects.count(), 2)