forked from thomas.barbier/connect4
commit
267eb0cd9f
@ -0,0 +1,42 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: testPythonconnect4
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
steps:
|
||||
- name: test
|
||||
image: python:3.7
|
||||
commands:
|
||||
- pip install parameterized
|
||||
- python -m unittest discover -v -p *_ut.py
|
||||
|
||||
- name: code-analysis
|
||||
#image: aosapps/drone-sonar-plugin:latest
|
||||
#image: python:3.7
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-python37
|
||||
commands:
|
||||
#- pip install nose
|
||||
#- pip install coverage
|
||||
#- pip install parameterized
|
||||
#- nosetests --with-coverage --cover-branches --cover-xml
|
||||
- nosetests connect4/test/*_ut.py --with-coverage --cover-branches --cover-xml
|
||||
#- cat coverage.xml
|
||||
#- export
|
||||
#- env
|
||||
#- echo $PLUGIN_SONAR_TOKEN
|
||||
#- sed -i 's/filename="/filename=".\//g' coverage-reports/coverage-test.xml
|
||||
#- sonar-runner
|
||||
- /opt/sonar-scanner/bin/sonar-scanner -Dsonar.login=$PLUGIN_SONAR_TOKEN
|
||||
settings:
|
||||
# accessible en ligne de commande par $${PLUGIN_SONAR_HOST}
|
||||
sonar_host: https://codefirst.iut.uca.fr/sonar/
|
||||
# accessible en ligne de commande par $${PLUGIN_SONAR_TOKEN}
|
||||
sonar_token:
|
||||
from_secret: SECRET_SONAR_LOGIN
|
||||
sonar.python.version: 3
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
__all__ = ['src/player']
|
@ -0,0 +1 @@
|
||||
__all__ = ['player']
|
@ -0,0 +1,25 @@
|
||||
from connect4.src.board import Board
|
||||
|
||||
class Rules:
|
||||
def __init__(self):
|
||||
|
||||
self.nb_row = 6
|
||||
self.nb_col = 7
|
||||
|
||||
def check_board_size(self, board):
|
||||
""" Checks if the board size is correct.
|
||||
Entries:
|
||||
self: the Rules class itself
|
||||
board -> Board: a board
|
||||
Output:
|
||||
correct -> Bool: if True, the board size is correct
|
||||
"""
|
||||
correct = False
|
||||
|
||||
|
||||
if self.nb_col == board.nbcol and self.nb_row == board.nbrow :
|
||||
correct = True
|
||||
else:
|
||||
correct = False
|
||||
|
||||
return correct
|
@ -0,0 +1,25 @@
|
||||
import unittest
|
||||
from parameterized import parameterized
|
||||
|
||||
from ..src.rules import Rules
|
||||
from ..src.board import Board
|
||||
|
||||
class TestRules(unittest.TestCase):
|
||||
@parameterized.expand([
|
||||
(6, 7, True),
|
||||
(10, 10, False),
|
||||
('6', '7', False),
|
||||
(7, '1', False),
|
||||
('1', 6, False),
|
||||
])
|
||||
def test_check_board_size(self, row, col, no_exception):
|
||||
rules = Rules()
|
||||
board = Board(row, col)
|
||||
|
||||
if no_exception:
|
||||
self.assertTrue(rules.check_board_size(board))
|
||||
else:
|
||||
self.assertFalse(rules.check_board_size(board))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -0,0 +1,11 @@
|
||||
sonar.projectKey=connect4
|
||||
sonar.projectName=Connect4 Workshop
|
||||
sonar.projectVersion=1.0
|
||||
sonar.sources=connect4/src
|
||||
sonar.tests=connect4/test
|
||||
sonar.language=py
|
||||
sonar.sourceEncoding=UTF-8
|
||||
sonar.python.xunit.reportPath=nosetests.xml
|
||||
sonar.python.coverage.reportPath=coverage.xml
|
||||
sonar.python.coveragePlugin=cobertura
|
||||
# sonar.inclusions="*_ut.py"
|
Loading…
Reference in new issue