django-job-portal icon indicating copy to clipboard operation
django-job-portal copied to clipboard

2 tests failed after basic installtion

Open lironmo opened this issue 3 years ago • 4 comments

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'

  • /en/jobs/2/ ? ^^
  • /en/jobs/1 ? ^ : Expected '/en/jobs/2/' to equal '/en/jobs/1'.

Ran 32 tests in 23.754s

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

lironmo avatar Jan 24 '22 08:01 lironmo

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

image

lironmo avatar Jan 24 '22 08:01 lironmo

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 avatar Jan 24 '22 08:01 lironmo

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

lironmo avatar Jan 24 '22 08:01 lironmo

Thanks for reporting. I will check.

manjurulhoque avatar Jan 24 '22 08:01 manjurulhoque

All tests are working fine.

manjurulhoque avatar Oct 10 '22 17:10 manjurulhoque