From d660da3b7f5c1ac9f3623976d2417836da5f93d7 Mon Sep 17 00:00:00 2001 From: Charles Antoine NOURY Date: Tue, 22 Nov 2022 16:52:17 +0100 Subject: [PATCH 01/16] [rules] added a try except --- src/rules.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rules.py b/src/rules.py index f53a32e..05e20d7 100644 --- a/src/rules.py +++ b/src/rules.py @@ -12,12 +12,12 @@ class Rules: Output: correct -> Bool: if True, the board size is correct """ - correct = True + correct = False - if not self.nb_col == board.nb_col: - correct = False - - if not self.nb_row == board.nb_row: - correct = False + try: + if self.nb_col == board.nb_col and self.nb_row == board.nb_row : + correct = True + except Exception: + print("Exception: check_board_size: col and row parameters might are compared to another type") return correct From 18da1f2043b727eb0e72d05e3e33a2a06fa0056a Mon Sep 17 00:00:00 2001 From: Guillaume MOUGEOT Date: Tue, 22 Nov 2022 16:52:24 +0100 Subject: [PATCH 02/16] test --- __init__.py | 1 + test/player_ut.py => player_ut.py | 8 +++++--- src/__init__.py | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) rename test/player_ut.py => player_ut.py (71%) diff --git a/__init__.py b/__init__.py index e69de29..4cf83ae 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +__all__ = ['src/player'] \ No newline at end of file diff --git a/test/player_ut.py b/player_ut.py similarity index 71% rename from test/player_ut.py rename to player_ut.py index 4b99a1d..951549b 100644 --- a/test/player_ut.py +++ b/player_ut.py @@ -1,9 +1,10 @@ import unittest -from parametrized import parametrized +from parameterized import parameterized from src.player import Players +# from player import Players class TestPlayer(unittest.TestCase): - @parametrized.expand([ + @parameterized.expand([ ("joe", "jonny", True), (1, "jonny", False), ("joe", 15, False), @@ -11,8 +12,9 @@ class TestPlayer(unittest.TestCase): def testString(self, name1, name2, no_exception): try: players = Players(name1=name1, name2=name2) + self.assertTrue(no_exception) except: self.assertFalse(no_exception) if __name__=='__main__': - test_player = TestPlayer() \ No newline at end of file + unittest.main() \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py index e69de29..c54c549 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -0,0 +1 @@ +__all__ = ['player'] \ No newline at end of file From 8113c657a82e875d914fc71d1487cd7c63871f7b Mon Sep 17 00:00:00 2001 From: Charles Antoine NOURY Date: Tue, 22 Nov 2022 16:52:31 +0100 Subject: [PATCH 03/16] [UT; rules] added a test --- test/rules_ut.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/rules_ut.py diff --git a/test/rules_ut.py b/test/rules_ut.py new file mode 100644 index 0000000..29578f6 --- /dev/null +++ b/test/rules_ut.py @@ -0,0 +1,25 @@ +import unittest +from parametrized import parametrized + +from src.rules import Rules + +class TestRules(unittest.TestCase): + @parameterized([ + ('Joe', 7, 6, True), + ('Joe', 10, 10, False), + ('Joe', '7', '6', False), + ('Joe', 7, '1', False), + ('Joe', '1', 6, False), + ]) + def test_check_board_size(self, name, col, row, no_exception=False): + Rules rules + Board board(name, col, row) + + if no_exception: + try: + rules.check_board_sizes(board) + except Exception: + self.assertEqual(no_exception, False) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From e314a81e697ed51ffadccf7486a71ee04f4fb43f Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:13:45 +0100 Subject: [PATCH 04/16] blabla --- rules_ut.py | 25 +++++++++++++++++++++++++ src/rules.py | 36 +++++++++++++++++++----------------- test/rules_ut.py | 25 ------------------------- 3 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 rules_ut.py delete mode 100644 test/rules_ut.py diff --git a/rules_ut.py b/rules_ut.py new file mode 100644 index 0000000..1ca3293 --- /dev/null +++ b/rules_ut.py @@ -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() \ No newline at end of file diff --git a/src/rules.py b/src/rules.py index 05e20d7..0dd0475 100644 --- a/src/rules.py +++ b/src/rules.py @@ -1,23 +1,25 @@ +from src.board import Board + class Rules: def __init__(self): - self.name = None - self.nb_row = None - self.nb_col = None - def check_board_size(self, board: Board) -> Bool: - """ 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 + self.nb_row = 6 + self.nb_col = 7 - try: - if self.nb_col == board.nb_col and self.nb_row == board.nb_row : - correct = True - except Exception: - print("Exception: check_board_size: col and row parameters might are compared to another type") + 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 diff --git a/test/rules_ut.py b/test/rules_ut.py deleted file mode 100644 index 29578f6..0000000 --- a/test/rules_ut.py +++ /dev/null @@ -1,25 +0,0 @@ -import unittest -from parametrized import parametrized - -from src.rules import Rules - -class TestRules(unittest.TestCase): - @parameterized([ - ('Joe', 7, 6, True), - ('Joe', 10, 10, False), - ('Joe', '7', '6', False), - ('Joe', 7, '1', False), - ('Joe', '1', 6, False), - ]) - def test_check_board_size(self, name, col, row, no_exception=False): - Rules rules - Board board(name, col, row) - - if no_exception: - try: - rules.check_board_sizes(board) - except Exception: - self.assertEqual(no_exception, False) - -if __name__ == "__main__": - unittest.main() \ No newline at end of file From 06c107f6606cb18eb28e13726adc6e96938ab427 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:18:31 +0100 Subject: [PATCH 05/16] added .drone.yml --- .drone.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a273105 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,15 @@ +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 + + \ No newline at end of file From 50e083e4b84887c59714b655d063886912f9da5c Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:19:32 +0100 Subject: [PATCH 06/16] etst --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index a273105..583fd99 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,4 +12,6 @@ steps: - pip install parameterized - python -m unittest discover -v -p *_ut.py + + \ No newline at end of file From 85060fee9e273e9cb52c95879344ff159f9a9dbf Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:21:18 +0100 Subject: [PATCH 07/16] etst --- player_ut.py => test/player_ut.py | 2 +- rules_ut.py => test/rules_ut.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename player_ut.py => test/player_ut.py (90%) rename rules_ut.py => test/rules_ut.py (82%) diff --git a/player_ut.py b/test/player_ut.py similarity index 90% rename from player_ut.py rename to test/player_ut.py index 951549b..b605286 100644 --- a/player_ut.py +++ b/test/player_ut.py @@ -1,6 +1,6 @@ import unittest from parameterized import parameterized -from src.player import Players +from ..src.player import Players # from player import Players class TestPlayer(unittest.TestCase): diff --git a/rules_ut.py b/test/rules_ut.py similarity index 82% rename from rules_ut.py rename to test/rules_ut.py index 1ca3293..2346a46 100644 --- a/rules_ut.py +++ b/test/rules_ut.py @@ -1,8 +1,8 @@ import unittest from parameterized import parameterized -from src.rules import Rules -from src.board import Board +from ..src.rules import Rules +from ..src.board import Board class TestRules(unittest.TestCase): @parameterized.expand([ From d765f9ca564be0697fc01d7fdef09e118a2bf278 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:22:40 +0100 Subject: [PATCH 08/16] etst --- __init__.py => connect4/__init__.py | 0 {src => connect4/src}/__init__.py | 0 {src => connect4/src}/board.py | 0 {src => connect4/src}/player.py | 0 {src => connect4/src}/rules.py | 0 {test => connect4/test}/__init__.py | 0 {test => connect4/test}/player_ut.py | 0 {test => connect4/test}/rules_ut.py | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename __init__.py => connect4/__init__.py (100%) rename {src => connect4/src}/__init__.py (100%) rename {src => connect4/src}/board.py (100%) rename {src => connect4/src}/player.py (100%) rename {src => connect4/src}/rules.py (100%) rename {test => connect4/test}/__init__.py (100%) rename {test => connect4/test}/player_ut.py (100%) rename {test => connect4/test}/rules_ut.py (100%) diff --git a/__init__.py b/connect4/__init__.py similarity index 100% rename from __init__.py rename to connect4/__init__.py diff --git a/src/__init__.py b/connect4/src/__init__.py similarity index 100% rename from src/__init__.py rename to connect4/src/__init__.py diff --git a/src/board.py b/connect4/src/board.py similarity index 100% rename from src/board.py rename to connect4/src/board.py diff --git a/src/player.py b/connect4/src/player.py similarity index 100% rename from src/player.py rename to connect4/src/player.py diff --git a/src/rules.py b/connect4/src/rules.py similarity index 100% rename from src/rules.py rename to connect4/src/rules.py diff --git a/test/__init__.py b/connect4/test/__init__.py similarity index 100% rename from test/__init__.py rename to connect4/test/__init__.py diff --git a/test/player_ut.py b/connect4/test/player_ut.py similarity index 100% rename from test/player_ut.py rename to connect4/test/player_ut.py diff --git a/test/rules_ut.py b/connect4/test/rules_ut.py similarity index 100% rename from test/rules_ut.py rename to connect4/test/rules_ut.py From 3a5d67f3c9cfb2cdc874bbb9e01b8c05dfe3f298 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:23:56 +0100 Subject: [PATCH 09/16] correct --- connect4/src/rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connect4/src/rules.py b/connect4/src/rules.py index 0dd0475..411658d 100644 --- a/connect4/src/rules.py +++ b/connect4/src/rules.py @@ -1,4 +1,4 @@ -from src.board import Board +from board import Board class Rules: def __init__(self): From 1e6d8fd23d753911c92dc32f27bf284e0d75c526 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:25:17 +0100 Subject: [PATCH 10/16] correct --- connect4/src/rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connect4/src/rules.py b/connect4/src/rules.py index 411658d..1c3ad19 100644 --- a/connect4/src/rules.py +++ b/connect4/src/rules.py @@ -1,4 +1,4 @@ -from board import Board +from connect4.src.board import Board class Rules: def __init__(self): From 4f8cd3f6a54ac92355840b4dbadb8f617165c9b8 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:30:50 +0100 Subject: [PATCH 11/16] sonar --- .drone.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 583fd99..5547461 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,32 @@ steps: 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: pubhub.codefirst.ddns.net/thbellem/codefirst-dronesonarplugin-python37 + commands: + #- pip install nose + #- pip install coverage + #- pip install parameterized + #- nosetests --with-coverage --cover-branches --cover-xml + - nosetests connect4/tests/*_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.ddns.net/sonar/ + # accessible en ligne de commande par $${PLUGIN_SONAR_TOKEN} + sonar_token: + from_secret: SECRET_SONAR_LOGIN + sonar.python.version: 3 + + \ No newline at end of file From 5461ed3f03d50a72a31d3e14049525d9518c7078 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:30:56 +0100 Subject: [PATCH 12/16] sonar --- sonar-project.properties | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..303bbbb --- /dev/null +++ b/sonar-project.properties @@ -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" \ No newline at end of file From f3eb2bd3fde3fb0707620552a94bf438fe5d82ff Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:33:26 +0100 Subject: [PATCH 13/16] sonar --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5547461..abda349 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,7 +21,7 @@ steps: #- pip install coverage #- pip install parameterized #- nosetests --with-coverage --cover-branches --cover-xml - - nosetests connect4/tests/*_ut.py --with-coverage --cover-branches --cover-xml + - nosetests connect4/test/*_ut.py --with-coverage --cover-branches --cover-xml #- cat coverage.xml #- export #- env @@ -31,7 +31,7 @@ steps: - /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.ddns.net/sonar/ + sonar_host: https://codefirst.iut.uca.fr/sonar/ # accessible en ligne de commande par $${PLUGIN_SONAR_TOKEN} sonar_token: from_secret: SECRET_SONAR_LOGIN From 253f12152f79a174e6f8c74f3f974b497a0d5024 Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:34:27 +0100 Subject: [PATCH 14/16] sonar --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index abda349..5481223 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: - name: code-analysis #image: aosapps/drone-sonar-plugin:latest #image: python:3.7 - image: pubhub.codefirst.ddns.net/thbellem/codefirst-dronesonarplugin-python37 + image: pubhub.codefirst.iut.uca.fr/thbellem/codefirst-dronesonarplugin-python37 commands: #- pip install nose #- pip install coverage From 419df2a18a02f5b137dbc341ce9b0c4c9524884e Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:35:12 +0100 Subject: [PATCH 15/16] sonar --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5481223..d334213 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: - name: code-analysis #image: aosapps/drone-sonar-plugin:latest #image: python:3.7 - image: pubhub.codefirst.iut.uca.fr/thbellem/codefirst-dronesonarplugin-python37 + image: pubhub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-python37 commands: #- pip install nose #- pip install coverage From c2e2970fdefe6dafc35efb57ee8d63b0cff28aab Mon Sep 17 00:00:00 2001 From: Julien HAUTOT Date: Tue, 22 Nov 2022 17:35:56 +0100 Subject: [PATCH 16/16] sonar --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d334213..0cadc27 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: - name: code-analysis #image: aosapps/drone-sonar-plugin:latest #image: python:3.7 - image: pubhub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-python37 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-python37 commands: #- pip install nose #- pip install coverage