File size: 1,275 Bytes
38171fa |
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 33 34 35 36 37 38 39 40 41 42 43 |
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)
|