Skip to content

Commit f558f36

Browse files
authored
Merge pull request #2 from phasehq/misc-cleanup
feat: add pyproject toml, clean up imports
2 parents a1b1685 + a931150 commit f558f36

File tree

9 files changed

+36
-24
lines changed

9 files changed

+36
-24
lines changed

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "phase_dev"
7+
version = "0.0.1"
8+
description = "Python SDK for Phase"
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"License :: OSI Approved :: MIT License",
14+
"Operating System :: OS Independent",
15+
]
16+
authors = [
17+
{ name = "Phase", email = "[email protected]" }
18+
]
19+
dependencies = [
20+
"pyNaCl >= 1.4.0",
21+
"requests >= 2.26.0",
22+
]
23+
24+
[project.optional-dependencies]
25+
dev = ["pip-tools", "pytest"]
26+
27+
[project.urls]
28+
"Homepage" = "https://phase.dev"
29+
"Documentation" = "https://docs.phase.dev"

setup.py

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.

src/phase.py renamed to src/phase/phase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
from nacl.bindings import crypto_kx_server_session_keys, crypto_kx_client_session_keys
33
from dataclasses import dataclass
4-
from src.utils.crypto import decrypt_b64, encrypt_b64, fetch_app_key, random_key_pair, reconstruct_secret
4+
from .utils.crypto import decrypt_b64, encrypt_b64, fetch_app_key, random_key_pair, reconstruct_secret
55
from .version import __version__, __ph_version__
66

77

src/phase/utils/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

tests/test_decrypt.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
2-
from src.phase import Phase
3-
import src
2+
from src.phase.phase import Phase
43

54
APP_ID = "phApp:v1:e0e50cb9a1953c610126b4092093b1beca51d08d91fc3d9f8d90482a32853215"
65
APP_SECRET = "pss:v1:d261abecb6708c18bebdb8b2748ee574e2b0bdeaf19b081a5f10006cc83d48d0:d146c8c6d326a7842ff9b2da0da455b3f7f568a70808e2eb0cfc5143d4fe170f:59e413612e06d75d251e3416361d0743345a9c9eda1cbcf2b1ef16e3077c011c"
@@ -19,7 +18,7 @@ def mock_fetch_app_key(appToken, wrapKey, appId, dataSize):
1918
def test_phase_decrypt_returns_correct_plaintext(phase_instance, monkeypatch):
2019
data = "Signal"
2120

22-
monkeypatch.setattr(src.phase, "fetch_app_key", mock_fetch_app_key)
21+
monkeypatch.setattr("src.phase.phase.fetch_app_key", mock_fetch_app_key)
2322

2423
ciphertext = phase_instance.encrypt(data)
2524

@@ -29,10 +28,10 @@ def test_phase_decrypt_returns_correct_plaintext(phase_instance, monkeypatch):
2928
assert plaintext == data
3029

3130

32-
def test_phase_decrypt_rejects_promise_with_incorrect_app_secret(monkeypatch):
31+
def test_phase_decrypt_fails_with_incorrect_app_secret(monkeypatch):
3332
phase = Phase(APP_ID, APP_SECRET_INVALID)
3433

35-
monkeypatch.setattr(src.phase, "fetch_app_key", mock_fetch_app_key)
34+
monkeypatch.setattr("src.phase.phase.fetch_app_key", mock_fetch_app_key)
3635

3736
data = "Signal"
3837
ciphertext = phase.encrypt(data)

tests/test_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ def phase_instance():
1010
return Phase(APP_ID_INVALID, APP_SECRET_INVALID)
1111

1212

13-
def test_invalid_app_id(phase_instance):
13+
def test_init_fails_with_invalid_app_id(phase_instance):
1414
invalid_app_id = "phApp:version:cd2d579490fd794f1640590220de86a3676fa7979d419056bc631741b320b701"
1515
with pytest.raises(ValueError, match="Invalid Phase APP_ID"):
1616
Phase(invalid_app_id, APP_SECRET_INVALID)
1717

1818

19-
def test_invalid_app_secret(phase_instance):
19+
def test_test_init_fails_with_invalid_app_secret(phase_instance):
2020
invalid_app_secret = "pss:v1:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000"
2121
with pytest.raises(ValueError, match="Invalid Phase APP_SECRET"):
2222
Phase(APP_ID_INVALID, invalid_app_secret)

0 commit comments

Comments
 (0)