Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Store repo configs in subdirectories named after each repo's org
Browse files Browse the repository at this point in the history
  • Loading branch information
davidalber committed Dec 4, 2018
1 parent f3e7ac2 commit 8babdb6
Show file tree
Hide file tree
Showing 22 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /highfive

COPY setup.py .
COPY highfive/*.py highfive/
COPY highfive/configs/* highfive/configs/
COPY highfive/configs/ highfive/configs/
RUN python setup.py install
RUN touch highfive/config
RUN chown -R www-data:www-data .
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions highfive/newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def __init__(self, payload):

def load_repo_config(self):
'''Load the repository configuration.'''
repo = self.payload['repository', 'name']
(org, repo) = self.payload['repository', 'full_name'].split('/')
try:
return self._load_json_file(repo + '.json')
return self._load_json_file(os.path.join(org, repo) + '.json')
except IOError:
raise UnsupportedRepoError

Expand Down
13 changes: 9 additions & 4 deletions highfive/tests/test_newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from highfive.tests.fakes import load_fake
import json
import mock
import os
import pytest
from urllib2 import HTTPError

Expand Down Expand Up @@ -77,25 +78,29 @@ def test_load_repo_config_supported(self, mock_load_json_file):
mock_load_json_file.return_value = {'a': 'config!'}
payload = Payload({
'action': 'opened',
'repository': {'name': 'blah'}
'repository': {'full_name': 'foo/blah'}
})
m = HighfiveHandlerMock(payload)
m.stop_patchers()
assert m.handler.load_repo_config() == {'a': 'config!'}
mock_load_json_file.assert_called_once_with('blah.json')
mock_load_json_file.assert_called_once_with(
os.path.join('foo', 'blah.json')
)

@mock.patch('highfive.newpr.HighfiveHandler._load_json_file')
def test_load_repo_config_unsupported(self, mock_load_json_file):
mock_load_json_file.side_effect = IOError
payload = Payload({
'action': 'created',
'repository': {'name': 'blah'}
'repository': {'full_name': 'foo/blah'}
})
m = HighfiveHandlerMock(payload)
m.stop_patchers()
with pytest.raises(newpr.UnsupportedRepoError):
m.handler.load_repo_config()
mock_load_json_file.assert_called_once_with('blah.json')
mock_load_json_file.assert_called_once_with(
os.path.join('foo', 'blah.json')
)

class TestNewPRGeneral(TestNewPR):
def test_welcome_msg(self):
Expand Down

0 comments on commit 8babdb6

Please sign in to comment.