Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions __init__.py

This file was deleted.

7 changes: 7 additions & 0 deletions caffa/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .restclient import RestClient as RestClient, SessionType as SessionType
from .object import (
Object as Object,
create_class as create_class,
create_method_class as create_method_class,
)
from .method import Method as Method
3 changes: 1 addition & 2 deletions method.py → caffa/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# See the GNU Lesser General Public License at <<http:#www.gnu.org/licenses/lgpl-2.1.html>>
# for more details.
#
import json
import logging


Expand Down Expand Up @@ -60,7 +59,7 @@ def name(self):


def make_read_lambda(property_name):
return lambda self: self_self_object.get(property_name)
return lambda self: self._self_object.get(property_name)


def make_write_lambda(property_name):
Expand Down
2 changes: 1 addition & 1 deletion object.py → caffa/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import json
import logging

from .method import Method, create_method_class
from .method import create_method_class


class Object(object):
Expand Down
28 changes: 14 additions & 14 deletions restclient.py → caffa/restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class RestClient:
delay_between_attempts = 0.5

def __init__(
self,
hostname,
port=50000,
username="",
password="",
min_app_version=MIN_APP_VERSION,
max_app_version=MAX_APP_VERSION,
session_type=SessionType.REGULAR,
self,
hostname,
port=50000,
username="",
password="",
min_app_version=MIN_APP_VERSION,
max_app_version=MAX_APP_VERSION,
session_type=SessionType.REGULAR,
):
self.hostname = hostname
self.port = port
Expand Down Expand Up @@ -315,9 +315,9 @@ def check_version(self, min_app_version, max_app_version):
max_app_version[2],
)
if (
app_info.major_version,
app_info.minor_version,
app_info.patch_version,
app_info.major_version,
app_info.minor_version,
app_info.patch_version,
) < min_app_version:
return (
False,
Expand All @@ -331,9 +331,9 @@ def check_version(self, min_app_version, max_app_version):
),
)
if (
app_info.major_version,
app_info.minor_version,
app_info.patch_version,
app_info.major_version,
app_info.minor_version,
app_info.patch_version,
) > max_app_version:
return (
False,
Expand Down
6 changes: 0 additions & 6 deletions conftest.py

This file was deleted.

29 changes: 28 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
[build-system]
requires = ["setuptool>=42"]
requires = ["setuptools>=62"]
build-backend = "setuptools.build_meta"

[project]
name = "caffa"
version = "1.6.0"
description = "Python bindings for caffa"
readme = "README.md"
requires-python = ">=3.6"
license = { file = "LICENSE" }
authors = [{ name = "Gaute Lindkvist", email = "lindkvis@gmail.com" }]
maintainers = [
{ name = "Gaute Lindkvist", email = "lindkvis@gmail.com" },
]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: LGPL License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
]
dependencies = ["requests"]

[project.optional-dependencies]
dev = ["pytest"]

[project.urls]
"Homepage" = "https://github.com/lindkvis/caffa-python"
"Bug Reports" = "https://github.com/lindkvis/caffa-python/issues"
"Source" = "https://github.com/lindkvis/caffa-python"
30 changes: 0 additions & 30 deletions setup.py

This file was deleted.

14 changes: 7 additions & 7 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def test_app_info():
assert app_info is not None
assert app_info.name != ""
app_string = (
app_info.name
+ " v"
+ str(app_info.major_version)
+ "."
+ str(app_info.minor_version)
+ "."
+ str(app_info.patch_version)
app_info.name
+ " v"
+ str(app_info.major_version)
+ "."
+ str(app_info.minor_version)
+ "."
+ str(app_info.patch_version)
)
log.info("App info: %s", app_string)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def test_fields(self):
try:
doc.id = "AnotherName"
pytest.fail("Should have failed to write to document id, but succeeded!")
except Exception as e:
except Exception:
print("Got expected error")

assert doc.id == "testDocument"

try:
doc.nonExistantField = "Test"
pytest.fail("Should get an exception!")
except Exception as e:
except Exception:
print("Got the expected exception for field not found")

def test_children(self):
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_non_existing_field(self):
doc = self.testApp.document("testDocument")
assert doc is not None
try:
value = doc.does_not_exist
doc.does_not_exist
pytest.fail("Should have had exception, but got none!")
except Exception as e:
log.info(
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_app_enum(self):

except Exception as e:
log.info(
"Got expected exception when trying to assign an invalid enum value: '0'".format(
"Got expected exception when trying to assign an invalid enum value: '{0}'".format(
e
)
)