Skip to content

Commit 73fa64b

Browse files
committed
update demo-assignments
1 parent 566b77f commit 73fa64b

File tree

14 files changed

+114
-726
lines changed

14 files changed

+114
-726
lines changed

demo-assignments/A1-OOP/cold/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525

2626
.PHONY: run-test-coverage
2727
run-test-coverage: create-doc-folder
28-
pytest --verbose --color=yes --cov --cov-report term-missing --cov-report=html:$(DOCS)/test-cov tests/
28+
pytest --verbose --color=yes --cov --cov-report term-missing --cov-report=html:$(DOCS)/htmlcov tests/
2929
@echo "All unittests passed!"
3030

3131
.PHONY: check-types
@@ -57,6 +57,7 @@ endif
5757
ifeq ($(wildcard ~/plantuml.jar), )
5858
@echo "Downloading plantuml.jar in home folder..."
5959
curl -L -o ~/plantuml.jar https://sourceforge.net/projects/plantuml/files/plantuml.jar/download
60+
sudo apt install graphviz
6061
endif
6162
$(PLANTUML) ./uml/temperature.plantuml
6263
$(PLANTUML) ./uml/solution.plantuml

demo-assignments/A1-OOP/cold/cold_singleton.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class Solution():
2525
_instance: "Solution" | None = None
2626

2727
def __new__(cls) -> "Solution":
28+
"""Creates a new instance of the class if not already created.
29+
30+
Enforces Singleton pattern.
31+
32+
Returns:
33+
Solution: class instance
34+
"""
2835
if cls._instance is None:
2936
cls._instance = super().__new__(cls)
3037
return cls._instance
2.49 KB
Loading

demo-assignments/A1-OOP/cold/uml/temperature.plantuml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Temperature {
66
.. Instance Variables ..
77
- _temp: int
88
- _unit: str
9+
- attribute: float
910
+ temp: int {get; set;}
1011
+ unit: str {get; set;}
1112
.. Overloaded Methods ..

demo-assignments/A2-ABC/egypt/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ check-types:
1919

2020
.PHONY: unittest
2121
unittest:
22-
pytest --verbose --color=yes --cov --cov-report term --cov-report html tests/
22+
pytest --verbose --color=yes --cov --cov-report term-missing --cov-report html tests/
2323
@echo "Unittest done."
2424

2525
.PHONY: create-uml
@@ -41,8 +41,7 @@ endif
4141

4242
.PHONY: cleanall
4343
localtest:
44-
kattis test -m egypt_abc.py
45-
kattis test -m egypt_singleton.py
44+
kattis test -m egypt.py
4645
@echo "Local kattis sample data test done."
4746

4847

demo-assignments/A2-ABC/egypt/egypt_abc.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

demo-assignments/A2-ABC/egypt/egypt_singleton.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

demo-assignments/A2-ABC/egypt/tests/test_egypt_singleton.py renamed to demo-assignments/A2-ABC/egypt/tests/test_egypt.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
import unittest
1515
from unittest.mock import patch
1616
from io import StringIO
17-
from egypt_singleton import Solution
17+
from egypt import Solution
1818

1919

2020
class TestSolution(unittest.TestCase):
2121
"""Unittesting Solution class
2222
"""
2323

24-
def tearDown(self) -> None:
25-
return super().tearDown()
26-
2724
@patch('sys.stdout', new_callable=StringIO)
2825
def test_solve1(self, mock_stdout: StringIO) -> None:
2926
"""Tests solve method
@@ -38,7 +35,6 @@ def test_solve1(self, mock_stdout: StringIO) -> None:
3835
output_file = path.join(dir_path, '1.ans')
3936
with open(output_file, 'r', encoding='utf-8') as expected:
4037
self.assertEqual(mock_stdout.getvalue(), expected.read())
41-
# Solution.reset_instance()
4238

4339
@patch('sys.stdout', new_callable=StringIO)
4440
def test_solve2(self, mock_stdout: StringIO) -> None:
@@ -52,7 +48,6 @@ def test_solve2(self, mock_stdout: StringIO) -> None:
5248
sol.print_answer()
5349
expected: str = 'right\nwrong\nright\n'
5450
self.assertEqual(mock_stdout.getvalue(), expected)
55-
# Solution.reset_instance()
5651

5752
@patch('sys.stdout', new_callable=StringIO)
5853
def test_solve3(self, mock_stdout: StringIO) -> None:
@@ -66,7 +61,6 @@ def test_solve3(self, mock_stdout: StringIO) -> None:
6661
sol.print_answer()
6762
expected: str = 'wrong\nwrong\nwrong\nright\n'
6863
self.assertEqual(mock_stdout.getvalue(), expected)
69-
# Solution.reset_instance()
7064

7165
def test_solve4(self) -> None:
7266
"""Tests solve method
@@ -77,7 +71,6 @@ def test_solve4(self) -> None:
7771
sol.solve()
7872
expected: str = 'wrong\nwrong\nwrong\nright\n'
7973
self.assertEqual(sol.answer, expected)
80-
# Solution.reset_instance()
8174

8275
@patch('sys.stdout', new_callable=StringIO)
8376
def test_main(self, mock_stdout: StringIO) -> None:
@@ -99,7 +92,7 @@ def test_data(self) -> None:
9992
sol.data, [[2, 3, 4], [20, 50, 62], [3, 4, 7]])
10093

10194
def test_singleton(self) -> None:
102-
"""Tests get_instance method
95+
"""Singleton pattern test
10396
"""
10497
data1 = '2 3 4\n20 50 62\n3 4 7\n0 0 0\n'
10598
data2 = '20 30 40\n200 500 620\n30 40 70\n0 0 0\n'

0 commit comments

Comments
 (0)