python-terminusgps 31.6.0__py3-none-any.whl → 31.7.0__py3-none-any.whl

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.

Potentially problematic release.


This version of python-terminusgps might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 31.6.0
3
+ Version: 31.7.0
4
4
  Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
5
5
  Project-URL: Documentation, https://docs.terminusgps.com
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -6,11 +6,12 @@ terminusgps/authorizenet/utils.py,sha256=T0ufuNiBgn54VS07qJRJHf7pmapA3sFLSiSGe_n
6
6
  terminusgps/authorizenet/profiles/__init__.py,sha256=IG4XCEEYtHKqXOatlZlob6J3ukAgF7cFR-RXxOSMS1c,161
7
7
  terminusgps/authorizenet/profiles/addresses.py,sha256=7yrOrb9kIsiiazgWbeH8v_YUBiWG3Y61g46R3S5DD-k,6592
8
8
  terminusgps/authorizenet/profiles/base.py,sha256=TOUHr22QRQBLErdysOkfcpJBusTjrUTqOmWEyNvMacA,2240
9
- terminusgps/authorizenet/profiles/customers.py,sha256=IgH4f7vQHwUiGfrOTRVz3mFDS-_JN1yyV9JOpWO2AE4,8297
9
+ terminusgps/authorizenet/profiles/customers.py,sha256=RlvSDuBNmtotu1WD24fQEktiBKyqKiTkGaBgoS2_V84,8851
10
10
  terminusgps/authorizenet/profiles/payments.py,sha256=ohhZrs9MB7GkCi7jQvPVvELNKnR9BwzMd607jJmT4n4,11316
11
11
  terminusgps/authorizenet/profiles/subscriptions.py,sha256=N4_0kbBBJ0FtKdIydN8FLnAG2kSI9DHQWAwemMt7Qu8,11020
12
- terminusgps/authorizenet/tests/test_auth.py,sha256=gNIjZw_QLzVMiPBqaxfm5-qVIISZlpBvPSstFYGsmzc,1625
13
- terminusgps/authorizenet/tests/test_profiles.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ terminusgps/authorizenet/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ terminusgps/authorizenet/tests/test_auth.py,sha256=zetg5xlg6A0dKuBJR7sPTHfza8TOIG8yIEP_CvI9XWQ,1612
14
+ terminusgps/authorizenet/tests/test_profiles.py,sha256=PWSynAZmosnAJVe6vNOpSui1-UwqggrYtaweD9uDDrg,1351
14
15
  terminusgps/authorizenet/tests/test_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
16
  terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
17
  terminusgps/aws/connect.py,sha256=TWf2bVz6LqSNQfVD7FKRn3K71VuLOwBj05Gs-9BsROg,693
@@ -18,11 +19,14 @@ terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,36
18
19
  terminusgps/aws/utils.py,sha256=68GWcllu4h41qzFiKdUkWOAA4LDsTPqRY446VRMxYsY,116
19
20
  terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
21
  terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
21
- terminusgps/django/settings.py,sha256=cKUpFXH-uYWStvT6vzclczJAKwCGNx_2wY9-fqsbmIs,624
22
+ terminusgps/django/settings.py,sha256=yJIcBE0xjY60AXF_gonY5hS3ofseqPW2k9uSoELgoho,639
22
23
  terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
23
24
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
24
25
  terminusgps/twilio/caller.py,sha256=Q0wcJ5aaNDGvKfht7ARwPTFdqpFoB81DmZ_K2oZixyA,5077
25
26
  terminusgps/twilio/validators.py,sha256=HWCpzgDXTedofty4Zhrm2OenbgtkzrDUC08B1l15gqc,1112
27
+ terminusgps/twilio/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
+ terminusgps/twilio/tests/test_caller.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ terminusgps/twilio/tests/test_validators.py,sha256=CETv7Mcr19UMMfh1UaWSV26FiOeh2WCK_VutfKXnf7g,1428
26
30
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
31
  terminusgps/wialon/constants.py,sha256=pMWqXkZK7bbA_KOdBdJ8hs9MnUUEk-MMygJ3fLNA4pQ,5783
