manjurulhoque / django-job-portal

Job portal application using Django
MIT License
541 stars 242 forks source link

2 tests failed after basic installtion #40

Closed lironmo closed 1 year ago

lironmo commented 2 years ago

Hi,

run the test and got:

(portal) C:\Users\liron\work\qualiifly\django-job-portal>python manage.py test Found 32 test(s). Creating test database for alias 'default'... System check identified no issues (0 silenced). ..............E........FC:\envs\portal\lib\site-packages\django\db\models\fields__init__.py:1409: RuntimeWarning: DateTimeField Job.last_date received a naive datetime (2022-02-23 10:06:16.518056) while time zone support is active. warnings.warn("DateTimeField %s received a naive datetime (%s)" .C:\envs\portal\lib\site-packages\django\db\models\fields__init__.py:1409: RuntimeWarning: DateTimeField Job.last_date received a naive datetime (2022-02-23 10:06:18.628519) while time zone support is active. warnings.warn("DateTimeField %s received a naive datetime (%s)" F......

ERROR: test_email_label (tests.accounts.test_models.TestUserModel)

Traceback (most recent call last): File "C:\Users\liron\work\qualiifly\django-job-portal\tests\accounts\test_models.py", line 28, in test_email_label user = User.objects.get(id=1) File "C:\envs\portal\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\envs\portal\lib\site-packages\django\db\models\query.py", line 439, in get raise self.model.DoesNotExist( accounts.models.User.DoesNotExist: User matching query does not exist.

====================================================================== FAIL: test_valid_and_save_form (tests.jobsapp.test_forms.TestCreateJobForm)

Traceback (most recent call last): File "C:\Users\liron\work\qualiifly\django-job-portal\tests\jobsapp\test_forms.py", line 36, in test_valid_and_save_form self.assertTrue(form.is_valid()) AssertionError: False is not true

====================================================================== FAIL: test_get_absolute_url (tests.jobsapp.test_models.TestJobModel)

Traceback (most recent call last): File "C:\Users\liron\work\qualiifly\django-job-portal\tests\jobsapp\test_models.py", line 43, in test_get_absolute_url self.assertURLEqual(self.job.get_absolute_url(), f"/{self.language_code}/jobs/1") File "C:\envs\portal\lib\site-packages\django\test\testcases.py", line 412, in assertURLEqual self.assertEqual( AssertionError: '/en/jobs/2/' != '/en/jobs/1'


Ran 32 tests in 23.754s

FAILED (failures=2, errors=1) Destroying test database for alias 'default'...

lironmo commented 2 years ago

seems that when I rerun the test manually it's works - may be a problem with the other tests?

image

lironmo commented 2 years ago

the bug in test_email_label, is that you using a specific id: user = User.objects.get(id=1) when you run all tests there are many tests before that create and delete users (7 tests before) so the id is 7.

for the test is best to simply get the first user - you just check the label. User.objects.first()

lironmo commented 2 years ago

the bug at is test_valid_and_save_form {'tags': ['This field is required.']}

seems that the field is required - need to add to the JSON.

suggestion - propagate the error instead true false check

manjurulhoque commented 2 years ago

Thanks for reporting. I will check.

manjurulhoque commented 1 year ago

All tests are working fine.