tutorialdb icon indicating copy to clipboard operation
tutorialdb copied to clipboard

Tests required.

Open Animesh-Ghosh opened this issue 5 years ago • 10 comments

None of the apps have any tests written. We NEED tests ASAP.

Animesh-Ghosh avatar Jul 29 '19 17:07 Animesh-Ghosh

Just having a headsup - we would be using the unittest framework

Bhupesh-V avatar Aug 17 '19 13:08 Bhupesh-V

I suggest using Django's testing APIs. That way we can perform isolated database transactions in our tests.

Animesh-Ghosh avatar Aug 17 '19 14:08 Animesh-Ghosh

just committed some initial tests, I will try to list all the things to test here.

  1. Template Names :heavy_check_mark:
  2. URLs :x:
  3. Page Status Codes :heavy_check_mark:
  4. Context Data :x:
  5. Models :x:

Bhupesh-V avatar Aug 25 '19 07:08 Bhupesh-V

What about the API? Can we test them as well?

Animesh-Ghosh avatar Aug 25 '19 08:08 Animesh-Ghosh

What about the API? Can we test them as well?

Yes we can, testing them would be similar to testing views

Bhupesh-V avatar Sep 01 '19 06:09 Bhupesh-V

Hi, I am participating in Hacktoberfest and would like to help on this project. I don't have much experience with testing in Python, but would love to learn and contribute.

hstandeffer avatar Oct 09 '19 16:10 hstandeffer

@hstandeffer you can hack around with the taggie app. When you're comfortable with that module, then create a tests directory inside the taggie directory itself.

Use the unittest module. Here's a video tutorial for you to get started with the unittest module.

Test out the functionality of the module, such as whether the functions give expected output for a specific input.

Animesh-Ghosh avatar Oct 09 '19 16:10 Animesh-Ghosh

@hstandeffer do this to run tests:

  1. Create a local branch.
  2. Update settings.py as follows:
STATIC_URL = '/static/'
STATIC_ROOT = os.environ['STATIC_ROOT']

# STATICFILES_DIRS = [os.path.join('static'),] # additional directories to collectstatic from, shouldn't contain STATIC_ROOT
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
  1. Update requirements.txt as follows (this applies only for development, not for production):
python-dotenv>=0.10.0
django-import-export>=1.0.0
whitenoise==3.3.1
gunicorn==19.7.1
  1. Add static/ to .gitignore:
*.log
local_settings.py
db.sqlite3
static/

# Flask stuff:
instance/
  1. Create a directory by the name 'static' and then run python manage.py collectstatic.
  2. Run tests with python manage.py test.

Do let me know if any problems arise.

Animesh-Ghosh avatar Oct 09 '19 18:10 Animesh-Ghosh

I've followed these steps and it is throwing a key error for the line in your second step of the email for the ['STATIC_ROOT']

On Wed, Oct 9, 2019 at 1:32 PM MaDDogx [email protected] wrote:

@hstandeffer https://github.com/hstandeffer do this to run tests:

  1. Create a local branch.
  2. Update settings.py as follows:

STATIC_URL = '/static/'STATIC_ROOT = os.environ['STATIC_ROOT']

STATICFILES_DIRS = [os.path.join('static'),] # additional directories to collectstatic from, shouldn't contain STATIC_ROOTSTATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

  1. Update requirements.txt as follows (this applies only for development, not for production):

python-dotenv>=0.10.0 django-import-export>=1.0.0 whitenoise==3.3.1 gunicorn==19.7.1

  1. Add static/ to .gitignore.
  2. Create a directory by the name 'static' and then run python manage.py collectstatic.
  3. Run tests with python manage.py test.

Do let me know if any problems arise.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Bhupesh-V/tutorialdb/issues/9?email_source=notifications&email_token=AIJKXCPVPTIVT7K767X5CWLQNYPSPA5CNFSM4IHUZFW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAY32WY#issuecomment-540130651, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIJKXCOWMAQQT6JYNZXPZEDQNYPSPANCNFSM4IHUZFWQ .

-- Harrison Standeffer

hstandeffer avatar Oct 09 '19 21:10 hstandeffer

Did you setup the .env files properly?

The STATIC_ROOT virtual environment variable needs to be an absolute path to the /static/ directory inside the tutorialdb root directory.

So, STATIC_ROOT needs to be set to C:\USER\path\to\tutorialdb\static\ inside .env for Windows.

Animesh-Ghosh avatar Oct 10 '19 02:10 Animesh-Ghosh