Skip to content

Commit be32fc5

Browse files
make tests work
1 parent 08a9625 commit be32fc5

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

.github/workflows/validate.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python package
1+
name: Check code
22

33
on:
44
push:
@@ -16,21 +16,18 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Set up Python ${{ matrix.python-version }}
19+
- name: install python
2020
uses: actions/setup-python@v2
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
- name: Install dependencies
23+
- name: install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
python -m pip install flake8 nose
26+
python -m pip install flake8 nose coverage
2727
pip install -r requirements.txt
28-
- name: Lint with flake8
28+
- name: lint
2929
run: |
30-
# stop the build if there are Python syntax errors or undefined names
31-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34-
- name: Test with nose
30+
make lint
31+
- name: test
3532
run: |
36-
nosetests -v --with-coverage --cover-package=python-gitlab-submodule tests
33+
make test

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PROJECT = gitlab_submodule
2+
3+
lint:
4+
flake8 $(PROJECT) --count --show-source --statistics
5+
6+
test:
7+
nosetests -v --with-coverage --cover-package=$(PROJECT) tests

gitlab_submodule/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
__all__ = [
66
'Submodule', 'Subproject',
77
'list_submodules',
8+
'iterate_submodules',
89
'submodule_to_subproject',
910
'iterate_subprojects', 'list_subprojects'
1011
]
1112

1213
from gitlab_submodule.objects import Submodule, Subproject
14+
from gitlab_submodule.read_gitmodules import (
15+
list_project_submodules as list_submodules)
1316
from gitlab_submodule.gitlab_submodule import (
14-
list_submodules,
17+
iterate_submodules,
1518
submodule_to_subproject,
1619
iterate_subprojects,
1720
list_subprojects,

gitlab_submodule/gitlab_submodule.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
from gitlab.v4.objects import Project, ProjectManager
55

66
from gitlab_submodule.objects import Submodule, Subproject
7-
from gitlab_submodule.read_gitmodules import list_project_submodules, iterate_project_submodules
7+
from gitlab_submodule.read_gitmodules import (
8+
iterate_project_submodules as iterate_submodules)
89
from gitlab_submodule.submodule_to_project import submodule_to_project
910
from gitlab_submodule.submodule_commit import get_submodule_commit
1011

1112

12-
list_submodules = list_project_submodules
13-
iterate_submodules = iterate_project_submodules
14-
15-
1613
def _get_project_manager(
1714
gitlab_object: Union[Gitlab, ProjectManager]) -> ProjectManager:
1815
if isinstance(gitlab_object, ProjectManager):
@@ -51,7 +48,7 @@ def iterate_subprojects(
5148
get_latest_commit_possible_if_not_found: bool = False,
5249
get_latest_commit_possible_ref: Optional[str] = None
5350
) -> Generator[Subproject, None, None]:
54-
for gitmodules_submodule in iterate_project_submodules(project, ref):
51+
for gitmodules_submodule in iterate_submodules(project, ref):
5552
try:
5653
yield submodule_to_subproject(
5754
gitmodules_submodule,

tests/test_gitlab_submodule.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from gitlab import Gitlab
44

55
from gitlab_submodule.objects import Subproject
6-
from gitlab_submodule.gitlab_submodule import (list_submodules,
6+
from gitlab_submodule.gitlab_submodule import (iterate_submodules,
77
submodule_to_subproject,
88
list_subprojects)
99

@@ -14,11 +14,16 @@ def test_read_inkscape_subproject(self):
1414

1515
gl = Gitlab()
1616
inkscape = gl.projects.get('inkscape/inkscape')
17-
submodules = list_submodules(
17+
submodules = iterate_submodules(
1818
inkscape,
1919
ref='e371b2f826adcba316f2e64bbf2f697043373d0b')
20-
submodule = [sub for sub in submodules if
21-
sub.url == 'https://gitlab.com/inkscape/lib2geom.git'][0]
20+
submodule = None
21+
for sub in submodules:
22+
if sub.url == 'https://gitlab.com/inkscape/lib2geom.git':
23+
submodule = sub
24+
break
25+
self.assertIsNotNone(submodule)
26+
2227
submodule_info: Subproject = submodule_to_subproject(submodule, gl)
2328
self.assertEqual(submodule_info.submodule, submodule)
2429

0 commit comments

Comments
 (0)