Hi Collin,
Thanks a lot for the answer. I think you are right, and that was what
I was doing. Still, apparently the models could not be created
properly, or whatever.
However I think I managed to convert this problem to a different one
(not sure if I should start a new thread).
What I did was: remove the __pycache__ dirs, remake the migrations,
and remove some models that were created by inspectdb (django
related).
Now, the original problem has gone, BUT something (related, I think)
happens. With _meta.managed=False in my models I get
...
django.db.utils.ProgrammingError: Table 'test_job_mon.job_info' doesn't exist
The test I'm running is very simple:
class HomePageTest(TestCase):
def setUp(self):
from django.db.models.loading import get_models
self.unmanaged_models = [m for m in get_models() if not m._meta.managed]
for m in self.unmanaged_models:
m._meta.managed = True
def tearDown(self):
for m in self.unmanaged_models:
m._meta.managed = False
def test_there_are_no_job_items_in_empty_db(self):
njobs = JobInfo.objects.count()
self.assertEqual(njobs, 0)
The relevant model:
class JobInfo(models.Model):
job_db_inx = models.IntegerField(primary_key=True)
id_job = models.IntegerField()
id_user = models.IntegerField()
id_group = models.IntegerField()
account = models.TextField(blank=True)
cpus_req = models.IntegerField()
cpus_alloc = models.IntegerField()
nodelist = models.TextField()
nodes_alloc = models.IntegerField()
partition = models.TextField()
time_start = models.IntegerField()
time_end = models.IntegerField()
was_updated = models.IntegerField()
jobmondatacleared =
models.IntegerField(db_column='jobMonDataCleared') # Field name made
lowercase.
endupcount = models.IntegerField(db_column='endUpCount') # Field
name made lowercase.
approved = models.IntegerField()
class Meta:
managed = False
db_table = 'job_info'
Now, if I comment the line "managed = False" and run makemigrations,
the test passes.
But I have checked that "managed" is switched to True during the tests.
Any ideas?
Thanks in advance,
David
2014-11-05 18:45 GMT+01:00 Collin Anderson <cmawebsite@gmail.com>:
> Hi David,
>
> Interesting. Shouldn't the test database be a separate, fresh, empty
> database (not a legacy database)?
>
> Thanks,
> Collin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b79d8ab2-38ef-489d-9563-c2474c58defb%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKUKWzm_8fM0fXW2DcAQsvYffXeN3indxtqtQHzsQ6U5_K7RWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment