clientcentral 12.2.2__tar.gz → 12.3.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.
Files changed (37) hide show
  1. {clientcentral-12.2.2/clientcentral.egg-info → clientcentral-12.3.1}/PKG-INFO +3 -3
  2. {clientcentral-12.2.2 → clientcentral-12.3.1}/README.md +2 -2
  3. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/ticket.py +21 -15
  4. {clientcentral-12.2.2 → clientcentral-12.3.1/clientcentral.egg-info}/PKG-INFO +3 -3
  5. {clientcentral-12.2.2 → clientcentral-12.3.1}/pyproject.toml +1 -1
  6. {clientcentral-12.2.2 → clientcentral-12.3.1}/setup.py +1 -1
  7. {clientcentral-12.2.2 → clientcentral-12.3.1}/tests/test_api.py +4 -3
  8. clientcentral-12.3.1/tests/test_api_mock.py +124 -0
  9. clientcentral-12.2.2/tests/test_api_mock.py +0 -124
  10. {clientcentral-12.2.2 → clientcentral-12.3.1}/AUTHORS.rst +0 -0
  11. {clientcentral-12.2.2 → clientcentral-12.3.1}/LICENSE +0 -0
  12. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/Exceptions.py +0 -0
  13. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/__init__.py +0 -0
  14. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/clientcentral.py +0 -0
  15. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/Button.py +0 -0
  16. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/Change.py +0 -0
  17. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/ChangeEvent.py +0 -0
  18. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/Comment.py +0 -0
  19. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/Role.py +0 -0
  20. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/Status.py +0 -0
  21. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/TicketEvent.py +0 -0
  22. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/TicketType.py +0 -0
  23. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/User.py +0 -0
  24. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/model/__init__.py +0 -0
  25. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/query.py +0 -0
  26. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/roles.py +0 -0
  27. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/ticketformatting.py +0 -0
  28. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral/users_client.py +0 -0
  29. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/SOURCES.txt +0 -0
  30. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/dependency_links.txt +0 -0
  31. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/entry_points.txt +0 -0
  32. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/not-zip-safe +0 -0
  33. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/requires.txt +0 -0
  34. {clientcentral-12.2.2 → clientcentral-12.3.1}/clientcentral.egg-info/top_level.txt +0 -0
  35. {clientcentral-12.2.2 → clientcentral-12.3.1}/setup.cfg +0 -0
  36. {clientcentral-12.2.2 → clientcentral-12.3.1}/tests/__init__.py +0 -0
  37. {clientcentral-12.2.2 → clientcentral-12.3.1}/tests/test_async_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clientcentral
3
- Version: 12.2.2
3
+ Version: 12.3.1
4
4
  Summary: Client Central Python API.
5
5
  Home-page: https://github.com/EPI-USE-Labs/client-central-python-api
6
6
  Author: Thomas Scholtz
@@ -18,7 +18,7 @@ License-File: LICENSE
18
18
  License-File: AUTHORS.rst
19
19
 
20
20
  # clientcentral-api-python
