Skip to content

Commit

Permalink
Merge pull request #212 from CLARIAH/dev
Browse files Browse the repository at this point in the history
Dev changes -- CI testing under windows
  • Loading branch information
c-martinez authored Jul 1, 2019
2 parents 0b516b0 + e94e895 commit 94506d4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
language: objective-c
env: PYENV_VERSION=3.5.2
# command to install dependencies
- stage: Tests
os: windows
language: shell
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
- stage: deploy
# deploy automatically to pypi
before_deploy:
Expand Down
2 changes: 2 additions & 0 deletions .travis/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ fi
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
brew install pyenv
pyenv install -s $PYENV_VERSION
elif [[ $TRAVIS_OS_NAME == 'windows' ]]; then
choco install python
fi
2 changes: 2 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
alias pip=pip3
fi
export PATH="/Users/travis/.pyenv/shims:${PATH}"
elif [[ $TRAVIS_OS_NAME == 'windows' ]]; then
alias pip="pip --user"
fi

if [[ $TRAVIS_BUILD_STAGE_NAME == 'Deploy' ]]; then
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
with codecs.open('requirements-test.txt', mode='r') as f:
tests_require = f.read().splitlines()

with codecs.open('README.md', mode='r') as f:
with codecs.open('README.md', mode='r', encoding='utf-8') as f:
long_description = f.read()

setup(
Expand Down
9 changes: 4 additions & 5 deletions src/fileLoaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, user, repo, sha, prov):
self.gh_repo = gh.get_repo(user + '/' + repo, lazy=False)
except BadCredentialsException:
raise Exception('BadCredentials: have you set up github_access_token on config.ini ?')
except Exception as e:
except Exception:
raise Exception('Repo not found: ' + user + '/' + repo)

def fetchFiles(self):
Expand Down Expand Up @@ -124,12 +124,11 @@ def __init__(self, baseDir=static.LOCAL_SPARQL_DIR):

def fetchFiles(self):
"""Returns a list of file items contained on the local repo."""
print("Fetching files from {}".format(self.baseDir))
files = glob(path.join(self.baseDir, '*'))
filesDef = []
baseDirSlash = path.join(self.baseDir, '')
for f in files:
print("Found SPARQL file {}".format(f))
relative = f.replace(self.baseDir, '')
relative = f.replace(baseDirSlash, '')
filesDef.append({
'download_url': relative,
'name': relative
Expand All @@ -145,7 +144,7 @@ def getTextFor(self, fileItem):
return self._getText(fileItem['download_url'])

def _getText(self, filename):
targetFile = self.baseDir + filename
targetFile = path.join(self.baseDir, filename)
if path.exists(targetFile):
with open(targetFile, 'r') as f:
lines = f.readlines()
Expand Down
6 changes: 3 additions & 3 deletions tests/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os import path
from glob import glob

base_url = 'tests/repo/'
base_url = path.join('tests', 'repo')
def buildEntry(entryName):
entryName = entryName.replace(base_url, '')
return {
Expand All @@ -11,15 +11,15 @@ def buildEntry(entryName):
u'path': entryName,
u'type': u'file'
}
mock_files = [ buildEntry(f) for f in glob(base_url + '*') ]
mock_files = [ buildEntry(f) for f in glob(path.join(base_url, '*')) ]

def mock_requestsGithub(uri, headers={}, params={}):
if uri.endswith('contents'):
return_value = Mock(ok=True)
return_value.json.return_value = mock_files
return return_value
else:
targetFile = uri.replace('https://raw.githubusercontent.com/fakeuser/fakerepo/master/', base_url)
targetFile = uri.replace('https://raw.githubusercontent.com/fakeuser/fakerepo/master/', path.join(base_url, ''))
if path.exists(targetFile):
f = open(targetFile, 'r')
lines = f.readlines()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_loaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import six
from mock import patch
from os import path

from grlc.fileLoaders import LocalLoader, GithubLoader
from grlc.queryTypes import qType
Expand Down Expand Up @@ -77,7 +78,7 @@ def test_getTextForName(self):
class TestLocalLoader(unittest.TestCase):
@classmethod
def setUpClass(self):
self.loader = LocalLoader('./tests/repo/')
self.loader = LocalLoader(path.join('tests', 'repo'))

def test_fetchFiles(self):
files = self.loader.fetchFiles()
Expand Down

0 comments on commit 94506d4

Please sign in to comment.