TestRandImgProvider.test_download_image()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
import unittest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
import os
3
from faker import Faker
4
from pyrandimg.randimg_provider import RandImgProvider
5
6
7
class TestRandImgProvider(unittest.TestCase):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
8
    def setUp(self):
9
        """ Initialize each unit test """
10
        self.faker = Faker()
11
        self.faker.add_provider(RandImgProvider)
12
13
    def test_generate_default_image_url(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
14
        self.assertRegex(self.faker.image_url(), r'^(https?\:\/\/)?www\.rand\-img\.com\/720\/480$')
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
15
16
    def test_generate_image_url_with_custom_width(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_generate_image_url_with_custom_width does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
17
        self.assertRegex(self.faker.image_url(200), r'^(https?\:\/\/)?www\.rand\-img\.com\/200\/480$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (102/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
18
        self.assertRegex(self.faker.image_url(980), r'^(https?\:\/\/)?www\.rand\-img\.com\/980\/480$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (102/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
19
20
    def test_generate_image_url_with_custom_width_and_height(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_generate_image_url_...custom_width_and_height does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
21
        self.assertRegex(self.faker.image_url(200, 500), r'^(https?\:\/\/)?www\.rand\-img\.com\/200\/500$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
22
        self.assertRegex(self.faker.image_url(320, 280), r'^(https?\:\/\/)?www\.rand\-img\.com\/320\/280$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
23
        self.assertRegex(self.faker.image_url(1920, 1080), r'(https?\:\/\/)?www\.rand\-img\.com\/1920\/1080')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (109/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
24
25
    def test_generate_image_url_with_category(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_generate_image_url_with_category does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
26
        self.assertRegex(self.faker.image_url(200, 500, 'food'), r'^(https?\:\/\/)?www\.rand\-img\.com\/200\/500\/food$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (121/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
27
        self.assertRegex(self.faker.image_url(500, 653, 'sky'), r'^(https?\:\/\/)?www\.rand\-img\.com\/500\/653\/sky$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
28
29
    def test_generate_rand_image_url(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
30
        self.assertRegex(
31
            self.faker.squared_image_url(320, rand=True),
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named squared_image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
32
            r'^(https?\:\/\/)?www\.rand\-img\.com\/320\/320\?rand=\d+$'
33
        )
34
35
    def test_generate_default_squared_image_url(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_generate_default_squared_image_url does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
36
        self.assertRegex(self.faker.squared_image_url(200), r'^(https?\:\/\/)?www\.rand\-img\.com\/200\/200$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named squared_image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
37
38
    def test_generate_squared_image_url_with_category(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_generate_squared_image_url_with_category does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
39
        self.assertRegex(
40
            self.faker.squared_image_url(200, 'food'),
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named squared_image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
41
            r'^(https?\:\/\/)?www\.rand\-img\.com\/200\/200\/food$'
42
        )
43
        self.assertRegex(
44
            self.faker.squared_image_url(1024, 'sky'),
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named squared_image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
45
            r'^(https?\:\/\/)?www\.rand\-img\.com\/1024\/1024\/sky$'
46
        )
47
48
    def test_image_url_with_parameters(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
49
        self.assertRegex(
50
            self.faker.image_url(720, 480, 'food', rand=True, blur=4, gray=1),
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
51
            r'https?:\/\/www\.rand\-img\.com\/720\/480/food\?([(\&?rand\=\d+)(\&?blur\=4)(\&?gray\=1)])'
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (104/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
52
        )
53
        self.assertRegex(
54
            self.faker.image_url(250, 120, 'fashion', rand=False, blur=4, gray=1),
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named image_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
55
            r'https?:\/\/www\.rand\-img\.com\/250\/120/fashion\?([(\&?blur\=4)(\&?gray\=1)])'
56
        )
57
58
    def test_get_gif(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
59
        self.assertRegex(self.faker.gif_url(), r'^(https?\:\/\/)?www\.rand\-img\.com\/gif$')
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named gif_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
60
61
    def test_get_gif_with_rand(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
62
        self.assertRegex(self.faker.gif_url(True), r'^(https?\:\/\/)?www\.rand\-img\.com\/gif\?rand\=\d+$')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Bug introduced by
The Instance of Generator does not seem to have a member named gif_url.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
63
64
    def test_download_gif(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
65
        gif = self.faker.gif()
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named gif.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
66
        gif_dirname = os.path.dirname(gif)
0 ignored issues
show
Unused Code introduced by
The variable gif_dirname seems to be unused.
Loading history...
67
        _, file_ext = os.path.splitext(gif)
68
69
        self.assertEqual('.gif', file_ext)
70
        self.assertTrue(os.path.exists(gif))
71
        os.remove(gif)
72
73
    def test_download_gif_with_dirname(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
74
        os.mkdir('output')
75
        output_dir = os.path.join(os.getcwd(), 'output')
76
        gif = self.faker.gif(dir=output_dir)
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named gif.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
77
        gif_dirname = os.path.dirname(gif)
78
        _, file_ext = os.path.splitext(gif)
79
80
        self.assertEqual(output_dir, gif_dirname)
81
        self.assertEqual('.gif', file_ext)
82
        self.assertTrue(os.path.exists(gif))
83
        os.remove(gif)
84
        os.rmdir(output_dir)
85
86
    def test_download_gif_with_invalid_argument_exception(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_download_gif_with_invalid_argument_exception does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
87
        pass
88
89
    def test_download_image(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
90
        gif = self.faker.gif()
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named gif.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
91
        gif_dirname = os.path.dirname(gif)
0 ignored issues
show
Unused Code introduced by
The variable gif_dirname seems to be unused.
Loading history...
92
        _, file_ext = os.path.splitext(gif)
93
94
        self.assertEqual('.gif', file_ext)
95
        self.assertTrue(os.path.exists(gif))
96
        os.remove(gif)
97
98 View Code Duplication
    def test_download_image_with_dirname(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Coding Style Naming introduced by
The name test_download_image_with_dirname does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
99
        os.mkdir('output')
100
        output_dir = os.path.join(os.getcwd(), 'output')
101
        image = self.faker.image(dir=output_dir)
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named image.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
102
        image_dirname = os.path.dirname(image)
103
        _, file_ext = os.path.splitext(image)
104
105
        self.assertEqual(output_dir, image_dirname)
106
        self.assertEqual('.jpg', file_ext)
107
        self.assertTrue(os.path.exists(image))
108
        os.remove(image)
109
        os.rmdir(output_dir)
110
111 View Code Duplication
    def test_download_image_with_dirname_and_filename(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Coding Style Naming introduced by
The name test_download_image_with_dirname_and_filename does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
112
        os.mkdir('output')
113
        output_dir = os.path.join(os.getcwd(), 'output')
114
        image = self.faker.image(dir=output_dir, filename='testing.png')
0 ignored issues
show
Bug introduced by
The Instance of Generator does not seem to have a member named image.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
115
        image_dirname = os.path.dirname(image)
116
        _, file_ext = os.path.splitext(image)
117
118
        self.assertEqual(output_dir, image_dirname)
119
        self.assertEqual('.png', file_ext)
120
        self.assertTrue(os.path.exists(image))
121
        os.remove(image)
122
        os.rmdir(output_dir)
123
124
    def test_download_image_with_exception(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_download_image_with_exception does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
125
        pass
126
127
    def test_download_image_with_invalid_argument_exception(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_download_image_with...alid_argument_exception does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
128
        pass
129