28
32
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
@@ -38,10 +42,11 @@ terminusgps/wialon/items/route.py,sha256=amNPKZqgl8pEzKA_XJudnvBPzEsfHTmrC7uF15s
38
42
  terminusgps/wialon/items/unit.py,sha256=iwHM4AfUED2blKkP940RbUxFFPD_4pTDe4Dut853cfA,12302
39
43
  terminusgps/wialon/items/unit_group.py,sha256=QV2ZZgICaN3n6W1pFIyMLyNKB6KYBsLyKG64i-qXoOg,4113
40
44
  terminusgps/wialon/items/user.py,sha256=5LgwalGO8KS_7psmAVmAlnC0S6SPBDZMOuT5ZqPKRmo,7758
41
- terminusgps/wialon/tests/test_items.py,sha256=P2LmBYx_63-bfSmsrIdVegLUcet-OBIjjJo0kJAJ-lE,1300
42
- terminusgps/wialon/tests/test_session.py,sha256=4H_TeIMrC4dyaDAy11a0o1GMn6PIZaRF8soPaoaowQg,1318
45
+ terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
+ terminusgps/wialon/tests/test_session.py,sha256=k5iEwd77nCebxWyFzkDCm9G0c04iztXY6UgOaxhub48,1314
43
48
  terminusgps/wialon/tests/test_utils.py,sha256=vYnOKCPPYqUWcQ2nTJTOu7NhNKMiTGNBkvX9H2APxL0,1670
44
- python_terminusgps-31.6.0.dist-info/METADATA,sha256=XP5bfNhmAhY6g_zYrFWhRegcnWLu4aef_I5hiOEI9oc,1609
45
- python_terminusgps-31.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
- python_terminusgps-31.6.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
47
- python_terminusgps-31.6.0.dist-info/RECORD,,
49
+ python_terminusgps-31.7.0.dist-info/METADATA,sha256=eNDi6Z4AU2kb9zY1iDzX04JwFJ-5HJRfVLEasUF9-20,1609
50
+ python_terminusgps-31.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
51
+ python_terminusgps-31.7.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
52
+ python_terminusgps-31.7.0.dist-info/RECORD,,
@@ -8,6 +8,11 @@ from .base import AuthorizenetProfileBase
8
8
  class CustomerProfile(AuthorizenetProfileBase):
9
9
  """An Authorizenet customer profile."""
10
10
 
11
+ def __init__(self, *args, **kwargs) -> None:
12
+ super().__init__(*args, **kwargs)
13
+ self._email = None
14
+ self._desc = None
15
+
11
16
  def create(self, email: str, desc: str = "") -> int:
12
17
  """
13
18
  Creates a customer profile and returns its id.
@@ -25,6 +30,8 @@ class CustomerProfile(AuthorizenetProfileBase):
25
30
  response = self._authorizenet_create_customer_profile(email=email, desc=desc)
26
31
  if response is None:
27
32
  raise ValueError("Failed to retrieve Authorizenet API response.")
33
+ self._email = email
34
+ self._desc = desc
28
35
  return int(response.customerProfileId)
29
36
 
30
37
  def update(self, email: str, desc: str = "") -> None:
@@ -41,6 +48,10 @@ class CustomerProfile(AuthorizenetProfileBase):
41
48
 
42
49
  """
43
50
  self._authorizenet_update_customer_profile(email, desc)
51
+ if email:
52
+ self._email = email
53
+ if desc:
54
+ self._desc = desc
44
55
 
45
56
  def delete(self) -> None:
46
57
  """
@@ -77,6 +88,13 @@ class CustomerProfile(AuthorizenetProfileBase):
77
88
  except (ControllerExecutionError, AttributeError):
78
89
  return []
79
90
 
91
+ @property
92
+ def email(self) -> str | None:
93
+ if not self._email:
94
+ response = self._authorizenet_get_customer_profile(issuer_info=False)
95
+ self._email = response.profile.email if response else None
96
+ return self._email
97
+
80
98
  def _authorizenet_get_customer_profile_ids(self) -> dict | None:
81
99
  """
