|
@@ 60-76 (lines=17) @@
|
| 57 |
|
def it_handles_invalid_paths(template): |
| 58 |
|
expect(template.get_path("@#$%^")) == None |
| 59 |
|
|
| 60 |
|
def describe_path(): |
| 61 |
|
|
| 62 |
|
def is_returned_when_file_exists(template): |
| 63 |
|
template.root = "my_root" |
| 64 |
|
|
| 65 |
|
with patch('pathlib.Path.is_file', Mock(return_value=True)): |
| 66 |
|
path = template.path |
| 67 |
|
|
| 68 |
|
expect(path) == Path("my_root/abc/default.png") |
| 69 |
|
|
| 70 |
|
def is_none_when_no_file(template): |
| 71 |
|
template.root = "my_root" |
| 72 |
|
|
| 73 |
|
with patch('pathlib.Path.is_file', Mock(return_value=False)): |
| 74 |
|
path = template.path |
| 75 |
|
|
| 76 |
|
expect(path) == None |
| 77 |
|
|
| 78 |
|
def describe_default_path(): |
| 79 |
|
|
|
@@ 133-148 (lines=16) @@
|
| 130 |
|
|
| 131 |
|
expect(template.validate_meta()) == False |
| 132 |
|
|
| 133 |
|
def describe_validate_link(): |
| 134 |
|
|
| 135 |
|
def with_bad_link(template): |
| 136 |
|
mock_response = Mock() |
| 137 |
|
mock_response.status_code = 404 |
| 138 |
|
|
| 139 |
|
with patch('requests.get', Mock(return_value=mock_response)): |
| 140 |
|
template.link = "example.com/fake" |
| 141 |
|
|
| 142 |
|
expect(template.validate_link()) == False |
| 143 |
|
|
| 144 |
|
@patch('pathlib.Path.is_file', Mock(return_value=True)) |
| 145 |
|
def with_cached_valid_link(template): |
| 146 |
|
template.link = "already_cached_site.com" |
| 147 |
|
|
| 148 |
|
expect(template.validate_link()) == True |
| 149 |
|
|
| 150 |
|
def describe_validate_size(): |
| 151 |
|
|