Skip to content

Commit

Permalink
Revert "Revert "main: Add long description type and run tests before …
Browse files Browse the repository at this point in the history
…publishing""

This reverts commit 7f9d58d.
  • Loading branch information
Angelina-C committed Apr 10, 2024
1 parent 7f9d58d commit 2682699
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 34 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,53 @@
name: Upload Python Package

on:
release:
types: [published]
push:
branches:
- main
# release:
# types: [published]

permissions:
contents: read

jobs:
deploy:

# TODO issue #11: deduplicate this, and trigger the test.yml directly
test:
name: Test job
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Modify sys.path and export it
id: modify-sys-path
run: |
echo "::set-output name=sys-path::$(realpath .)"
shell: bash

# Add your build/test steps here
- name: Run Tests
working-directory: test
run: python adb-pywrapper.py
env:
PYTHONPATH: ${{ steps.modify-sys-path.outputs.sys-path }}

publish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Add your build/test steps here
- name: Run Tests
working-directory: test
run: python test_adb_py.py
run: python adb-pywrapper.py
env:
PYTHONPATH: ${{ steps.modify-sys-path.outputs.sys-path }}

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
adb_py.egg-info
*egg-info
build
venv
dist
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# adb_py Documentation
# adb-pywrapper
A python wrapper for the Android Debug Bridge enabling interaction with Android devices and emulators.

<img src="adb-pywrapper_logo.jpg" alt="adb-pywrapper logo" width="500"/>

<img src="adb_py_logo.jpg" alt="adb_py logo" width="500"/>

## AdbDevice: Interacting with Android Devices using ADB in Python

The `AdbDevice` class in the `adb_py` Python package facilitates seamless interaction with Android devices using the Android Debug Bridge (ADB) directly within Python scripts.
The `AdbDevice` class in the `adb-pywrapper` Python package facilitates seamless interaction with Android devices using the Android Debug Bridge (ADB) directly within Python scripts.

Installation
------------

To install the `adb_py` package from the internal nexus pipy server, you can use `pip`:
To install the `adb-pywrapper` package from the internal nexus pipy server, you can use `pip`:

```bash
pip install adb_py
pip install adb-pywrapper
```

Before using `adb_py`, ensure that ADB is installed on your machine and added to PATH. You can download and install the Android SDK, which includes ADB, from the official Android developer website.
Before using `adb-pywrapper`, ensure that ADB is installed on your machine and added to PATH. You can download and install the Android SDK, which includes ADB, from the official Android developer website.

If running the below in a terminal gives you an output, you are ready to go!

Expand All @@ -28,7 +30,7 @@ adb --version
Import the necessary modules:

```python
from adb_py import AdbDevice, AdbResult, PullResult
from adb-pywrapper import AdbDevice, AdbResult, PullResult
```

## Listing Connected Devices
Expand Down Expand Up @@ -191,7 +193,7 @@ ls(path)
* snapshot_delete(delete=None)

## Error Handling
Be sure to handle errors gracefully in your code, as various operations may fail, adb_py tries to provide information where possible on success or failure in the `AdbResult` and `PullResult` objects.
Be sure to handle errors gracefully in your code, as various operations may fail, adb-pywrapper tries to provide information where possible on success or failure in the `AdbResult` and `PullResult` objects.

## Contributing
Contributions to the adb_py package are welcome. If you encounter any issues, have suggestions, or want to contribute, feel free to open an issue or PR.
Contributions to the adb-pywrapper package are welcome. If you encounter any issues, have suggestions, or want to contribute, feel free to open an issue or PR.
File renamed without changes
File renamed without changes.
10 changes: 1 addition & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

setup(
name="adb_py",
version="0.9",
description="adb_py facilitates seamless interaction with Android devices using the Android Debug Bridge (ADB) "
"directly within Python scripts.",
long_description=f"{open('README.md').read()}",
author="Netherlands Forensic Institute",
author_email="netherlandsforensicinstitute@users.noreply.github.com",
url="https://github.com/NetherlandsForensicInstitute/adb_py",
licence="EUPL-1.2",
version="0.8",
py_modules=["adb_py", "adb_init"],
test_suite="test",
)
20 changes: 10 additions & 10 deletions test/test_adb_py.py → test/adb-pywrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from parameterized import parameterized

from adb_py import AdbResult, AdbDevice
from adb_pywrapper import AdbResult, AdbDevice

PROCESS = subprocess.run('echo hello', shell=True, capture_output=True)
MOCK_SUCCESSFULLY_PULLED_FILE = ['abc.apk', 'bla.jpg']
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_get_state(self):
self.assertFalse(result.success)
self.assertIn('Invalid command', result.stderr)

@patch('adb_py.AdbDevice._snapshot_command')
@patch('adb_pywrapper.AdbDevice._snapshot_command')
def test_emulator_snapshots_list(self, mock_snapshot_command):
# Test emulator_snapshots_list function
snapshot_list_output = """List of snapshots present on all disks:
Expand All @@ -336,8 +336,8 @@ def test_emulator_snapshots_list(self, mock_snapshot_command):
mock_snapshot_command.assert_called_once_with('list')
self.assertEqual(result, ['snap_2023-11-23_13-13-02', 'snap_2023-12-05_12-56-56'])

@patch('adb_py.AdbDevice._snapshot_exists')
@patch('adb_py.AdbDevice._snapshot_command')
@patch('adb_pywrapper.AdbDevice._snapshot_exists')
@patch('adb_pywrapper.AdbDevice._snapshot_command')
def test_emulator_snapshot_load_existing(self, mock_snapshot_command, mock_snapshot_exists):
# Test emulator_snapshot_load function with an existing snapshot
mock_snapshot_exists.return_value = True
Expand All @@ -348,7 +348,7 @@ def test_emulator_snapshot_load_existing(self, mock_snapshot_command, mock_snaps
mock_snapshot_exists.assert_called_once_with('snapshot1')
mock_snapshot_command.assert_called_once_with('load', 'snapshot1')

@patch('adb_py.AdbDevice._snapshot_exists')
@patch('adb_pywrapper.AdbDevice._snapshot_exists')
def test_emulator_snapshot_load_non_existing(self, mock_snapshot_exists):
# Test emulator_snapshot_load function with a non-existing snapshot
mock_snapshot_exists.return_value = False
Expand All @@ -358,8 +358,8 @@ def test_emulator_snapshot_load_non_existing(self, mock_snapshot_exists):
mock_snapshot_exists.assert_called_once_with('non_existing_snapshot')
self.assertFalse(result.success)

@patch('adb_py.AdbDevice._snapshot_exists')
@patch('adb_py.AdbDevice._snapshot_command')
@patch('adb_pywrapper.AdbDevice._snapshot_exists')
@patch('adb_pywrapper.AdbDevice._snapshot_command')
def test_emulator_snapshot_save(self, mock_snapshot_command, mock_snapshot_exists):
# Test emulator_snapshot_save function
mock_snapshot_exists.return_value = False
Expand All @@ -370,9 +370,9 @@ def test_emulator_snapshot_save(self, mock_snapshot_command, mock_snapshot_exist
mock_snapshot_exists.assert_called_once_with('snapshot1')
mock_snapshot_command.assert_called_once_with('save', 'snapshot1')

@patch('adb_py.AdbDevice.emulator_snapshots_list', return_value=['snapshot1', 'snapshot2'])
@patch('adb_py.AdbDevice._snapshot_exists')
@patch('adb_py.AdbDevice._snapshot_command')
@patch('adb_pywrapper.AdbDevice.emulator_snapshots_list', return_value=['snapshot1', 'snapshot2'])
@patch('adb_pywrapper.AdbDevice._snapshot_exists')
@patch('adb_pywrapper.AdbDevice._snapshot_command')
def test_emulator_snapshot_delete(self, mock_snapshot_command, mock_snapshot_exists, mock_emulator_snapshots_list):
# Test emulator_snapshot_delete function
mock_snapshot_exists.return_value = True # Existing snapshots
Expand Down

0 comments on commit 2682699

Please sign in to comment.