82
100
  Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileIdsRequest` using the Authorizenet API.
File without changes
@@ -2,7 +2,6 @@ from unittest import TestCase
2
2
 
3
3
  from authorizenet.apicontractsv1 import merchantAuthenticationType
4
4
  from authorizenet.constants import constants
5
- from django.conf import settings
6
5
  from django.test import override_settings
7
6
 
8
7
  from terminusgps.authorizenet import auth
@@ -10,23 +9,22 @@ from terminusgps.authorizenet import auth
10
9
  TEST_MERCHANT_AUTH_LOGIN_ID = "test_id"
11
10
  TEST_MERCHANT_AUTH_TRANSACTION_KEY = "test_key"
12
11
 
13
- if not settings.configured:
14
- settings.configure(DEBUG=True)
15
-
16
12
 
17
13
  class MerchantAuthenticationTestCase(TestCase):
18
14
  @override_settings(
19
15
  MERCHANT_AUTH_LOGIN_ID=TEST_MERCHANT_AUTH_LOGIN_ID,
20
16
  MERCHANT_AUTH_TRANSACTION_KEY=TEST_MERCHANT_AUTH_TRANSACTION_KEY,
17
+ DEBUG=True,
21
18
  )
22
19
  def test_merchant_authentication(self) -> None:
23
20
  auth_obj: merchantAuthenticationType = auth.get_merchant_auth()
24
- self.assertTrue(isinstance(auth_obj, merchantAuthenticationType))
21
+ self.assertIsInstance(auth_obj, merchantAuthenticationType)
25
22
  self.assertTrue(auth_obj.name, TEST_MERCHANT_AUTH_LOGIN_ID)
26
23
  self.assertTrue(auth_obj.transactionKey, TEST_MERCHANT_AUTH_TRANSACTION_KEY)
27
24
 
28
25
 
29
26
  class ValidationModeTestCase(TestCase):
27
+ @override_settings(DEBUG=True)
30
28
  def test_validation_mode_debug_enabled(self) -> None:
31
29
  self.assertTrue(auth.get_validation_mode(), "testMode")
32
30
 
@@ -36,6 +34,7 @@ class ValidationModeTestCase(TestCase):
36
34
 
37
35
 
38
36
  class EnvironmentTestCase(TestCase):
37
+ @override_settings(DEBUG=True)
39
38
  def test_environment_debug_enabled(self) -> None:
40
39
  self.assertTrue(auth.get_environment(), constants.SANDBOX)
41
40
 
@@ -0,0 +1,36 @@
1
+ import uuid
2
+ from datetime import datetime
3
+ from unittest import TestCase
4
+
5
+ from terminusgps.authorizenet.auth import get_merchant_auth
6
+ from terminusgps.authorizenet.profiles import CustomerProfile
7
+
8
+
9
+ class CustomerProfileTestCase(TestCase):
10
+ def setUp(self) -> None:
11
+ self.merchantAuthentication = get_merchant_auth()
12
+ self.test_timestamp = f"{datetime.now():%Y-%m-%d-%H:%M:%S}"
13
+ self.test_id = str(uuid.uuid4())[:24]
14
+ self.test_email = f"test_customer_{self.test_id}@domain.com"
15
+ self.test_desc = f"Test customer created on: {self.test_timestamp}"
16
+ self.test_customer_profile = CustomerProfile(
17
+ merchant_id=self.test_id,
18
+ id=None,
19
+ email=self.test_email,
20
+ desc=self.test_desc,
21
+ )
22
+
23
+ def tearDown(self) -> None:
24
+ self.test_customer_profile.delete()
25
+
26
+ def test_customer_profile_update(self) -> None:
27
+ old_email: str = self.test_email
28
+ new_email: str = f"test_customer_{str(uuid.uuid4())[:24]}@domain.com"
29
+ self.test_customer_profile.update(email=new_email)
30
+ self.assertTrue(self.test_customer_profile.email, new_email)
31
+ self.assertFalse(self.test_customer_profile.email, old_email)
32
+
33
+
34
+ class AddressProfileTestCase(TestCase):
35
+ def setUp(self) -> None:
36
+ self.merchantAuthentication = get_merchant_auth()
@@ -4,6 +4,7 @@ import pathlib
4
4
  BASE_DIR = pathlib.Path(__file__).resolve().parent
5
5
  DEBUG = True
6
6
  SECRET_KEY = "xem*6no%8d9%^qzt2f3x3ar-uq4_+7h9myc$t0!+4%bj5us6f)"
7
+ USE_TZ = False
7
8
 
8
9
  # Secrets
9
10
  CONNECT_SECRET = os.getenv("CONNECT_SECRET")
File without changes
File without changes
@@ -0,0 +1,40 @@
1
+ from unittest import TestCase
2
+
3
+ import django
4
+ from django.core.exceptions import ValidationError
5
+
6
+ from terminusgps.twilio import validators
7
+
8
+ django.setup()
9
+
10
+
11
+ class PhoneNumberValidatorTestCase(TestCase):
12
+ def setUp(self) -> None:
13
+ self.validator = validators.validate_phone_number
14
+
15
+ def test_phone_without_plus(self) -> None:
16
+ """Fails if a phone number without a '+' leading character passes validation."""
17
+ with self.assertRaises(ValidationError) as context:
18
+ self.validator("15555555555")
19
+ self.assertTrue(
20
+ "Phone number must begin with a '+', got '15555555555'."
21
+ in str(context.exception)
22
+ )
23
+
24
+ def test_phone_min_length(self) -> None:
25
+ """Fails if a phone number of 8 characters in length passes validation."""
26
+ with self.assertRaises(ValidationError) as context:
27
+ self.validator("+1555555")
28
+ self.assertTrue(
29
+ "Phone number cannot be less than 12 characters, got 8."
30
+ in str(context.exception)
31
+ )
32
+
33
+ def test_phone_max_length(self) -> None:
34
+ """Fails if a phone number of 20 characters in length passes validation."""
35
+ with self.assertRaises(ValidationError) as context:
36
+ self.validator("+1555555555555555555")
37
+ self.assertTrue(
38
+ "Phone number cannot be greater than 19 characters, got 20."
39
+ in str(context.exception)
40
+ )
File without changes
@@ -1,37 +0,0 @@
1
- import unittest
2
- from datetime import datetime
3
-
4
- from django.conf import settings
5
-
6
- from .. import items
7
- from ..session import WialonSession
8
-
9
-
10
- class WialonResourceTestCase(unittest.TestCase):
11
- def setUp(self) -> None:
12
- if not hasattr(settings, "WIALON_TOKEN"):
13
- self.fail("'WIALON_TOKEN' setting is required.")
14
- if not hasattr(settings, "WIALON_ADMIN_ID"):
15
- self.fail("'WIALON_ADMIN_ID' setting is required.")
16
-
17
- self.session = WialonSession()
18
- self.session.login(settings.WIALON_TOKEN)
19
- self.test_timestamp = f"{datetime.now():%Y-%m-%d-%H:%M:%S}"
20
- self.test_resource = items.WialonResource(
21
- id=None,
22
- creator_id=str(settings.WIALON_ADMIN_ID),
23
- name=f"test_resource_{self.test_timestamp}",
24
- skip_creator_check=True,
25
- session=self.session,
26
- )
27
-
28
- def tearDown(self) -> None:
29
- self.test_resource.delete()
30
-
31
- def test_resource_is_not_account(self) -> None:
32
- """Tests whether or not a new resource is an account after creation."""
33
- self.assertFalse(self.test_resource.is_account)
34
-
35
- def test_resource_create_account(self) -> None:
36
- self.test_resource.create_account("terminusgps_ext_hist")
37
- self.assertTrue(self.test_resource.is_account)
@@ -25,12 +25,12 @@ class WialonSessionTestCase(unittest.TestCase):
25
25
  def test_session_logout(self) -> None:
26
26
  self.session.login(self.token)
27
27
  self.session.logout()
28
- self.assertEqual(self.session.id, None)
28
+ self.assertIsNone(self.session.id, None)
29
29
 
30
30
  def test_session_bad_call(self) -> None:
31
31
  self.session.login(self.token)
32
32
  response = self.session.wialon_api.core_bad_call({})
33
- self.assertEqual(response, None)
33
+ self.assertIsNone(response)
34
34
  self.session.logout()
35
35
 
36
36
  def test_session_valid_call_count(self) -> None: