S
S
Sergey Nizhny Novgorod2016-08-10 17:50:55
Django
Sergey Nizhny Novgorod, 2016-08-10 17:50:55

How to check image loading with unit-tests/integration tests?

Hello. Now I'm writing a "straightforward check" of the model. Those. I create a model with certain attributes and check that this model has those attributes.
There is a question on two points:
1) How to check the loading of pictures?
2) How to check m2m

class Article_can_save_models_data(TestCase):

    def article_can_call_for_its_attr(self):

        article = Article.objects.create(
            article_categore = 'отношения',
            seo_title = 'seo заголовок статьи',
            seo_description = 'seo описание статьи',
            small_description = 'малое описание',
            title = 'заголовок статьи',
            # article_image = False,
            # article_smallimage = False,
            article_body = 'тело статьи',
            thumbnumber = 10,
            # main = "", M2M
            course1 = 1,
            course2 = 2,
            # likedone = "" FKey
        )

        self.assertEqual(article.get_plus(), '+10')
        self.assertEqual(article.article_categore, 'отношения')
        self.assertEqual(article.seo_title, 'seo заголовок статьи')
        self.assertEqual(article.seo_description, 'seo описание статьи')
        self.assertEqual(article.title, 'заголовок статьи')
        self.assertEqual(article.article_body, 'тело статьи')
        self.assertEqual(article.thumbnumber, 10)
        self.assertEqual(article.course1, 1)
        self.assertEqual(article.course2, 2)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-08-10
@deliro

Selenium and run the complete script, from logging in to the site, to uploading images, and verifying that it exists.
PS It makes no sense to test Article.objects.create if you have objects - not a custom manager with an overridden create method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question