Move test/ to tests/ (#17)

This PR includes:
- Migrate test/ to tests/
- Remove codecov (use the organization's default)
This commit is contained in:
Dag Wieers 2020-04-01 12:42:04 +02:00 committed by GitHub
parent 6e9a4718fe
commit fa90644f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 29 additions and 45 deletions

4
.gitattributes vendored
View File

@ -1,10 +1,8 @@
.github/ export-ignore .github/ export-ignore
test/ export-ignore tests/ export-ignore
.coverage export-ignore
.gitattributes export-ignore .gitattributes export-ignore
.gitignore export-ignore .gitignore export-ignore
.pylintrc export-ignore .pylintrc export-ignore
codecov.yml export-ignore
Makefile export-ignore Makefile export-ignore
requirements.txt export-ignore requirements.txt export-ignore
tox.ini export-ignore tox.ini export-ignore

View File

@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
PYTHONIOENCODING: utf-8 PYTHONIOENCODING: utf-8
PYTHONPATH: ${{ github.workspace }}/resources/lib:${{ github.workspace }}/test PYTHONPATH: ${{ github.workspace }}/resources/lib:${{ github.workspace }}/tests
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -49,7 +49,7 @@ jobs:
coverage run -m unittest discover coverage run -m unittest discover
- name: Run addon - name: Run addon
run: | run: |
coverage run -a test/run.py / coverage run -a tests/run.py /
- name: Run add-on service - name: Run add-on service
run: | run: |
coverage run -a service_entry.py coverage run -a service_entry.py

14
.gitignore vendored
View File

@ -12,10 +12,10 @@ Thumbs.db
.coverage .coverage
.tox/ .tox/
test/userdata/credentials.json tests/userdata/credentials.json
test/userdata/temp tests/userdata/temp
test/userdata/token.json tests/userdata/token.json
test/userdata/cache tests/userdata/cache
test/userdata/addon_data tests/userdata/addon_data
test/userdata/tokens tests/userdata/tokens
test/cdm tests/cdm

View File

@ -1,4 +1,4 @@
export PYTHONPATH := $(CURDIR):$(CURDIR)/test export PYTHONPATH := $(CURDIR):$(CURDIR)/tests
PYTHON := python PYTHON := python
# Collect information to build as sensible package name # Collect information to build as sensible package name
@ -13,8 +13,6 @@ exclude_files = \*.new \*.orig \*.pyc \*.pyo
languages = $(filter-out en_gb, $(patsubst resources/language/resource.language.%, %, $(wildcard resources/language/*))) languages = $(filter-out en_gb, $(patsubst resources/language/resource.language.%, %, $(wildcard resources/language/*)))
.PHONY: check test
all: check test build all: check test build
zip: build zip: build
@ -22,7 +20,7 @@ check: check-pylint check-tox check-translations
check-pylint: check-pylint:
@echo ">>> Running pylint checks" @echo ">>> Running pylint checks"
@$(PYTHON) -m pylint *.py resources/lib/ test/ @$(PYTHON) -m pylint *.py resources/lib/ tests/
check-tox: check-tox:
@echo ">>> Running tox checks" @echo ">>> Running tox checks"
@ -48,10 +46,9 @@ test-unit:
@$(PYTHON) -m unittest discover -v -b -f @$(PYTHON) -m unittest discover -v -b -f
clean: clean:
@find . -name '*.pyc' -type f -delete @find . -name '*.py[cod]' -type f -delete
@find . -name '*.pyo' -type f -delete
@find . -name '__pycache__' -type d -delete @find . -name '__pycache__' -type d -delete
@rm -rf .pytest_cache/ .tox/ test/cdm test/userdata/temp @rm -rf .pytest_cache/ .tox/ tests/cdm tests/userdata/temp
@rm -f *.log .coverage @rm -f *.log .coverage
build: clean build: clean

View File

@ -1,12 +0,0 @@
coverage:
range: 50..100
round: nearest
status:
project:
default:
target: 75%
threshold: 6%
patch: false
comment: false
ignore:
- "test"

View File

@ -8,6 +8,7 @@ import logging
import os import os
import time import time
from resources.lib import kodiutils
from resources.lib.viervijfzes.auth_awsidp import AwsIdp, InvalidLoginException, AuthenticationException from resources.lib.viervijfzes.auth_awsidp import AwsIdp, InvalidLoginException, AuthenticationException
_LOGGER = logging.getLogger('auth-api') _LOGGER = logging.getLogger('auth-api')

View File

@ -237,11 +237,11 @@ def sleep(seconds):
def translatePath(path): def translatePath(path):
""" A stub implementation of the xbmc translatePath() function """ """ A stub implementation of the xbmc translatePath() function """
if path.startswith('special://home'): if path.startswith('special://home'):
return path.replace('special://home', os.path.join(os.getcwd(), 'test/')) return path.replace('special://home', os.path.join(os.getcwd(), 'tests/'))
if path.startswith('special://masterprofile'): if path.startswith('special://masterprofile'):
return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'test/userdata/')) return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'tests/userdata/'))
if path.startswith('special://profile'): if path.startswith('special://profile'):
return path.replace('special://profile', os.path.join(os.getcwd(), 'test/userdata/')) return path.replace('special://profile', os.path.join(os.getcwd(), 'tests/userdata/'))
if path.startswith('special://userdata'): if path.startswith('special://userdata'):
return path.replace('special://userdata', os.path.join(os.getcwd(), 'test/userdata/')) return path.replace('special://userdata', os.path.join(os.getcwd(), 'tests/userdata/'))
return path return path

View File

@ -60,7 +60,7 @@ class Addon:
"""A stub implementation for the xbmcaddon Addon class setSetting() method""" """A stub implementation for the xbmcaddon Addon class setSetting() method"""
self.settings[key] = value self.settings[key] = value
# NOTE: Disable actual writing as it is no longer needed for testing # NOTE: Disable actual writing as it is no longer needed for testing
# with open('test/userdata/addon_settings.json', 'w') as fd: # with open('tests/userdata/addon_settings.json', 'w') as fd:
# json.dump(filtered_settings, fd, sort_keys=True, indent=4) # json.dump(filtered_settings, fd, sort_keys=True, indent=4)
def setSettingBool(self, key, value): def setSettingBool(self, key, value):

View File

@ -74,10 +74,10 @@ def global_settings():
"""Use the global_settings file""" """Use the global_settings file"""
import json import json
try: try:
with open('test/userdata/global_settings.json') as f: with open('tests/userdata/global_settings.json') as f:
settings = json.load(f) settings = json.load(f)
except OSError as e: except OSError as e:
print("Error: Cannot use 'test/userdata/global_settings.json' : %s" % e) print("Error: Cannot use 'tests/userdata/global_settings.json' : %s" % e)
settings = { settings = {
'locale.language': 'resource.language.en_gb', 'locale.language': 'resource.language.en_gb',
'network.bandwidth': 0, 'network.bandwidth': 0,
@ -104,10 +104,10 @@ def addon_settings(addon_id=None):
"""Use the addon_settings file""" """Use the addon_settings file"""
import json import json
try: try:
with open('test/userdata/addon_settings.json') as f: with open('tests/userdata/addon_settings.json') as f:
settings = json.load(f) settings = json.load(f)
except OSError as e: except OSError as e:
print("Error: Cannot use 'test/userdata/addon_settings.json' : %s" % e) print("Error: Cannot use 'tests/userdata/addon_settings.json' : %s" % e)
settings = {} settings = {}
# Read credentials from environment or credentials.json # Read credentials from environment or credentials.json
@ -115,13 +115,13 @@ def addon_settings(addon_id=None):
# print('Using credentials from the environment variables ADDON_USERNAME and ADDON_PASSWORD') # print('Using credentials from the environment variables ADDON_USERNAME and ADDON_PASSWORD')
settings[ADDON_ID]['username'] = os.environ.get('ADDON_USERNAME') settings[ADDON_ID]['username'] = os.environ.get('ADDON_USERNAME')
settings[ADDON_ID]['password'] = os.environ.get('ADDON_PASSWORD') settings[ADDON_ID]['password'] = os.environ.get('ADDON_PASSWORD')
elif os.path.exists('test/userdata/credentials.json'): elif os.path.exists('tests/userdata/credentials.json'):
# print('Using credentials from test/userdata/credentials.json') # print('Using credentials from tests/userdata/credentials.json')
with open('test/userdata/credentials.json') as f: with open('tests/userdata/credentials.json') as f:
credentials = json.load(f) credentials = json.load(f)
settings[ADDON_ID].update(credentials) settings[ADDON_ID].update(credentials)
else: else:
print("Error: Cannot use 'test/userdata/credentials.json'") print("Error: Cannot use 'tests/userdata/credentials.json'")
if addon_id: if addon_id:
return settings[addon_id] return settings[addon_id]