mercredi 6 novembre 2019

Mock import to test class method

I have a class that is a Django model:

from django.db import models


class User(models.Model):

The class has a few methods unrelated to the DB side (helpers/static methods, etc). However, when I import it, because it calls django.db.models, it also tries to use the Django settings to connect to the DB. I'm not sure how to properly mock this so it's workable but I can write unit tests for the extra methods.

Aucun commentaire:

Enregistrer un commentaire