Skip to content

Feat/tests #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
83aa3ae
Feat: Add some proof-of-concept unit tests
dorianim Apr 8, 2022
2ab4b96
Feat: Add workflow for codecov.io
dorianim Apr 8, 2022
900e0df
Fix: install ldap deps
dorianim Apr 8, 2022
82fc68a
Fix: sudo for apt
dorianim Apr 8, 2022
19250f2
Test: python 3.10
dorianim Apr 8, 2022
ce3988c
Fix: version as string
dorianim Apr 8, 2022
7dfcd83
Fix: coverage.xml path
dorianim Apr 8, 2022
af4d19e
Fix: remove invalid import
dorianim Apr 8, 2022
e5da708
Fix: unneeded vars
dorianim Apr 8, 2022
ee21027
Feat: Add unittest and codecov badge
dorianim Apr 8, 2022
675087b
Fix: url
dorianim Apr 8, 2022
3b004f9
Tests: Add test for computer module
dorianim Apr 9, 2022
d8466b6
Fix: Only split at first =
dorianim Apr 9, 2022
ad65095
Tests: Add tests for environment module
dorianim Apr 9, 2022
960ba14
Refactor: Move gtkBookmarksFile path to constants
dorianim Apr 9, 2022
242a788
Doc: Better error message
dorianim Apr 9, 2022
79e7952
Doc: Add comment
dorianim Apr 9, 2022
edeb65a
Tests: Add tests for user module
dorianim Apr 9, 2022
1208b91
Doc: Update comment
dorianim Apr 9, 2022
b95d885
Doc: More percise comment
dorianim Apr 9, 2022
aeeb44f
Fix: Don't delete folders in delteFile function
dorianim Apr 9, 2022
fd5f1b0
Doc: More precise comment
dorianim Apr 9, 2022
e44813e
Docs: More precise comment
dorianim Apr 9, 2022
bfc1c14
Doc: More precise comment
dorianim Apr 9, 2022
6773c64
Tests: Change naming
dorianim Apr 9, 2022
c1c682c
Tests: Add tests for fileHelper module
dorianim Apr 9, 2022
0be2c86
Tests: ignore tests from coverage
dorianim Apr 9, 2022
c820722
Tests: Ignore tests from coverage
dorianim Apr 9, 2022
6cb79e6
Fix: Move codecove config to right location
dorianim Apr 9, 2022
e50a105
Tests: Try to fix ignore
dorianim Apr 9, 2022
79a2bd0
Refactor: fix better return codes and error handling
dorianim Apr 10, 2022
55a3c75
Tests: Add tests for gpo module
dorianim Apr 10, 2022
423b730
Tests: Add new tests
dorianim Aug 17, 2022
16db20b
Tests: test remote hook execution
dorianim Aug 17, 2022
486d603
Tests: testing of error handling in hooks
dorianim Aug 17, 2022
ace362b
Tests: improove hook tests
dorianim Aug 19, 2022
78ab45c
Tests: Enshure execution order in hooks
dorianim Aug 19, 2022
a56e504
Tests: test with more files
dorianim Aug 19, 2022
b3d0d7c
Merge branch 'master' into feat/tests
dorianim Aug 19, 2022
a579be5
Tests: Add basic test for template
dorianim Aug 19, 2022
f1a28d6
Merge branch 'feat/tests' of github.com:linuxmuster/linuxmuster-linux…
dorianim Aug 19, 2022
8494d4d
Tests: more tests for templates
dorianim Aug 19, 2022
26c6a40
Chore: remove unused imports
dorianim Aug 19, 2022
2192579
Tests: add test for primters.translateSambaToIpp
dorianim Aug 19, 2022
b8ccbd7
Tests: Add test for printers.installPrinter
dorianim Aug 19, 2022
b322caa
Tests: add tests for printers.uninstallAllPrintersOfUser
dorianim Aug 19, 2022
3c669ff
Tests: improove tests for printers.uninstallAllPrintersOfUser
dorianim Aug 19, 2022
04b4c22
Fix: rename test
dorianim Aug 19, 2022
3dbdf53
Chore: remove unused imports
dorianim Aug 19, 2022
bd58f4c
Tests: add tests for logging
dorianim Aug 19, 2022
770a4fa
Chore: remove unused imports
dorianim Aug 19, 2022
08ccae2
Tests: Add tests for realm
dorianim Aug 19, 2022
9a8adc2
Tests: Add more tests for realm
dorianim Aug 19, 2022
89990ae
Merge branch 'master' into feat/tests
dorianim Sep 14, 2022
c4fb2c6
Merge branch 'master' into feat/tests
dorianim Sep 14, 2022
8cad4fe
Chore: remove duplicate code in imageHelper
dorianim Sep 14, 2022
f2c05d2
Chore: handle invalid case
dorianim Sep 14, 2022
b6cfb28
Tests: Add test to shares.getMountpointOfRemotePath
dorianim Sep 14, 2022
cf60b95
Merge branch 'master' into feat/tests
dorianim Jun 16, 2023
e075faf
Chore: trigger CI
dorianim Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore:
- "**/test_*.py"
- "usr/lib/python3/dist-packages/linuxmusterLinuxclient7/tests"
37 changes: 37 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unittests
on: [push]
jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
env:
OS: ${{ matrix.os }}
PYTHON: '3.10'
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: '3.10'
- name: Generate coverage report
run: |
sudo apt-get update
sudo apt-get install build-essential python3-dev \
libldap2-dev libsasl2-dev slapd ldap-utils tox \
lcov valgrind

