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