From 132e7ed3f416a022ed59dabc2944b6ba04b31144 Mon Sep 17 00:00:00 2001 From: Zeke Gabrielse Date: Mon, 3 Jul 2023 14:38:14 -0500 Subject: [PATCH] add ci --- .github/FUNDING.yml | 1 + .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ README.md | 3 +++ tests/__init__.py | 25 +++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/test.yml create mode 100644 tests/__init__.py diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e6d21fb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: ezekg \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b02e633 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + test: + runs-on: + - windows-latest + - ubuntu-latest + - macos-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup + uses: actions/setup-python@v4 + with: + python-version: ${{matrix.python-version}} + - name: Install + run: python -m pip install --upgrade pip + - name: Test + run: python -m unittest tests diff --git a/README.md b/README.md index beed496..965405d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # py-machineid +[![CI](https://github.com/keygen-sh/py-machineid/actions/workflows/test.yml/badge.svg)](https://github.com/keygen-sh/py-machineid/actions) +[![PyPI version](https://badge.fury.io/py/py-machineid.svg)](https://badge.fury.io/py/py-machineid) + Get the unique machine ID of any host (without admin privileges). Sponsored by: diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..93800bf --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,25 @@ +from sys import platform + +import machineid +import unittest + +class TestMachineId(unittest.TestCase): + def test_hashed_id(self): + self.assertTrue(isinstance(machineid.hashed_id(), str)) + self.assertTrue(len(machineid.hashed_id()) > 0) + self.assertTrue(machineid.hashed_id('foo') != machineid.hashed_id('bar')) + self.assertTrue(machineid.hashed_id('foo') != machineid.hashed_id()) + + def test_id(self): + self.assertTrue(isinstance(machineid.id(), str)) + self.assertTrue(len(machineid.id()) > 0) + + def test_registry(self): + if platform != 'win32': + return + + self.assertTrue(isinstance(machineid.id(winregistry=False), str)) + self.assertTrue(machineid.id(winregistry=False) != machineid.id(winregistry=True)) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file