Skip to content

Commit

Permalink
Added file_id to File, resolves #108
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Oct 5, 2022
1 parent 9630c8c commit ed2bca7
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 70 deletions.
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ pytest = "~=7.1"
vcrpy = "~=4.2"
pytest-vcr = "~=1.0.2"
pytest-cov = "~=3.0"
pylint = "~= 2.14"
pylint = "~= 2.15"
pytest-pylint = "~= 0.3"
mypy = "~= 0.981"
mypy = "~= 0.982"
python-dotenv = "~= 0.19.2"
autopep8 = "~= 1.6"
autopep8 = "~= 1.7"
importlib-metadata = "*"

[packages]
Expand Down
102 changes: 51 additions & 51 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/additional_info/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Changelog
=========

1.6.0 (05-Oct-2022)
-------------------

* Added `file_id` attribute to `File` model:

.. code-block:: python
files = client.files(project_id)
files.items[0].file_id # => 839819
1.5.0 (07-Jul-2022)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion lokalise/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
This module contains plugin metadata.
"""

__version__: str = "1.5.0"
__version__: str = "1.6.0"
1 change: 1 addition & 0 deletions lokalise/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FileModel(BaseModel):
"""Describes file.
"""
ATTRS = [
'file_id',
'filename',
'key_count'
]
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ addopts = -s --cov=lokalise --cov-report html --pylint
min-public-methods=0
max-public-methods=150
min-similarity-lines=5
max-module-lines=2500
max-module-lines=2500
disable=W3101
25 changes: 14 additions & 11 deletions tests/cassettes/files_test/test_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ interactions:
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-lokalise-api plugin/0.0.1
- python-lokalise-api plugin/1.5.0
x-api-token:
- FILTERED
method: GET
uri: https://api.lokalise.com/api2/projects/454087345e09f3e7e7eae3.57891254/files
uri: https://api.lokalise.com/api2/projects/71749499610303a83ad8a2.67103833/files
response:
body:
string: '{"project_id":"454087345e09f3e7e7eae3.57891254","branch":"master","files":[{"filename":"%LANG_ISO%.xml","key_count":1},{"filename":"%LANG_ISO%.yml","key_count":4},{"filename":"__unassigned__","key_count":8}]}'
string: '{"project_id":"71749499610303a83ad8a2.67103833","branch":"master","files":[{"file_id":839819,"filename":"%LANG_ISO%.yml","key_count":58},{"file_id":1275799,"filename":"test.yml","key_count":1},{"file_id":-1,"filename":"__unassigned__","key_count":0}]}'
headers:
Access-Control-Allow-Headers:
- Content-Type
Expand All @@ -29,13 +27,16 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 19 Jun 2020 12:08:41 GMT
- Wed, 05 Oct 2022 10:45:54 GMT
Expires:
- Fri, 19 Jun 2020 12:08:41 GMT
Pragma:
- no-cache
- Wed, 05 Oct 2022 10:45:54 GMT
Referrer-Policy:
- origin
Server:
- nginx
Set-Cookie:
- PHPSESSID=deleted; expires=Tue, 05-Oct-2021 10:45:53 GMT; Max-Age=0; path=/;
httponly
Strict-Transport-Security:
- max-age=31536000
Transfer-Encoding:
Expand All @@ -46,6 +47,8 @@ interactions:
- nosniff
X-Frame-Options:
- deny
X-Lokalise-Process-Id:
- bf28fa21-fc3a-4d4b-b4c3-e05f728ef8b6
X-Pagination-Limit:
- '100'
X-Pagination-Page:
Expand All @@ -56,8 +59,8 @@ interactions:
- '3'
X-XSS-Protection:
- 1; mode=block
content-length:
- '208'
pragma:
- no-cache
status:
code: 200
message: OK
Expand Down
8 changes: 5 additions & 3 deletions tests/client/files_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
def test_files(client):
"""Tests fetching of all files
"""
files = client.files(PROJECT_ID)
assert files.project_id == PROJECT_ID
assert files.items[0].filename == "%LANG_ISO%.xml"
project_id = "71749499610303a83ad8a2.67103833"
files = client.files(project_id)
assert files.project_id == project_id
assert files.items[0].filename == "%LANG_ISO%.yml"
assert files.items[0].file_id == 839819


@pytest.mark.vcr
Expand Down

0 comments on commit ed2bca7

Please sign in to comment.