pierre-storage 1.0.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pierre_storage-1.0.0/pierre_storage.egg-info → pierre_storage-1.0.1}/PKG-INFO +1 -1
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/client.py +4 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/repo.py +8 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/types.py +5 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/version.py +1 -1
- {pierre_storage-1.0.0 → pierre_storage-1.0.1/pierre_storage.egg-info}/PKG-INFO +1 -1
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pyproject.toml +1 -1
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/tests/test_client.py +67 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/LICENSE +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/MANIFEST.in +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/README.md +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/__init__.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/auth.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/commit.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/errors.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/py.typed +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage/webhook.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage.egg-info/SOURCES.txt +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage.egg-info/dependency_links.txt +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage.egg-info/requires.txt +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/pierre_storage.egg-info/top_level.txt +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/setup.cfg +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/tests/test_commit.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/tests/test_repo.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/tests/test_version.py +0 -0
- {pierre_storage-1.0.0 → pierre_storage-1.0.1}/tests/test_webhook.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Main client for Pierre Git Storage SDK."""
|
|
2
2
|
|
|
3
3
|
import uuid
|
|
4
|
+
from datetime import datetime, timezone
|
|
4
5
|
from typing import Any, Dict, Optional, cast
|
|
5
6
|
from urllib.parse import urlencode
|
|
6
7
|
|
|
@@ -216,6 +217,7 @@ class GitStorage:
|
|
|
216
217
|
name,
|
|
217
218
|
api_version,
|
|
218
219
|
self._generate_jwt,
|
|
220
|
+
created_at=datetime.now(timezone.utc).isoformat(),
|
|
219
221
|
)
|
|
220
222
|
|
|
221
223
|
async def list_repos(
|
|
@@ -317,6 +319,7 @@ class GitStorage:
|
|
|
317
319
|
|
|
318
320
|
body = response.json()
|
|
319
321
|
default_branch = body.get("default_branch", "main")
|
|
322
|
+
created_at = body.get("created_at", "")
|
|
320
323
|
|
|
321
324
|
# These are guaranteed to be set in __init__
|
|
322
325
|
api_base_url: str = self.options["api_base_url"] # type: ignore[assignment]
|
|
@@ -332,6 +335,7 @@ class GitStorage:
|
|
|
332
335
|
name,
|
|
333
336
|
api_version,
|
|
334
337
|
self._generate_jwt,
|
|
338
|
+
created_at=created_at,
|
|
335
339
|
)
|
|
336
340
|
|
|
337
341
|
async def delete_repo(
|
|
@@ -112,6 +112,7 @@ class RepoImpl:
|
|
|
112
112
|
name: str,
|
|
113
113
|
api_version: int,
|
|
114
114
|
generate_jwt: Callable[[str, Optional[Dict[str, Any]]], str],
|
|
115
|
+
created_at: str = "",
|
|
115
116
|
) -> None:
|
|
116
117
|
"""Initialize repository.
|
|
117
118
|
|
|
@@ -123,9 +124,11 @@ class RepoImpl:
|
|
|
123
124
|
name: Customer name
|
|
124
125
|
api_version: API version
|
|
125
126
|
generate_jwt: Function to generate JWT tokens
|
|
127
|
+
created_at: Repository creation timestamp
|
|
126
128
|
"""
|
|
127
129
|
self._id = repo_id
|
|
128
130
|
self._default_branch = default_branch
|
|
131
|
+
self._created_at = created_at
|
|
129
132
|
self.api_base_url = api_base_url.rstrip("/")
|
|
130
133
|
self.storage_base_url = storage_base_url
|
|
131
134
|
self.name = name
|
|
@@ -142,6 +145,11 @@ class RepoImpl:
|
|
|
142
145
|
"""Get default branch name."""
|
|
143
146
|
return self._default_branch
|
|
144
147
|
|
|
148
|
+
@property
|
|
149
|
+
def created_at(self) -> str:
|
|
150
|
+
"""Get repository creation timestamp."""
|
|
151
|
+
return self._created_at
|
|
152
|
+
|
|
145
153
|
async def get_remote_url(
|
|
146
154
|
self,
|
|
147
155
|
*,
|
|
@@ -84,6 +84,32 @@ class TestGitStorage:
|
|
|
84
84
|
assert repo is not None
|
|
85
85
|
assert repo.id == "test-repo"
|
|
86
86
|
|
|
87
|
+
@pytest.mark.asyncio
|
|
88
|
+
async def test_create_repo_sets_created_at(self, git_storage_options: dict) -> None:
|
|
89
|
+
"""Test that create_repo sets created_at on the returned repo."""
|
|
90
|
+
from datetime import datetime, timezone
|
|
91
|
+
|
|
92
|
+
storage = GitStorage(git_storage_options)
|
|
93
|
+
|
|
94
|
+
mock_response = MagicMock()
|
|
95
|
+
mock_response.status_code = 200
|
|
96
|
+
mock_response.is_success = True
|
|
97
|
+
mock_response.json.return_value = {"repo_id": "test-repo", "url": "https://test.git"}
|
|
98
|
+
|
|
99
|
+
with patch("httpx.AsyncClient") as mock_client:
|
|
100
|
+
mock_client.return_value.__aenter__.return_value.post = AsyncMock(
|
|
101
|
+
return_value=mock_response
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
before = datetime.now(timezone.utc).isoformat()
|
|
105
|
+
repo = await storage.create_repo(id="test-repo")
|
|
106
|
+
after = datetime.now(timezone.utc).isoformat()
|
|
107
|
+
|
|
108
|
+
assert repo.created_at is not None
|
|
109
|
+
assert len(repo.created_at) > 0
|
|
110
|
+
assert repo.created_at >= before
|
|
111
|
+
assert repo.created_at <= after
|
|
112
|
+
|
|
87
113
|
@pytest.mark.asyncio
|
|
88
114
|
async def test_create_repo_with_base_repo(self, git_storage_options: dict) -> None:
|
|
89
115
|
"""Test creating a repository with GitHub sync."""
|
|
@@ -282,6 +308,47 @@ class TestGitStorage:
|
|
|
282
308
|
assert repo is not None
|
|
283
309
|
assert repo.id == "test-repo"
|
|
284
310
|
|
|
311
|
+
@pytest.mark.asyncio
|
|
312
|
+
async def test_find_one_created_at(self, git_storage_options: dict) -> None:
|
|
313
|
+
"""Test that find_one exposes created_at from API response."""
|
|
314
|
+
storage = GitStorage(git_storage_options)
|
|
315
|
+
|
|
316
|
+
mock_response = MagicMock()
|
|
317
|
+
mock_response.status_code = 200
|
|
318
|
+
mock_response.is_success = True
|
|
319
|
+
mock_response.json.return_value = {
|
|
320
|
+
"default_branch": "main",
|
|
321
|
+
"created_at": "2024-06-15T12:00:00Z",
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
with patch("httpx.AsyncClient") as mock_client:
|
|
325
|
+
mock_client.return_value.__aenter__.return_value.get = AsyncMock(
|
|
326
|
+
return_value=mock_response
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
repo = await storage.find_one(id="test-repo")
|
|
330
|
+
assert repo is not None
|
|
331
|
+
assert repo.created_at == "2024-06-15T12:00:00Z"
|
|
332
|
+
|
|
333
|
+
@pytest.mark.asyncio
|
|
334
|
+
async def test_find_one_created_at_missing(self, git_storage_options: dict) -> None:
|
|
335
|
+
"""Test that find_one defaults created_at to empty string when not in response."""
|
|
336
|
+
storage = GitStorage(git_storage_options)
|
|
337
|
+
|
|
338
|
+
mock_response = MagicMock()
|
|
339
|
+
mock_response.status_code = 200
|
|
340
|
+
mock_response.is_success = True
|
|
341
|
+
mock_response.json.return_value = {"default_branch": "main"}
|
|
342
|
+
|
|
343
|
+
with patch("httpx.AsyncClient") as mock_client:
|
|
344
|
+
mock_client.return_value.__aenter__.return_value.get = AsyncMock(
|
|
345
|
+
return_value=mock_response
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
repo = await storage.find_one(id="test-repo")
|
|
349
|
+
assert repo is not None
|
|
350
|
+
assert repo.created_at == ""
|
|
351
|
+
|
|
285
352
|
@pytest.mark.asyncio
|
|
286
353
|
async def test_find_one_not_found(self, git_storage_options: dict) -> None:
|
|
287
354
|
"""Test finding a repository that doesn't exist."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|