21
- [![version](https://img.shields.io/badge/version-12.2.2-brightgreen.svg)]()
21
+ [![version](https://img.shields.io/badge/version-12.3.1-brightgreen.svg)]()
22
22
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
23
23
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
24
24
 
@@ -33,7 +33,7 @@ pip install --user --upgrade clientcentral
33
33
 
34
34
  A specific version can also be installed by adding the tag:
35
35
  ```bash
36
- pip install --user --upgrade clientcentral==12.2.2
36
+ pip install --user --upgrade clientcentral==12.3.1
37
37
  ```
38
38
 
39
39
  # Requirements
@@ -1,5 +1,5 @@
1
1
  # clientcentral-api-python
2
- [![version](https://img.shields.io/badge/version-12.2.2-brightgreen.svg)]()
2
+ [![version](https://img.shields.io/badge/version-12.3.1-brightgreen.svg)]()
3
3
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
4
4
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
5
5
 
@@ -14,7 +14,7 @@ pip install --user --upgrade clientcentral
14
14
 
15
15
  A specific version can also be installed by adding the tag:
16
16
  ```bash
17
- pip install --user --upgrade clientcentral==12.2.2
17
+ pip install --user --upgrade clientcentral==12.3.1
18
18
  ```
19
19
 
20
20
  # Requirements
@@ -49,7 +49,7 @@ class Ticket(object):
49
49
  owner: Optional[User] = None,
50
50
  creator: Optional[User] = None,
51
51
  user_watchers: Optional[List[User]] = None,
52
- # email_watchers: Optional[List[str]] = None,
52
+ email_watchers: Optional[List[str]] = None,
53
53
  priority: Optional[int] = None,
54
54
  assignee: Optional[str] = None,
55
55
  related_tickets: Optional[List[int]] = None,
@@ -68,7 +68,7 @@ class Ticket(object):
68
68
  # self.change_events = []
69
69
  # self.comments = []
70
70
  self.user_watchers = [] if user_watchers is None else user_watchers
71
- # self.email_watchers = [] if email_watchers is None else email_watchers
71
+ self.email_watchers = [] if email_watchers is None else email_watchers
72
72
 
73
73
  self.custom_fields_attributes = (
74
74
  [] if custom_fields_attributes is None else custom_fields_attributes
@@ -138,6 +138,7 @@ class Ticket(object):
138
138
  owner: Optional[User] = None,
139
139
  creator: Optional[User] = None,
140
140
  user_watchers: Optional[List[User]] = None,
141
+ email_watchers: Optional[List[str]] = None,
141
142
  priority: Optional[int] = None,
142
143
  assignee: Optional[str] = None,
143
144
  related_tickets: Optional[List[int]] = None,
@@ -162,6 +163,7 @@ class Ticket(object):
162
163
  owner=owner,
163
164
  creator=creator,
164
165
  user_watchers=user_watchers,
166
+ email_watchers=email_watchers,
165
167
  priority=priority,
166
168
  assignee=assignee,
167
169
  related_tickets=related_tickets,
@@ -359,7 +361,10 @@ class Ticket(object):
359
361
  )
360
362
 
361
363
  self.account_vp = result["data"]["account"]["id"]
362
- self.customer_user_vp = result["data"]["customer_user"]["id"]
364
+
365
+ # Customer user / Owner can be null
366
+ if result["data"]["customer_user"]:
367
+ self.customer_user_vp = result["data"]["customer_user"]["id"]
363
368
 
364
369
  self.project_id = result["data"]["project"]["id"]
365
370
  self.workspace_id = result["data"]["workspace"]["id"]
@@ -430,6 +435,9 @@ class Ticket(object):
430
435
  user_watcher.title = user["title"]["name"]
431
436
  self.user_watchers.append(user_watcher)
432
437
 
438
+ if result["data"]["email_watchers"]:
439
+ self.email_watchers = [email for email in result["data"]["email_watchers"]]
440
+
433
441
  if not hasattr(self, "_change_events_attribute"):
434
442
  setattr(self, "_change_events_attribute", List[ChangeEvent])
435
443
  self._change_events_attribute: List[ChangeEvent] = list()
@@ -513,7 +521,8 @@ class Ticket(object):
513
521
  if not self.user_watchers:
514
522
  self.user_watchers = []
515
523
 
516
- # self.email_watchers = [email for email in result["data"]["email_watcher_emails"]]
524
+ if not self.email_watchers:
525
+ self.email_watchers = []
517
526
 
518
527
  # Update available buttons
519
528
  return self
@@ -544,12 +553,8 @@ class Ticket(object):
544
553
  "custom_fields_attributes": {
545
554
  str(key): value
546
555
  for key, value in enumerate(self.custom_fields_attributes)
547
- }
548
- # Not supported yet
549
- # "email_watcher_emails": self.email_watchers,
550
- # 0 -> Security related
551
- # 1 -> SAP SID
552
- # 2 -> Category [363 -> Other]
556
+ },
557
+ "email_watcher_emails": self.email_watchers
553
558
  }
554
559
  }
555
560
 
@@ -651,10 +656,10 @@ class Ticket(object):
651
656
 
652
657
  return self._event_loop.run_until_complete(future)
653
658
 
654
- # def add_email_watcher(self, email:str, update: bool = True) -> None:
655
- # self.email_watchers.append(email)
656
- # if update:
657
- # self.commit()
659
+ def add_user_watcher_by_email(self, email:str, update: bool = True) -> None:
660
+ self.email_watchers.append(email.strip())
661
+ if update:
662
+ self.commit()
658
663
 
659
664
  def add_user_watcher_by_id(self, user_id: int, update: bool = True) -> None:
660
665
  self.user_watchers.append(
@@ -708,7 +713,7 @@ class Ticket(object):
708
713
  int(related_ticket_id)
709
714
  for related_ticket_id in self._related_tickets_attribute
710
715
  ],
711
- # "email_watchers": self.email_watchers,
716
+ "email_watchers": self.email_watchers,
712
717
  },
713
718
  "ticket_event": {
714
719
  "comment": None,
@@ -792,6 +797,7 @@ class Ticket(object):
792
797
  "user_watchers.last_name",
793
798
  "user_watchers.title",
794
799
  "user_watchers.job_title",
800
+ "email_watchers",
795
801
  "events.event_changes.to_value",
796
802
  "events.event_changes.from_value",
797
803
  "events.internal",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clientcentral
3
- Version: 12.2.2
3
+ Version: 12.3.1
4
4
  Summary: Client Central Python API.
5
5
  Home-page: https://github.com/EPI-USE-Labs/client-central-python-api
6
6
  Author: Thomas Scholtz
@@ -18,7 +18,7 @@ License-File: LICENSE
18
18
  License-File: AUTHORS.rst
19
19
 
20
20
  # clientcentral-api-python
21
- [![version](https://img.shields.io/badge/version-12.2.2-brightgreen.svg)]()
21
+ [![version](https://img.shields.io/badge/version-12.3.1-brightgreen.svg)]()
22
22
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
23
23
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
24
24
 
@@ -33,7 +33,7 @@ pip install --user --upgrade clientcentral
33
33
 
34
34
  A specific version can also be installed by adding the tag:
35
35
  ```bash
36
- pip install --user --upgrade clientcentral==12.2.2
36
+ pip install --user --upgrade clientcentral==12.3.1
37
37
  ```
38
38
 
39
39
  # Requirements
@@ -3,7 +3,7 @@
3
3
  name = "cz_conventional_commits"
4
4
  update_changelog_on_bump = true
5
5
  bump_message = "bump: release $current_version to $new_version [skip-ci]"
6
- version = "12.2.2"
6
+ version = "12.3.1"
7
7
  tag_format = "v$version"
8
8
  version_files = [
9
9
  "setup.py",
@@ -42,7 +42,7 @@ setup(
42
42
  test_suite='tests',
43
43
  tests_require=test_requirements,
44
44
  url='https://github.com/EPI-USE-Labs/client-central-python-api',
45
- version='12.2.2',
45
+ version='12.3.1',
46
46
  zip_safe=False,
47
47
  data_files=[('.', [])],
48
48
  python_requires='>=3.9'
@@ -339,9 +339,10 @@ def test_add_user_watcher():
339
339
  assert len(ticket.user_watchers) == 1
340
340
 
341
341
  # Test adding an email watcher
342
- # ticket.add_user_watcher_by_email("test@example.com")
343
- # ticket.refresh()
344
- # assert ticket.user_watchers[1].email == "test@example.com"
342
+ ticket.add_user_watcher_by_email("test@example.com")
343
+ ticket.refresh()
344
+ print(ticket.email_watchers)
345
+ assert ticket.email_watchers[0] == "test@example.com"
345
346
 
346
347
 
347
348
  def test_assignee_user_by_id():
@@ -0,0 +1,124 @@
1
+ import pytest
2
+ from aiohttp import web
3
+
4
+ import asyncio
5
+ import clientcentral.query as operators
6
+ from clientcentral.clientcentral import ClientCentral
7
+ from clientcentral.model.Status import Status
8
+ from clientcentral.Exceptions import (
9
+ ButtonNotAvailable,
10
+ ButtonRequiresComment,
11
+ HTTPError,
12
+ DateFormatInvalid,
13
+ )
14
+
15
+ import aiohttp
16
+ import asyncio
17
+ from aioresponses import aioresponses
18
+
19
+ import json
20
+
21
+ async_cc = ClientCentral(
22
+ production=False,
23
+ token="12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB",
24
+ run_async=True,
25
+ )
26
+
27
+
28
+ @pytest.fixture
29
+ def mock_aioresponse():
30
+ with aioresponses() as m:
31
+ yield m
32
+
33
+
34
+ get_by_id_requst_url = "https://qa.clientcentral.io/api/v1/tickets/123.json?select=subject%252Cdescription%252Cpriority.name%252Cstatus.name%252Cstatus.closed%252Cevents.event_changes.name%252Ccustomer_user.%252A%252Ctype.name%252Cevents.comment%252Cevents.created_by_user.first_name%252Cevents.created_by_user.last_name%252Cevents.created_by_user.title%252Cevents.created_by_user.job_title%252Cevents.created_by_user.email%252Cevents.created_at%252Ccreated_by_user.email%252Ccreated_by_user.title%252Ccreated_by_user.job_title%252Ccreated_by_user.first_name%252Ccreated_by_user.last_name%252Cuser_watchers.email%252Cuser_watchers.first_name%252Cuser_watchers.last_name%252Cuser_watchers.title%252Cuser_watchers.job_title%252Cemail_watchers%252Cevents.event_changes.to_value%252Cevents.event_changes.from_value%252Cevents.internal%252Cassignee%252C%252A&token=12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB"
35
+
36
+ get_by_id_raw_response = '{"data":{"id":123,"type":{"id":9,"_type":"TicketType","name":"Service request"},"project":{"id":43,"_type":"TicketProject"},"workspace":{"id":87,"_type":"Workspace"},"created_by_user":{"id":14012,"_type":"User","title":{"id":5,"name":"master","human_name":"Master","_type":"Title"},"email":"thomas@labs.epiuse.com","first_name":"Thomas","last_name":"Scholtz","job_title":"Software Engineer"},"status":{"id":1,"_type":"TicketStatus","closed":false,"name":"New"},"priority":{"id":3,"_type":"TicketPriority","name":"P3 Medium"},"account":{"id":1,"_type":"Account"},"customer_user":{"id":14012,"_type":"User","account":{"id":1,"_type":"Account"},"roles":[{"id":352,"_type":"Role"},{"id":1850,"_type":"Role"},{"id":10187,"_type":"Role"},{"id":12160,"_type":"Role"},{"id":12680,"_type":"Role"},{"id":12744,"_type":"Role"},{"id":13153,"_type":"Role"},{"id":13159,"_type":"Role"},{"id":13290,"_type":"Role"},{"id":13293,"_type":"Role"},{"id":13320,"_type":"Role"},{"id":13396,"_type":"Role"},{"id":13410,"_type":"Role"},{"id":13696,"_type":"Role"},{"id":13697,"_type":"Role"},{"id":13830,"_type":"Role"},{"id":14459,"_type":"Role"},{"id":14490,"_type":"Role"}],"profile":{"id":14008,"_type":"UserProfile"},"email_campaigns":[{"id":11,"_type":"EmailCampaign"},{"id":14,"_type":"EmailCampaign"},{"id":17,"_type":"EmailCampaign"},{"id":20,"_type":"EmailCampaign"},{"id":23,"_type":"EmailCampaign"},{"id":26,"_type":"EmailCampaign"},{"id":29,"_type":"EmailCampaign"},{"id":32,"_type":"EmailCampaign"},{"id":35,"_type":"EmailCampaign"},{"id":37,"_type":"EmailCampaign"}],"title":{"id":5,"name":"master","human_name":"Master","_type":"Title"},"email":"thomas@labs.epiuse.com","first_name":"Thomas","last_name":"Scholtz","locked":false,"last_sign_in_at":"2021-08-05T15:03:53Z","locale":"en","number":13962,"office_number":"","mobile_number":"+27780360680","job_title":"Software Engineer","activities_count":1362,"activities_temporal_count":431,"name":"Thomas Scholtz","solution_field":[]},"assignee":{"id":12744,"_type":"Role"},"reported_version":null,"reported_build":null,"target_version":null,"target_build":null,"sla_policy":null,"events":[{"id":1178337,"_type":"TicketEvent","created_by_user":null,"event_changes":[{"id":1078317,"_type":"TicketEventChange","name":"assignee","from_value":"","to_value":"Role:12744"}],"comment":"","internal":true,"created_at":"2021-08-05T14:54:07Z"}],"attachments":[],"user_watchers":[], "email_watchers": [],"role_watchers":[],"sla":null,"time_log_entries":[],"original_locale":null,"subject":"Some magical test ticket","description":"<div>TEST</div>","internal":false,"created_at":"2021-08-05T14:54:07Z","updated_at":"2021-08-05T14:54:08Z","created_by_name":null,"created_by_email":null,"responded_at":"2021-08-05T14:54:07Z","resolved_at":null,"assignee_roles":[{"id":12744,"_type":"Role"}],"last_event":{"id":1178337,"_type":"TicketEvent"},"last_user_event":null,"previous_status":null,"offering_accesses":[{"id":45390,"_type":"OfferingAccess"},{"id":40741,"_type":"OfferingAccess"}],"related_tickets":[],"time_log_entries_duration":0,"visible_to_customer":true,"slo_sys_required":null,"existing_customer":null,"ccat_related_tp":null,"motivation_no_labs_system":null,"sloa_reviewer":null,"slo_cloud_storage":null,"slo_sap_source":null,"testing":[],"deal_contact_list":[],"test_attendance":[],"test_count":null,"delivery_type":null,"doc_update_required":null,"deal_start_date":null,"ms_approval_sbg":[],"test_field_3":null,"qg_version":null,"test_api":[],"supported_sap_version":[],"sbsa_delivery_date":null,"sbsa_nr_employees":null,"ccat_tp_info":[],"sa2_system_product_info":[],"previous_assignee":null,"due_date":null,"test_field_2":null,"test_start":null,"internal_it_category":{"id":374,"name":"Other","_type":370},"test_training_name":[],"ticket_test":null,"transport_number":null,"vm_milestone":null,"sku_list":[],"ccat_tp_status":[],"license_exchange_comment":null,"sa2_engagement_context":null,"sa2_system_reports_for_review":[],"cancellation_reason_b":null,"delivery_date":null,"billing_address":null,"lt_oap_ref":null,"eval_agrmnt":[],"solution":null,"sprint_start_date":null,"target_date":null,"sources_required":null,"twb_proj_number":null,"sa2_web_ticket":null,"ms_retainer":null,"sbsa_ecc_sid":[],"sa2_abap_ticket":null,"sbsa_system_type":null,"ms_category":null,"screenshots_1":[],"license_extension_request":[],"sa2_test_qa_effort":null,"sap_tested_on":[],"sa2_hcm_review_perspectives_other":null,"sbsa_country":null,"sbsa_functional_area":null,"sbsa_tp_approval":[],"license_change_reason":null,"up_team":null,"sbsa_approvals":[],"installation_no_change_reason":null,"quote_optional":null,"sbsa_cr_number":null,"ccat_tp_scenario":null,"ccat_tp_type":null,"sbsa_change_reason":null,"test_ticket":null,"sbsa_resources":[],"sa2_s4ha_review_perspectives":[],"sap_land":null,"cc_link":null,"netsuite_customer":null,"po_contact_email":null,"quote":null,"sbsa_batch_name":null,"text_type":null,"sbsa_test_cycle":null,"sbsa_test_env":null,"sbsa_test_case_line_type":[],"sbsa_target":[],"sbsa_category":null,"test_field":[],"sa2_dsm_review_perspectives_other":null,"sa2_s4h_review_perspectives_other":null,"sa2_slo_review_perspectives_other":null,"sa2_hcma_review_perspectives":[],"sbsa_tp_basis_approval":null,"sa_reported_build":null,"sbsa_batch_boolean":null,"netsuite_bill_to_customer":null,"notes":null,"cla_scope":[],"footprints_number":null,"regr_test_status":null,"dev_transport":null,"sbsa_defect_type":null,"sbsa_project_number":null,"pending":null,"invoice_number":null,"internal_it_affected_users":[{"id":14012,"_type":"User"}],"sa_engagement_start_date":null,"oap_category":[],"patch_status":null,"patch_type":null,"rank":null,"sap_sid":null,"test_steps":null,"transport_date":null,"cc_category":null,"sa2_sloa_review_perspectives":[],"ccat_failed_tp":null,"sbsa_tp_technical_approval":null,"workload":null,"auto_generate_eval_key":null,"sbsa_incident_number":null,"est_cost":null,"test_case_id":null,"valid_for_build":null,"valid_for_release":[],"basis_customer":null,"cancellation_reason":null,"euuk_project_name":null,"euuk_project_type":[],"euuk_target_date":null,"correction":null,"internal_mac_address":null,"invoice_paid":null,"steps":null,"ms_atuo_rating":null,"ms_landscape":null,"sloa_status":null,"system_owner":null,"internal_mailing_list_name":null,"ms_centos_version":[],"proj_related":null,"security_related":false,"file_type":[],"git_branch":null,"ms_cr_category":null,"prod_dev_lead":null,"reseller":null,"screenshots":[],"sow_draft":[],"supported_sap_version_new":[],"upsource_id":null,"region":[],"language_review_status":null,"sa_data_file_version":null,"categorization_of_change":null,"defect_classification":null,"est_slo_end":null,"legal_agrmnt":[],"service_owner":null,"dischem_fnr_sid":[],"escalation_line":null,"build":null,"ms_backup":[],"atf_replicate_issue_script":null,"eula_addendnum":[],"ms_testers":[],"changelog_text":null,"po_contact_telno":null,"collector":null,"due_date_cr":null,"campaign":null,"sap_version":[],"ms_linux_comp":null,"pex_portal_category":null,"scheduled_time":null,"slo_classification":null,"terminate_user":[],"new_sku_display_name":null,"dsm_oap_analysis_type":[],"prerequisites":null,"account_customer":null,"slo_sap_target":null,"kb_used":[],"dsm_product":null,"new_sku_name":null,"sku_product":null,"hr_category":null,"isphere_category":null,"ms_linux_dis":null,"ms_sap_product_sp":null,"product":[],"test_effort":[],"vm_category":null,"change_control":[],"downtime_required":null,"euuk_start_date":null,"ms_solution_partner":null,"project_contact":null,"dual_maintained":[],"exp_cat":null,"git_branch_from":null,"ignore_errors":null,"ms_os":null,"strict_import_time":null,"estimated_hours":null,"developer":null,"product_portfolio":null,"bifrost_source_control":[],"exp_currency":null,"iow_system_type":null,"platform":null,"target_product":null,"has_parameters":null,"dischem_fiori_sid":[],"dischem_solman_sid":[],"include_in_change_log":null,"parent":null,"db_size":null,"expro_build_number":null,"expro_data_dependent":null,"images":null,"ms_db2_v":null,"abap_program":[],"collector_type":null,"data_file":[],"ms_fp":null,"ms_os_db2":[],"sku_change":[],"sku_name":null,"ms_sap_patch":null,"marketing_request_type":null,"assigned_tester":null,"build_tested":null,"flow_app":null,"host_name":null,"milestone":null,"mt_customer_number":null,"pex_p_milestone":null,"sap_area":null,"master_ticket":null,"origin":null,"qcs_task_type":null,"client_central_suggestion":null,"code_reviewer":null,"ccat_system_type":null,"change_frequency":null,"data_previews":[],"eula_signed_a":[],"license_key_days":null,"customer_action":null,"dischem_projects":null,"end_window":null,"incident_ref":null,"internal_it_automatic_access_request_affected_user":null,"languages":[],"ms_comp":null,"ms_linux_other":null,"sa_transport_number":null,"dischem_ecc_sid":[],"dischem_ewm_sid":[],"doc_type":[],"internal_it_vpn_choice":null,"temporary_workaround":null,"dischem_system_type":null,"internal_it_automatic_access_request":null,"qa_lead":[],"abap_class":[],"abap_method_dev_int_lib":[],"abap_method_imp":[],"abap_package":[],"aberdare_ecc_sid":[],"aberdare_system_type":null,"at_milestone":[],"ccat_ecc_sid":[],"change_location":null,"adapter_generator_source_file":[],"atf_script_expected_to_pass":null,"auto_product_tickets":null,"azure_work_item_id":null,"bifrost_milestone":null,"euuk_system":[],"exp_approver":null,"flow_milestone":null,"frequency_of_change":null,"iow_ecc_sid":[],"ms_auto_affected_customer":null,"ms_auto_products":null,"ms_changelink":null,"ms_changemodel":null,"ms_comp_version":null,"ms_db":null,"ms_db2_v2":[],"ms_patch_type":null,"ms_prod":null,"ms_rhel_version":[],"ms_sap_product":null,"ms_suse_version":[],"ms_windows":[],"oap_engine_category":[],"expected_end_date":null,"regression_testing":[],"rms_del_entries":null,"invoice_approved_by":null,"invoice_contact_email":null,"invoice_contact_name":null,"invoice_contact_telno":null,"invoice_issued":null,"rms_tags":[],"sa2_backup_tp_num":null,"sa2_code_rev_effort":null,"sa2_code_tp_num":null,"sa2_content_tp_num":null,"sa2_del_tp_num":null,"sa2_grouping":[],"licence_req_type":null,"ms_backup_retention":null,"ms_hostname":null,"ms_inctoprob":null,"new_sku_inc_accnt":null,"payment_due":null,"pmnt_date":null,"po_contact_name":null,"po_file":[],"po_received":null,"prod_dev_lead_sku":null,"project_active":null,"sap_change_control":null,"sku_display_name":null,"sku_inc_accnt":null,"dischem_bw_sid":[],"dischem_crm_sid":[],"dischem_full_landscape":[],"dischem_hr_sid":[],"dischem_sandbox_sid":[],"dischem_test_sid":[],"est_slo_start":null,"eu_uk_customer_if_external":null,"project_notes":null,"qa_tester":null,"quote_signed":[],"quote_signed_non_required":[],"retestable":null,"slo_type":null,"solution_attachment":[],"vat_number":null,"sources":null,"supports_field_sets":null,"tech_collector_name":null,"sow_ref":null,"splunk_component":null,"start_window":null,"test_field1":null,"transport_ids":null,"test_field_1":null,"ui_mock_ups":[],"word_count":null}}'
37
+
38
+ get_buttons_avail_request_url = "https://qa.clientcentral.io/api/v1/tickets/123/available_buttons.json?token=12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB"
39
+ get_buttons_avail_response = '{"page":1,"more":false,"total_pages":1,"data":[{"id":477,"colour":{"id":4,"name":"neutral","human_name":"Neutral","_type":"StatusColour"},"agent_only":false,"require_comment":true,"enabled":true,"name":"Comment"},{"id":478,"colour":{"id":1,"name":"positive","human_name":"Positive","_type":"StatusColour"},"agent_only":true,"require_comment":false,"enabled":true,"name":"Grab"}]}'
40
+
41
+
42
+ def test_incorrect_date_format_request(mock_aioresponse):
43
+ ticket_response_body_dict = json.loads(get_by_id_raw_response)
44
+ ticket_response_body_dict["data"]["created_at"] = "2021-01-01 00:00:00 UTC"
45
+
46
+ mock_aioresponse.get(
47
+ get_by_id_requst_url,
48
+ status=200,
49
+ body=json.dumps(ticket_response_body_dict),
50
+ )
51
+
52
+ mock_aioresponse.get(
53
+ get_buttons_avail_request_url,
54
+ status=200,
55
+ body=get_buttons_avail_response,
56
+ )
57
+
58
+ try:
59
+ loop = async_cc._event_loop
60
+ print(loop)
61
+ # assert loop == asyncio.get_running_loop()
62
+ ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
63
+ assert ticket.subject == "Some magical test ticket"
64
+ assert False
65
+ except DateFormatInvalid as e:
66
+ assert True
67
+
68
+
69
+ def test_correct_date_format_1_request(mock_aioresponse):
70
+ ticket_response_body_dict = json.loads(get_by_id_raw_response)
71
+ ticket_response_body_dict["data"]["created_at"] = "2021-01-01T00:00:00Z"
72
+ ticket_response_body_dict["data"]["updated_at"] = "2021-01-01T00:00:00Z"
73
+
74
+ loop = async_cc._event_loop
75
+ mock_aioresponse.get(
76
+ get_by_id_requst_url,
77
+ status=200,
78
+ body=json.dumps(ticket_response_body_dict),
79
+ )
80
+
81
+ mock_aioresponse.get(
82
+ get_buttons_avail_request_url,
83
+ status=200,
84
+ body=get_buttons_avail_response,
85
+ )
86
+
87
+ ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
88
+ assert ticket.subject == "Some magical test ticket"
89
+ assert (
90
+ ticket.created_at.strftime("%Y-%m-%dT%H:%M:%S%z") == "2021-01-01T00:00:00+0000"
91
+ )
92
+ assert (
93
+ ticket.updated_at.strftime("%Y-%m-%dT%H:%M:%S%z") == "2021-01-01T00:00:00+0000"
94
+ )
95
+
96
+
97
+ def test_correct_date_format_2_request(mock_aioresponse):
98
+ ticket_response_body_dict = json.loads(get_by_id_raw_response)
99
+ ticket_response_body_dict["data"]["created_at"] = "2021-01-01T00:00:00.000000Z"
100
+ ticket_response_body_dict["data"]["updated_at"] = "2021-01-01T00:00:00.000000Z"
101
+
102
+ loop = async_cc._event_loop
103
+ mock_aioresponse.get(
104
+ get_by_id_requst_url,
105
+ status=200,
106
+ body=json.dumps(ticket_response_body_dict),
107
+ )
108
+
109
+ mock_aioresponse.get(
110
+ get_buttons_avail_request_url,
111
+ status=200,
112
+ body=get_buttons_avail_response,
113
+ )
114
+
115
+ ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
116
+ assert ticket.subject == "Some magical test ticket"
117
+ assert (
118
+ ticket.created_at.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
119
+ == "2021-01-01T00:00:00.000000+0000"
120
+ )
121
+ assert (
122
+ ticket.updated_at.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
123
+ == "2021-01-01T00:00:00.000000+0000"
124
+ )
@@ -1,124 +0,0 @@
1
- import pytest
2
- from aiohttp import web
3
-
4
- import asyncio
5
- import clientcentral.query as operators
6
- from clientcentral.clientcentral import ClientCentral
7
- from clientcentral.model.Status import Status
8
- from clientcentral.Exceptions import (
9
- ButtonNotAvailable,
10
- ButtonRequiresComment,
11
- HTTPError,
12
- DateFormatInvalid,
13
- )
14
-
15
- import aiohttp
16
- import asyncio
17
- from aioresponses import aioresponses
18
-
19
- import json
20
-
21
- async_cc = ClientCentral(
22
- production=False,
23
- token="12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB",
24
- run_async=True,
25
- )
26
-
27
-
28
- @pytest.fixture
29
- def mock_aioresponse():
30
- with aioresponses() as m:
31
- yield m
32
-
33
-
34
- get_by_id_requst_url = "https://qa.clientcentral.io/api/v1/tickets/123.json?select=subject%252Cdescription%252Cpriority.name%252Cstatus.name%252Cstatus.closed%252Cevents.event_changes.name%252Ccustomer_user.%252A%252Ctype.name%252Cevents.comment%252Cevents.created_by_user.first_name%252Cevents.created_by_user.last_name%252Cevents.created_by_user.title%252Cevents.created_by_user.job_title%252Cevents.created_by_user.email%252Cevents.created_at%252Ccreated_by_user.email%252Ccreated_by_user.title%252Ccreated_by_user.job_title%252Ccreated_by_user.first_name%252Ccreated_by_user.last_name%252Cuser_watchers.email%252Cuser_watchers.first_name%252Cuser_watchers.last_name%252Cuser_watchers.title%252Cuser_watchers.job_title%252Cevents.event_changes.to_value%252Cevents.event_changes.from_value%252Cevents.internal%252Cassignee%252C%252A&token=12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB"
35
-
36
- get_by_id_raw_response = '{"data":{"id":123,"type":{"id":9,"_type":"TicketType","name":"Service request"},"project":{"id":43,"_type":"TicketProject"},"workspace":{"id":87,"_type":"Workspace"},"created_by_user":{"id":14012,"_type":"User","title":{"id":5,"name":"master","human_name":"Master","_type":"Title"},"email":"thomas@labs.epiuse.com","first_name":"Thomas","last_name":"Scholtz","job_title":"Software Engineer"},"status":{"id":1,"_type":"TicketStatus","closed":false,"name":"New"},"priority":{"id":3,"_type":"TicketPriority","name":"P3 Medium"},"account":{"id":1,"_type":"Account"},"customer_user":{"id":14012,"_type":"User","account":{"id":1,"_type":"Account"},"roles":[{"id":352,"_type":"Role"},{"id":1850,"_type":"Role"},{"id":10187,"_type":"Role"},{"id":12160,"_type":"Role"},{"id":12680,"_type":"Role"},{"id":12744,"_type":"Role"},{"id":13153,"_type":"Role"},{"id":13159,"_type":"Role"},{"id":13290,"_type":"Role"},{"id":13293,"_type":"Role"},{"id":13320,"_type":"Role"},{"id":13396,"_type":"Role"},{"id":13410,"_type":"Role"},{"id":13696,"_type":"Role"},{"id":13697,"_type":"Role"},{"id":13830,"_type":"Role"},{"id":14459,"_type":"Role"},{"id":14490,"_type":"Role"}],"profile":{"id":14008,"_type":"UserProfile"},"email_campaigns":[{"id":11,"_type":"EmailCampaign"},{"id":14,"_type":"EmailCampaign"},{"id":17,"_type":"EmailCampaign"},{"id":20,"_type":"EmailCampaign"},{"id":23,"_type":"EmailCampaign"},{"id":26,"_type":"EmailCampaign"},{"id":29,"_type":"EmailCampaign"},{"id":32,"_type":"EmailCampaign"},{"id":35,"_type":"EmailCampaign"},{"id":37,"_type":"EmailCampaign"}],"title":{"id":5,"name":"master","human_name":"Master","_type":"Title"},"email":"thomas@labs.epiuse.com","first_name":"Thomas","last_name":"Scholtz","locked":false,"last_sign_in_at":"2021-08-05T15:03:53Z","locale":"en","number":13962,"office_number":"","mobile_number":"+27780360680","job_title":"Software Engineer","activities_count":1362,"activities_temporal_count":431,"name":"Thomas Scholtz","solution_field":[]},"assignee":{"id":12744,"_type":"Role"},"reported_version":null,"reported_build":null,"target_version":null,"target_build":null,"sla_policy":null,"events":[{"id":1178337,"_type":"TicketEvent","created_by_user":null,"event_changes":[{"id":1078317,"_type":"TicketEventChange","name":"assignee","from_value":"","to_value":"Role:12744"}],"comment":"","internal":true,"created_at":"2021-08-05T14:54:07Z"}],"attachments":[],"user_watchers":[],"role_watchers":[],"sla":null,"time_log_entries":[],"original_locale":null,"subject":"Some magical test ticket","description":"<div>TEST</div>","internal":false,"created_at":"2021-08-05T14:54:07Z","updated_at":"2021-08-05T14:54:08Z","created_by_name":null,"created_by_email":null,"responded_at":"2021-08-05T14:54:07Z","resolved_at":null,"assignee_roles":[{"id":12744,"_type":"Role"}],"last_event":{"id":1178337,"_type":"TicketEvent"},"last_user_event":null,"previous_status":null,"offering_accesses":[{"id":45390,"_type":"OfferingAccess"},{"id":40741,"_type":"OfferingAccess"}],"related_tickets":[],"time_log_entries_duration":0,"visible_to_customer":true,"slo_sys_required":null,"existing_customer":null,"ccat_related_tp":null,"motivation_no_labs_system":null,"sloa_reviewer":null,"slo_cloud_storage":null,"slo_sap_source":null,"testing":[],"deal_contact_list":[],"test_attendance":[],"test_count":null,"delivery_type":null,"doc_update_required":null,"deal_start_date":null,"ms_approval_sbg":[],"test_field_3":null,"qg_version":null,"test_api":[],"supported_sap_version":[],"sbsa_delivery_date":null,"sbsa_nr_employees":null,"ccat_tp_info":[],"sa2_system_product_info":[],"previous_assignee":null,"due_date":null,"test_field_2":null,"test_start":null,"internal_it_category":{"id":374,"name":"Other","_type":370},"test_training_name":[],"ticket_test":null,"transport_number":null,"vm_milestone":null,"sku_list":[],"ccat_tp_status":[],"license_exchange_comment":null,"sa2_engagement_context":null,"sa2_system_reports_for_review":[],"cancellation_reason_b":null,"delivery_date":null,"billing_address":null,"lt_oap_ref":null,"eval_agrmnt":[],"solution":null,"sprint_start_date":null,"target_date":null,"sources_required":null,"twb_proj_number":null,"sa2_web_ticket":null,"ms_retainer":null,"sbsa_ecc_sid":[],"sa2_abap_ticket":null,"sbsa_system_type":null,"ms_category":null,"screenshots_1":[],"license_extension_request":[],"sa2_test_qa_effort":null,"sap_tested_on":[],"sa2_hcm_review_perspectives_other":null,"sbsa_country":null,"sbsa_functional_area":null,"sbsa_tp_approval":[],"license_change_reason":null,"up_team":null,"sbsa_approvals":[],"installation_no_change_reason":null,"quote_optional":null,"sbsa_cr_number":null,"ccat_tp_scenario":null,"ccat_tp_type":null,"sbsa_change_reason":null,"test_ticket":null,"sbsa_resources":[],"sa2_s4ha_review_perspectives":[],"sap_land":null,"cc_link":null,"netsuite_customer":null,"po_contact_email":null,"quote":null,"sbsa_batch_name":null,"text_type":null,"sbsa_test_cycle":null,"sbsa_test_env":null,"sbsa_test_case_line_type":[],"sbsa_target":[],"sbsa_category":null,"test_field":[],"sa2_dsm_review_perspectives_other":null,"sa2_s4h_review_perspectives_other":null,"sa2_slo_review_perspectives_other":null,"sa2_hcma_review_perspectives":[],"sbsa_tp_basis_approval":null,"sa_reported_build":null,"sbsa_batch_boolean":null,"netsuite_bill_to_customer":null,"notes":null,"cla_scope":[],"footprints_number":null,"regr_test_status":null,"dev_transport":null,"sbsa_defect_type":null,"sbsa_project_number":null,"pending":null,"invoice_number":null,"internal_it_affected_users":[{"id":14012,"_type":"User"}],"sa_engagement_start_date":null,"oap_category":[],"patch_status":null,"patch_type":null,"rank":null,"sap_sid":null,"test_steps":null,"transport_date":null,"cc_category":null,"sa2_sloa_review_perspectives":[],"ccat_failed_tp":null,"sbsa_tp_technical_approval":null,"workload":null,"auto_generate_eval_key":null,"sbsa_incident_number":null,"est_cost":null,"test_case_id":null,"valid_for_build":null,"valid_for_release":[],"basis_customer":null,"cancellation_reason":null,"euuk_project_name":null,"euuk_project_type":[],"euuk_target_date":null,"correction":null,"internal_mac_address":null,"invoice_paid":null,"steps":null,"ms_atuo_rating":null,"ms_landscape":null,"sloa_status":null,"system_owner":null,"internal_mailing_list_name":null,"ms_centos_version":[],"proj_related":null,"security_related":false,"file_type":[],"git_branch":null,"ms_cr_category":null,"prod_dev_lead":null,"reseller":null,"screenshots":[],"sow_draft":[],"supported_sap_version_new":[],"upsource_id":null,"region":[],"language_review_status":null,"sa_data_file_version":null,"categorization_of_change":null,"defect_classification":null,"est_slo_end":null,"legal_agrmnt":[],"service_owner":null,"dischem_fnr_sid":[],"escalation_line":null,"build":null,"ms_backup":[],"atf_replicate_issue_script":null,"eula_addendnum":[],"ms_testers":[],"changelog_text":null,"po_contact_telno":null,"collector":null,"due_date_cr":null,"campaign":null,"sap_version":[],"ms_linux_comp":null,"pex_portal_category":null,"scheduled_time":null,"slo_classification":null,"terminate_user":[],"new_sku_display_name":null,"dsm_oap_analysis_type":[],"prerequisites":null,"account_customer":null,"slo_sap_target":null,"kb_used":[],"dsm_product":null,"new_sku_name":null,"sku_product":null,"hr_category":null,"isphere_category":null,"ms_linux_dis":null,"ms_sap_product_sp":null,"product":[],"test_effort":[],"vm_category":null,"change_control":[],"downtime_required":null,"euuk_start_date":null,"ms_solution_partner":null,"project_contact":null,"dual_maintained":[],"exp_cat":null,"git_branch_from":null,"ignore_errors":null,"ms_os":null,"strict_import_time":null,"estimated_hours":null,"developer":null,"product_portfolio":null,"bifrost_source_control":[],"exp_currency":null,"iow_system_type":null,"platform":null,"target_product":null,"has_parameters":null,"dischem_fiori_sid":[],"dischem_solman_sid":[],"include_in_change_log":null,"parent":null,"db_size":null,"expro_build_number":null,"expro_data_dependent":null,"images":null,"ms_db2_v":null,"abap_program":[],"collector_type":null,"data_file":[],"ms_fp":null,"ms_os_db2":[],"sku_change":[],"sku_name":null,"ms_sap_patch":null,"marketing_request_type":null,"assigned_tester":null,"build_tested":null,"flow_app":null,"host_name":null,"milestone":null,"mt_customer_number":null,"pex_p_milestone":null,"sap_area":null,"master_ticket":null,"origin":null,"qcs_task_type":null,"client_central_suggestion":null,"code_reviewer":null,"ccat_system_type":null,"change_frequency":null,"data_previews":[],"eula_signed_a":[],"license_key_days":null,"customer_action":null,"dischem_projects":null,"end_window":null,"incident_ref":null,"internal_it_automatic_access_request_affected_user":null,"languages":[],"ms_comp":null,"ms_linux_other":null,"sa_transport_number":null,"dischem_ecc_sid":[],"dischem_ewm_sid":[],"doc_type":[],"internal_it_vpn_choice":null,"temporary_workaround":null,"dischem_system_type":null,"internal_it_automatic_access_request":null,"qa_lead":[],"abap_class":[],"abap_method_dev_int_lib":[],"abap_method_imp":[],"abap_package":[],"aberdare_ecc_sid":[],"aberdare_system_type":null,"at_milestone":[],"ccat_ecc_sid":[],"change_location":null,"adapter_generator_source_file":[],"atf_script_expected_to_pass":null,"auto_product_tickets":null,"azure_work_item_id":null,"bifrost_milestone":null,"euuk_system":[],"exp_approver":null,"flow_milestone":null,"frequency_of_change":null,"iow_ecc_sid":[],"ms_auto_affected_customer":null,"ms_auto_products":null,"ms_changelink":null,"ms_changemodel":null,"ms_comp_version":null,"ms_db":null,"ms_db2_v2":[],"ms_patch_type":null,"ms_prod":null,"ms_rhel_version":[],"ms_sap_product":null,"ms_suse_version":[],"ms_windows":[],"oap_engine_category":[],"expected_end_date":null,"regression_testing":[],"rms_del_entries":null,"invoice_approved_by":null,"invoice_contact_email":null,"invoice_contact_name":null,"invoice_contact_telno":null,"invoice_issued":null,"rms_tags":[],"sa2_backup_tp_num":null,"sa2_code_rev_effort":null,"sa2_code_tp_num":null,"sa2_content_tp_num":null,"sa2_del_tp_num":null,"sa2_grouping":[],"licence_req_type":null,"ms_backup_retention":null,"ms_hostname":null,"ms_inctoprob":null,"new_sku_inc_accnt":null,"payment_due":null,"pmnt_date":null,"po_contact_name":null,"po_file":[],"po_received":null,"prod_dev_lead_sku":null,"project_active":null,"sap_change_control":null,"sku_display_name":null,"sku_inc_accnt":null,"dischem_bw_sid":[],"dischem_crm_sid":[],"dischem_full_landscape":[],"dischem_hr_sid":[],"dischem_sandbox_sid":[],"dischem_test_sid":[],"est_slo_start":null,"eu_uk_customer_if_external":null,"project_notes":null,"qa_tester":null,"quote_signed":[],"quote_signed_non_required":[],"retestable":null,"slo_type":null,"solution_attachment":[],"vat_number":null,"sources":null,"supports_field_sets":null,"tech_collector_name":null,"sow_ref":null,"splunk_component":null,"start_window":null,"test_field1":null,"transport_ids":null,"test_field_1":null,"ui_mock_ups":[],"word_count":null}}'
37
-
38
- get_buttons_avail_request_url = "https://qa.clientcentral.io/api/v1/tickets/123/available_buttons.json?token=12345-ABCABC-ABCABCABCABCAB-1A_ABCABCABCAB_ABC_ABCABCABCABCABCAB"
39
- get_buttons_avail_response = '{"page":1,"more":false,"total_pages":1,"data":[{"id":477,"colour":{"id":4,"name":"neutral","human_name":"Neutral","_type":"StatusColour"},"agent_only":false,"require_comment":true,"enabled":true,"name":"Comment"},{"id":478,"colour":{"id":1,"name":"positive","human_name":"Positive","_type":"StatusColour"},"agent_only":true,"require_comment":false,"enabled":true,"name":"Grab"}]}'
40
-
41
-
42
- def test_incorrect_date_format_request(mock_aioresponse):
43
- ticket_response_body_dict = json.loads(get_by_id_raw_response)
44
- ticket_response_body_dict["data"]["created_at"] = "2021-01-01 00:00:00 UTC"
45
-
46
- mock_aioresponse.get(
47
- get_by_id_requst_url,
48
- status=200,
49
- body=json.dumps(ticket_response_body_dict),
50
- )
51
-
52
- mock_aioresponse.get(
53
- get_buttons_avail_request_url,
54
- status=200,
55
- body=get_buttons_avail_response,
56
- )
57
-
58
- try:
59
- loop = async_cc._event_loop
60
- print(loop)
61
- # assert loop == asyncio.get_running_loop()
62
- ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
63
- assert ticket.subject == "Some magical test ticket"
64
- assert False
65
- except DateFormatInvalid as e:
66
- assert True
67
-
68
-
69
- def test_correct_date_format_1_request(mock_aioresponse):
70
- ticket_response_body_dict = json.loads(get_by_id_raw_response)
71
- ticket_response_body_dict["data"]["created_at"] = "2021-01-01T00:00:00Z"
72
- ticket_response_body_dict["data"]["updated_at"] = "2021-01-01T00:00:00Z"
73
-
74
- loop = async_cc._event_loop
75
- mock_aioresponse.get(
76
- get_by_id_requst_url,
77
- status=200,
78
- body=json.dumps(ticket_response_body_dict),
79
- )
80
-
81
- mock_aioresponse.get(
82
- get_buttons_avail_request_url,
83
- status=200,
84
- body=get_buttons_avail_response,
85
- )
86
-
87
- ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
88
- assert ticket.subject == "Some magical test ticket"
89
- assert (
90
- ticket.created_at.strftime("%Y-%m-%dT%H:%M:%S%z") == "2021-01-01T00:00:00+0000"
91
- )
92
- assert (
93
- ticket.updated_at.strftime("%Y-%m-%dT%H:%M:%S%z") == "2021-01-01T00:00:00+0000"
94
- )
95
-
96
-
97
- def test_correct_date_format_2_request(mock_aioresponse):
98
- ticket_response_body_dict = json.loads(get_by_id_raw_response)
99
- ticket_response_body_dict["data"]["created_at"] = "2021-01-01T00:00:00.000000Z"
100
- ticket_response_body_dict["data"]["updated_at"] = "2021-01-01T00:00:00.000000Z"
101
-
102
- loop = async_cc._event_loop
103
- mock_aioresponse.get(
104
- get_by_id_requst_url,
105
- status=200,
106
- body=json.dumps(ticket_response_body_dict),
107
- )
108
-
109
- mock_aioresponse.get(
110
- get_buttons_avail_request_url,
111
- status=200,
112
- body=get_buttons_avail_response,
113
- )
114
-
115
- ticket = loop.run_until_complete(async_cc.get_ticket_by_id(123))
116
- assert ticket.subject == "Some magical test ticket"
117
- assert (
118
- ticket.created_at.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
119
- == "2021-01-01T00:00:00.000000+0000"
120
- )
121
- assert (
122
- ticket.updated_at.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
123
- == "2021-01-01T00:00:00.000000+0000"
124
- )
File without changes
File without changes