From d4d2ea0c87affb27a952c800de9226ec8a5c57a8 Mon Sep 17 00:00:00 2001 From: Skom Erik Date: Wed, 14 Feb 2024 21:39:39 +0300 Subject: [PATCH] [HW-#1.2] Style fixes and python version decrement --- .github/workflows/test.yml | 8 ++++---- project/hw1/task.py | 11 +++++++---- tests/test_hw1_task.py | 30 ++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e33ac8b31..38d22c5f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,14 +7,14 @@ jobs: tests: runs-on: ubuntu-latest steps: - - name: Set up Python 3.10 - uses: actions/setup-python@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.8" - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt - name: Test with pytest run: | - python ./scripts/run_tests.py \ No newline at end of file + python ./scripts/run_tests.py diff --git a/project/hw1/task.py b/project/hw1/task.py index b35af446f..21cf3c058 100644 --- a/project/hw1/task.py +++ b/project/hw1/task.py @@ -6,11 +6,14 @@ def getGraphInfoByName(graphName: str): graph_csv = cfpq_data.download(graphName) graph = cfpq_data.graph_from_csv(graph_csv) - return graph.number_of_nodes(),\ - graph.number_of_edges(),\ - set(map(lambda x: x[2]['label'], graph.edges(data=True))) + return ( + graph.number_of_nodes(), + graph.number_of_edges(), + set(map(lambda x: x[2]["label"], graph.edges(data=True))), + ) + def createBiSycleGraph(cSize1: int, cSize2: int, labels: set[str], path: str): graph = labeled_two_cycles_graph(n=cSize1, m=cSize2, labels=labels) print(path) - write_dot(graph, path) \ No newline at end of file + write_dot(graph, path) diff --git a/tests/test_hw1_task.py b/tests/test_hw1_task.py index e12ca46ba..63f2c8e56 100644 --- a/tests/test_hw1_task.py +++ b/tests/test_hw1_task.py @@ -1,24 +1,34 @@ import pytest from tempfile import NamedTemporaryFile -from project.hw1.task import ( - createBiSycleGraph, - getGraphInfoByName -) +from project.hw1.task import createBiSycleGraph, getGraphInfoByName + def test_get_graph_info_by_bzip_name(): nodes, edge, labels = getGraphInfoByName("bzip") assert nodes == 632 assert edge == 556 - assert labels == {'a', 'd'} + assert labels == {"a", "d"} + def test_get_graph_info_by_biomedical_name(): nodes, edge, labels = getGraphInfoByName("biomedical") assert nodes == 341 assert edge == 459 - assert labels == {'type', 'label', 'subClassOf', 'comment', 'versionInfo', - 'title', 'language', 'publisher', 'description', 'creator'} - + assert labels == { + "type", + "label", + "subClassOf", + "comment", + "versionInfo", + "title", + "language", + "publisher", + "description", + "creator", + } + + def test_create_bisycle_graph(): target = ["digraph {"] for i in [1, 2, 3, 0]: @@ -33,6 +43,6 @@ def test_create_bisycle_graph(): target.append("") with NamedTemporaryFile("w+") as tmp: - createBiSycleGraph(3, 5, ('a', 'b'), tmp.name) + createBiSycleGraph(3, 5, ("a", "b"), tmp.name) result = tmp.read() - assert result == "\n".join(target) \ No newline at end of file + assert result == "\n".join(target)