i have a initial_data command in my project and when i try to create my test database and run this command "py manage.py initial_data" it's not working because this command makes data in main database and not test_database, actually can't understand which one is test_database. so i give up to use this command,and i have other method to resolve my problem . and i decided to create manually my initial_data. initial_data command actually makes my required data in my other tables. and why i try to create data? because i have greater than 500 tests and this tests required to other test datas. so i have this tests:
class BankServiceTest(TestCase):
def setUp(self):
self.bank_model = models.Bank
self.country_model = models.Country
def test_create_bank_object(self):
self.bank_model.objects.create(name='bank')
re1 = self.bank_model.objects.get(name='bank')
self.assertEqual(re1.name, 'bank')
def test_create_country_object(self):
self.country_model.objects.create(name='country', code=100)
bank = self.bank_model.objects.get(name='bank')
re1 = self.country_model.objects.get(code=100)
self.assertEqual(re1.name, 'country')
i want after running "test create bank object " to have first function datas in second function actually this method Performs the command "initial_data".
so what is the method for this problem.
i used unit_test.TestCase but it not working for me. this method actually makes test data in main data base and i do not want this method. or maybe i used bad of this method.
actually i need to keep my data in running test.