class ImageDownloaderCreateImagesTest(APITestCase): """ Test for validate creating records in Image model by upload images from external API """ def setUp(self): self.image_downloader = ImageDownloader() def test_get_update_images(self): self.assertEqual(Image.objects.count(), 0) self.image_downloader.update_or_create_images() self.assertEqual(Image.objects.count(), 259)
class ImageDownloaderUpdateImagesTests(APITestCase): """ Test for validate updating of Image model by upload new records from external API """ def setUp(self): call_command("loaddata", "main_app/fixtures/initial_data.json", verbosity=0) self.image_downloader = ImageDownloader() def test_get_update_images(self): self.assertEqual(Image.objects.count(), 20) self.image_downloader.update_or_create_images() self.assertEqual(Image.objects.count(), 259)
def cron_update_images(): logger.info("cron job update_images started") image_downloader = ImageDownloader() image_downloader.update_or_create_images() logger.info("cron job update_images finished")
def handle(self, *args, **options): logger.info("Started initialize db command") img_downloader = ImageDownloader() img_downloader.update_or_create_images() logger.info("Finished initialize db command")
def setUp(self): self.image_downloader = ImageDownloader()
def setUp(self): call_command("loaddata", "main_app/fixtures/initial_data.json", verbosity=0) self.image_downloader = ImageDownloader()