pip install pytest
pip install pytest-cov
cd ./usr/lib/python3/dist-packages/linuxmusterLinuxclient7
pip install -r requirements.txt

pytest --cov=./ --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./usr/lib/python3/dist-packages/linuxmusterLinuxclient7/coverage.xml
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ debian/linuxmuster-linuxclient7.substvars
debian/linuxmuster-linuxclient7/
__pycache__
/public
venv
.coverage
coverage.xml
.vscode/*.log
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"njpwerner.autodocstring",
"ms-python.python"
"ms-python.python",
"ryanluker.vscode-coverage-gutters"
]
}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ help:
@echo " deb Build debian package"
@echo " docs Build Sphinx documentation"
@echo " clean Remove built files"
@echo " tests Run tests"
@echo " help Show this help"


deb:
dpkg-buildpackage -rfakeroot -tc -sa -us -uc -I".directory" -I".git" -I"buildpackage.sh"
Expand All @@ -13,4 +16,7 @@ docs:
cd docs && sphinx-build . ../public

clean:
rm -r public
rm -r public

tests:
pytest -vv --cov=./ --cov-report=xml
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
<a href="https://www.gnu.org/licenses/agpl-3.0">
<img src="https://img.shields.io/badge/License-AGPL%20v3-blue.svg" />
</a>
<a href="https://github.com/linuxmuster/linuxmuster-linuxclient7/actions/workflows/release.yml">
<img src="https://github.com/linuxmuster/linuxmuster-linuxclient7/workflows/Build%20Release/badge.svg" />
<a href="https://codecov.io/gh/linuxmuster/linuxmuster-linuxclient7">
<img src="https://codecov.io/gh/linuxmuster/linuxmuster-linuxclient7/branch/feat/tests/graph/badge.svg?token=V9XYC91882"/>
</a>
<a href="https://github.com/linuxmuster/linuxmuster-linuxclient7/actions/workflows/unittests.yml">
<img src="https://github.com/linuxmuster/linuxmuster-linuxclient7/actions/workflows/unittests.yml/badge.svg" />
</a>
<a href="https://ask.linuxmuster.net">
<img src="https://img.shields.io/discourse/users?logo=discourse&amp;logoColor=white&amp;server=https%3A%2F%2Fask.linuxmuster.net" alt="Community Forum" />
Expand All @@ -24,9 +27,9 @@
Package for Ubuntu clients to connect to the linuxmuster.net 7 active directory server.
This is the new version of the linuxmuster-client-adsso package.
- For user documentation, take a look at the [wiki](https://github.com/linuxmuster/linuxmuster-linuxclient7/wiki).
- For developmer documentation, take a look at the [documentation](https://linuxmuster.github.io/linuxmuster-linuxclient7)
- For developer documentation, take a look at the [documentation](https://linuxmuster.github.io/linuxmuster-linuxclient7)

## Maintainance Details
## Maintenance Details

Linuxmuster.net official | ❌ NO*
:---: | :---:
Expand All @@ -36,7 +39,7 @@ Maintainer organisation | Netzint GmbH
Primary maintainer | [email protected] / [email protected]

\* Even though this is not an official package, pull requests and issues are being looked at.
** The linuxmuster community consits of people who are nice and happy to help. They are not directly involved in the development though, and might not be able to help in any case.
** The linuxmuster community consists of people who are nice and happy to help. They are not directly involved in the development though, and might not be able to help in any case.

## Version schema:
- General: `major.minor.patch`
Expand All @@ -45,3 +48,16 @@ Primary maintainer | [email protected] / [email protected]
- Releases are always prefixed with `release`.
- So, once version `7.1.1` is ready, it is published as `7.1.1-release`
- This concept ensures that stable releases are always evaluated as a higher version number than pre-releases.

## Setup development environment

Tested with Python 3.10:

1. `python3 -m venv ./venv`
2. `. ./venv/bin/activate`
3. `cd ./usr/lib/python3/dist-packages/linuxmusterLinuxclient7`
4. `pip install -r requirements.txt`

To run tests:
1. `pytest`
2. with coverage: `pytest --cov=./ --cov-report=xml`
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
defaultDomainAdminUser = "global-admin"

# {} will be substituted for the username
gtkBookmarksFile = "/home/{}/.config/gtk-3.0/bookmarks"

shareMountBasepath = "/home/{}/media"
hiddenShareMountBasepath = "/srv/samba/{}"
machineAccountSysvolMountPath = "/var/lib/samba/sysvol"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def export(keyValuePair):
"""
logging.debug("Saving export '{}' to tmp file".format(keyValuePair))

envList = keyValuePair.split("=")
envList = keyValuePair.split("=", 1)
if len(envList) == 2:
os.putenv(envList[0], envList[1])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def removeLinesInFileContainingString(filePath, forbiddenStrings):
:param filePath: The path to the file
:type filePath: str
:param forbiddenStrings: The string to search for
:type forbiddenStrings: str
:type forbiddenStrings: str or list[str]
:return: True on success, False otherwise
:rtype: bool
"""
Expand Down Expand Up @@ -48,12 +48,12 @@ def deleteFile(filePath):

:param filePath: The path of the file
:type filePath: str
:return: True on success, False otherwise
:return: True on success or if the file does not exist, False otherwise
:rtype: bool
"""
try:
if os.path.exists(filePath):
os.unlink(filePath)
os.remove(filePath)
return True
except Exception as e:
logging.error("Failed!")
Expand All @@ -68,7 +68,7 @@ def deleteFilesWithExtension(directory, extension):
:type directory: str
:param extension: The file extension
:type extension: str
:return: True on success, False otherwise
:return: True on success or if the path does not exist, False otherwise
:rtype: bool
"""
if directory.endswith("/"):
Expand Down Expand Up @@ -105,11 +105,11 @@ def deleteDirectory(directory):

def deleteAllInDirectory(directory):
"""
Delete all files in a given directory
Delete all files and folders in a given directory

:param directory: The path of the directory
:type directory: str
:return: True on success, False otherwise
:return: True on success or if the directory does not exist, False otherwise
:rtype: bool
"""

Expand Down
Loading