Skip to content

Commit

Permalink
Only validate links during CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 29, 2017
1 parent 0b92668 commit 0264a98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -10,6 +10,7 @@ cache:
env:
global:
- RANDOM_SEED=12345
- VALIDATE_LINKS=true

install:
- pip install coveralls scrutinizer-ocular
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -104,8 +104,9 @@ doctor: ## Confirm system dependencies are available

.env:
echo "FLASK_CONFIG=dev" >> $@
echo "#REGENERATE_IMAGES=true" >> $@
echo "GOOGLE_ANALYTICS_TID=local" >> $@
echo "#REGENERATE_IMAGES=true" >> $@
echo "#VALIDATE_LINKS=true" >> $@

# PROJECT DEPENDENCIES #########################################################

Expand Down
3 changes: 3 additions & 0 deletions memegen/domain/template.py
Expand Up @@ -166,6 +166,9 @@ def validate_meta(self):
return True

def validate_link(self, delay=3):
if not os.getenv('VALIDATE_LINKS'):
log.warning("Link validation skipped ('VALIDATE_LINKS' unset)")
return True
if self.link:
flag = Path(self.dirpath, self.VALID_LINK_FLAG)
if flag.is_file():
Expand Down
4 changes: 4 additions & 0 deletions memegen/tests/test_domain_template.py
Expand Up @@ -144,6 +144,10 @@ def with_nonalphanumberic_name(template):

def describe_validate_link():

@pytest.fixture(autouse=True)
def enable_validation(monkeypatch):
monkeypatch.setenv('VALIDATE_LINKS', "true")

def with_bad_link(template):
mock_response = Mock()
mock_response.status_code = 404
Expand Down

0 comments on commit 0264a98

Please sign in to comment.