Ejemplo n.º 1
0
    def test_image_file_name_uuid(self, mock_uuid):
        uuid = 'test_uuid'
        mock_uuid.return_value = uuid
        file_path = models.image_file_path(None, 'testimage.jpg')

        exp_path = f'uploads/images/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
Ejemplo n.º 2
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = image_file_path(None, 'myimage.jpg')
        exp_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
Ejemplo n.º 3
0
    def test_image_filename_uuid(self, mock_uuid):
        """Testing if image is saved correctly."""

        uuid = 'mock-uuid'

        mock_uuid.return_value = uuid

        file_path = models.image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/images/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
    def test_recipe_filename_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid

        # recipe_image_file_paths accepts 2 parameters
        # first one is the instance which is required
        # by django for the upload_to argument
        # second one is the file name of the original file that
        # is added.
        # The reason we pass the second param is that we want to keep
        # the file extension as it is but we are going to replace the
        # first part 'myimage' with the uuid
        file_path = models.image_file_path(None, 'myimage.jpg')

        # f string, can have variables
        exp_path = f'uploads/gallery/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)