aplos-nca-saas-sdk 0.0.12__py3-none-any.whl → 0.0.13__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.
Files changed (44) hide show
  1. aplos_nca_saas_sdk/integration_testing/configs/_config_base.py +7 -2
  2. aplos_nca_saas_sdk/integration_testing/configs/app_settings_config.py +29 -29
  3. aplos_nca_saas_sdk/integration_testing/configs/config_sample.json +9 -9
  4. aplos_nca_saas_sdk/integration_testing/configs/file_upload_config.py +1 -1
  5. aplos_nca_saas_sdk/integration_testing/configs/login_config.py +15 -14
  6. aplos_nca_saas_sdk/integration_testing/configs/nca_execution_config.py +1 -1
  7. aplos_nca_saas_sdk/integration_testing/integration_test_base.py +2 -2
  8. aplos_nca_saas_sdk/integration_testing/integration_test_configurations.py +9 -5
  9. aplos_nca_saas_sdk/integration_testing/integration_test_factory.py +1 -1
  10. aplos_nca_saas_sdk/integration_testing/integration_test_response.py +1 -1
  11. aplos_nca_saas_sdk/integration_testing/integration_test_suite.py +10 -3
  12. aplos_nca_saas_sdk/integration_testing/main.py +8 -7
  13. aplos_nca_saas_sdk/integration_testing/readme.md +1 -1
  14. aplos_nca_saas_sdk/integration_testing/tests/app_configuration_test.py +3 -3
  15. aplos_nca_saas_sdk/integration_testing/tests/app_login_test.py +3 -3
  16. aplos_nca_saas_sdk/integration_testing/tests/file_upload_test.py +40 -91
  17. aplos_nca_saas_sdk/integration_testing/tests/nca_analysis_test.py +2 -2
  18. aplos_nca_saas_sdk/integration_testing/tests/validation_test.py +1 -1
  19. aplos_nca_saas_sdk/nca_resources/_api_base.py +44 -0
  20. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_cognito.py +2 -2
  21. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_s3_presigned_payload.py +3 -3
  22. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_s3_presigned_upload.py +28 -22
  23. aplos_nca_saas_sdk/nca_resources/nca_analysis.py +23 -167
  24. aplos_nca_saas_sdk/nca_resources/nca_app_configuration.py +4 -4
  25. aplos_nca_saas_sdk/nca_resources/{nca_login.py → nca_authenticator.py} +23 -20
  26. aplos_nca_saas_sdk/nca_resources/nca_endpoints.py +56 -30
  27. aplos_nca_saas_sdk/nca_resources/nca_file_download.py +130 -0
  28. aplos_nca_saas_sdk/nca_resources/nca_file_upload.py +27 -29
  29. aplos_nca_saas_sdk/nca_resources/nca_validations.py +34 -0
  30. aplos_nca_saas_sdk/run_analysis_execution.py +148 -0
  31. aplos_nca_saas_sdk/utilities/commandline_args.py +29 -13
  32. aplos_nca_saas_sdk/utilities/environment_services.py +3 -2
  33. aplos_nca_saas_sdk/utilities/environment_vars.py +10 -4
  34. aplos_nca_saas_sdk/utilities/file_utility.py +1 -1
  35. aplos_nca_saas_sdk/utilities/http_utility.py +1 -26
  36. aplos_nca_saas_sdk/version.py +1 -1
  37. {aplos_nca_saas_sdk-0.0.12.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/METADATA +1 -1
  38. aplos_nca_saas_sdk-0.0.13.dist-info/RECORD +51 -0
  39. {aplos_nca_saas_sdk-0.0.12.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/licenses/LICENSE +1 -1
  40. aplos_nca_saas_sdk-0.0.12.dist-info/RECORD +0 -47
  41. /aplos_nca_saas_sdk/{files/analysis_files/single_ev/configuration_single_ev.json → sample_files/analysis_files/single_ev/config.json} +0 -0
  42. /aplos_nca_saas_sdk/{files/analysis_files/single_ev/single_ev.csv → sample_files/analysis_files/single_ev/input.csv} +0 -0
  43. /aplos_nca_saas_sdk/{files → sample_files}/analysis_files/single_ev/meta_data.json +0 -0
  44. {aplos_nca_saas_sdk-0.0.12.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/WHEEL +0 -0
@@ -1,5 +1,10 @@
1
- from typing import Dict
2
- from typing import Any
1
+ """
2
+ Copyright 2024-2025 Aplos Analytics
3
+ All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
+ Property of Aplos Analytics, Utah, USA
5
+ """
6
+
7
+ from typing import Dict, Any
3
8
 
4
9
 
5
10
  class ConfigBase:
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -8,26 +8,26 @@ from typing import List, Dict, Any
8
8
  from aplos_nca_saas_sdk.integration_testing.configs._config_base import ConfigBase
9
9
 
10
10
 
11
- class ApplicationDomainConfig(ConfigBase):
11
+ class ApplicationHostConfig(ConfigBase):
12
12
  """
13
- Application Domain: Defines the domains that the application configuration tests will check against
13
+ Application host: Defines the domains that the application configuration tests will check against
14
14
 
15
15
  """
16
16
 
17
- def __init__(self, domain: str | None = None):
17
+ def __init__(self, host: str | None = None):
18
18
  super().__init__()
19
- self.__domain: str | None = domain
19
+ self.__host: str | None = host
20
20
 
21
21
  @property
22
- def domain(self) -> str:
23
- """The domain to validate"""
24
- if self.__domain is None:
25
- raise RuntimeError("Domain is not set")
26
- return self.__domain
22
+ def host(self) -> str:
23
+ """The host to validate"""
24
+ if self.__host is None:
25
+ raise RuntimeError("host is not set")
26
+ return self.__host
27
27
 
28
- @domain.setter
29
- def domain(self, value: str):
30
- self.__domain = value
28
+ @host.setter
29
+ def host(self, value: str):
30
+ self.__host = value
31
31
 
32
32
 
33
33
  class ApplicationDomainConfigs(ConfigBase):
@@ -38,19 +38,19 @@ class ApplicationDomainConfigs(ConfigBase):
38
38
 
39
39
  def __init__(self):
40
40
  super().__init__()
41
- self.__domains: List[ApplicationDomainConfig] = []
41
+ self.__hosts: List[ApplicationHostConfig] = []
42
42
 
43
43
  @property
44
- def list(self) -> List[ApplicationDomainConfig]:
44
+ def list(self) -> List[ApplicationHostConfig]:
45
45
  """List the logins"""
46
- return self.__domains
46
+ return self.__hosts
47
47
 
48
- def add(self, *, domain: str, enabled: bool = True):
48
+ def add(self, *, host: str, enabled: bool = True):
49
49
  """Add a loging"""
50
- app_domain = ApplicationDomainConfig()
51
- app_domain.domain = domain
50
+ app_domain = ApplicationHostConfig()
51
+ app_domain.host = host
52
52
  app_domain.enabled = enabled
53
- self.__domains.append(app_domain)
53
+ self.__hosts.append(app_domain)
54
54
 
55
55
  def load(self, test_config: Dict[str, Any]):
56
56
  """Load the logins from a list of dictionaries"""
@@ -58,13 +58,13 @@ class ApplicationDomainConfigs(ConfigBase):
58
58
  super().load(test_config)
59
59
  domains: List[Dict[str, Any]] = test_config.get("domains", [])
60
60
 
61
- domain: Dict[str, Any]
62
- for domain in domains:
63
- app_domain = ApplicationDomainConfig()
64
- app_domain.domain = domain.get("domain", None)
65
- app_domain.enabled = bool(domain.get("enabled", True))
61
+ host: Dict[str, Any]
62
+ for host in domains:
63
+ app_domain = ApplicationHostConfig()
64
+ app_domain.host = host.get("host", None)
65
+ app_domain.enabled = bool(host.get("enabled", True))
66
66
 
67
- self.__domains.append(app_domain)
67
+ self.__hosts.append(app_domain)
68
68
 
69
69
 
70
70
  class ApplicationSettings(ConfigBase):
@@ -75,12 +75,12 @@ class ApplicationSettings(ConfigBase):
75
75
 
76
76
  def __init__(self):
77
77
  super().__init__()
78
- self.__domains: ApplicationDomainConfigs = ApplicationDomainConfigs()
78
+ self.__hosts: ApplicationDomainConfigs = ApplicationDomainConfigs()
79
79
 
80
80
  @property
81
81
  def domains(self) -> ApplicationDomainConfigs:
82
- """List of the domain"""
83
- return self.__domains
82
+ """List of the host"""
83
+ return self.__hosts
84
84
 
85
85
  def load(self, test_config: Dict[str, Any]):
86
86
  """Load the domains from the config"""
@@ -3,14 +3,14 @@
3
3
  "purpose": "Tests the application configuration endpoints",
4
4
  "domains": [
5
5
  {
6
- "domain": "api.example.com",
6
+ "host": "api.example.com",
7
7
  "expected_results": {
8
8
  "status_code": 200
9
9
  },
10
10
  "enabled": true
11
11
  },
12
12
  {
13
- "domain": "XXXXXXXXXXXXXXXXXXXXX",
13
+ "host": "XXXXXXXXXXXXXXXXXXXXX",
14
14
  "expected_results": {
15
15
  "status_code": 403
16
16
  },
@@ -24,13 +24,13 @@
24
24
  {
25
25
  "username": "foo",
26
26
  "password": "barr",
27
- "domain": "api.example.com",
27
+ "host": "api.example.com",
28
28
  "roles": []
29
29
  },
30
30
  {
31
31
  "username": "XXXXXXXXXXXXXXXXXXXXX",
32
32
  "password": "XXXXXXXXXXXXXXXXXXXXX",
33
- "domain": "XXXXXXXXXXXXXXXXXXXXX",
33
+ "host": "XXXXXXXXXXXXXXXXXXXXX",
34
34
  "roles": [
35
35
  "XXXXXXXXXXXXXXXXXXXXX"
36
36
  ],
@@ -48,7 +48,7 @@
48
48
  "purpose": "optional: if present this login is used, unless a specific login is defined for the test",
49
49
  "username": "foo",
50
50
  "password": "bar",
51
- "domain": "api.example.com"
51
+ "host": "api.example.com"
52
52
  },
53
53
  "files": [
54
54
  {
@@ -60,7 +60,7 @@
60
60
  "purpose": "optional: if present tests an upload for a specific user",
61
61
  "username": "XXXXXXXXXXXXXXXXXXXXX",
62
62
  "password": "XXXXXXXXXXXXXXXXXXXXX",
63
- "domain": "XXXXXXXXXXXXXXXXXXXXX"
63
+ "host": "XXXXXXXXXXXXXXXXXXXXX"
64
64
  }
65
65
  }
66
66
  ]
@@ -70,7 +70,7 @@
70
70
  "login": {
71
71
  "username": "XXXXXXXXXXXXXXXXXXXXX",
72
72
  "password": "XXXXXXXXXXXXXXXXXXXXX",
73
- "domain": "XXXXXXXXXXXXXXXXXXXXX"
73
+ "host": "XXXXXXXXXXXXXXXXXXXXX"
74
74
  },
75
75
  "output_dir": "XXXXXXXXXXXXXXXXXXXXX",
76
76
  "analyses": [
@@ -90,7 +90,7 @@
90
90
  "login": {
91
91
  "username": "XXXXXXXXXXXXXXXXXXXXX",
92
92
  "password": "XXXXXXXXXXXXXXXXXXXXX",
93
- "domain": "XXXXXXXXXXXXXXXXXXXXX"
93
+ "host": "XXXXXXXXXXXXXXXXXXXXX"
94
94
  },
95
95
  "expected_results": {
96
96
  "status_code": 200
@@ -103,7 +103,7 @@
103
103
  "login": {
104
104
  "username": "XXXXXXXXXXXXXXXXXXXXX",
105
105
  "password": "XXXXXXXXXXXXXXXXXXXXX",
106
- "domain": "XXXXXXXXXXXXXXXXXXXXX"
106
+ "host": "XXXXXXXXXXXXXXXXXXXXX"
107
107
  },
108
108
  "expected_results": {
109
109
  "status_code": 200
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -18,13 +18,13 @@ class LoginConfig(ConfigBase):
18
18
  self,
19
19
  username: Optional[str] = None,
20
20
  passord: Optional[str] = None,
21
- domain: Optional[str] = None,
21
+ host: Optional[str] = None,
22
22
  roles: Optional[List[str]] = None,
23
23
  ):
24
24
  super().__init__()
25
25
  self.__username: Optional[str] = username
26
26
  self.__password: Optional[str] = passord
27
- self.__domain: Optional[str] = domain
27
+ self.__host: Optional[str] = host
28
28
  self.__roles: List[str] = roles if roles is not None else []
29
29
 
30
30
  @property
@@ -48,14 +48,15 @@ class LoginConfig(ConfigBase):
48
48
  self.__password = value
49
49
 
50
50
  @property
51
- def domain(self) -> str:
52
- if self.__domain is None:
53
- raise RuntimeError("Domain is not set")
54
- return self.__domain
51
+ def host(self) -> str:
52
+ """API Host"""
53
+ if self.__host is None:
54
+ raise RuntimeError("Host is not set")
55
+ return self.__host
55
56
 
56
- @domain.setter
57
- def domain(self, value: str):
58
- self.__domain = value
57
+ @host.setter
58
+ def host(self, value: str):
59
+ self.__host = value
59
60
 
60
61
  @property
61
62
  def roles(self) -> List[str]:
@@ -84,12 +85,12 @@ class LoginConfigs(ConfigBase):
84
85
  """List the logins"""
85
86
  return self.__logins
86
87
 
87
- def add(self, *, username: str, password: str, domain: str, enabled: bool = True):
88
+ def add(self, *, username: str, password: str, host: str, enabled: bool = True):
88
89
  """Add a loging"""
89
90
  login = LoginConfig()
90
91
  login.username = username
91
92
  login.password = password
92
- login.domain = domain
93
+ login.host = host
93
94
  login.enabled = enabled
94
95
  self.__logins.append(login)
95
96
 
@@ -111,8 +112,8 @@ class LoginConfigs(ConfigBase):
111
112
  if login_config is not None:
112
113
  username = login_config.get("username", None)
113
114
  password = login_config.get("password", None)
114
- domain = login_config.get("domain", None)
115
+ host = login_config.get("host", None)
115
116
  enabled = login_config.get("enabled", True)
116
- login = LoginConfig(username, password, domain)
117
+ login = LoginConfig(username, password, host)
117
118
  login.enabled = enabled
118
119
  return login
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,11 +1,11 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
- from typing import Dict, Any, List
8
7
  from abc import ABC, abstractmethod
8
+ from typing import List
9
9
 
10
10
  from aplos_nca_saas_sdk.integration_testing.integration_test_configurations import (
11
11
  TestConfiguration,
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -9,9 +9,13 @@ from typing import Any, Dict
9
9
  from aplos_nca_saas_sdk.integration_testing.configs.app_settings_config import (
10
10
  ApplicationSettings,
11
11
  )
12
- from aplos_nca_saas_sdk.integration_testing.configs.file_upload_config import FileUploadConfigs
12
+ from aplos_nca_saas_sdk.integration_testing.configs.file_upload_config import (
13
+ FileUploadConfigs,
14
+ )
13
15
  from aplos_nca_saas_sdk.integration_testing.configs.login_config import LoginConfigs
14
- from aplos_nca_saas_sdk.integration_testing.configs.nca_execution_config import NCAExecutionConfigs
16
+ from aplos_nca_saas_sdk.integration_testing.configs.nca_execution_config import (
17
+ NCAExecutionConfigs,
18
+ )
15
19
 
16
20
 
17
21
  class TestConfiguration:
@@ -25,7 +29,7 @@ class TestConfiguration:
25
29
  self.logins: LoginConfigs = LoginConfigs()
26
30
  self.file_uploads: FileUploadConfigs = FileUploadConfigs()
27
31
  self.nca_executions: NCAExecutionConfigs = NCAExecutionConfigs()
28
-
32
+
29
33
  def load(self, file_path: str):
30
34
  """
31
35
  Loads the configuration from a file
@@ -41,4 +45,4 @@ class TestConfiguration:
41
45
  self.logins.load(config.get("login_test", {}))
42
46
  self.app_config.load(config.get("application_config_test", {}))
43
47
  self.file_uploads.load(config.get("file_upload_test", {}))
44
- self.nca_executions.load(config.get("analysis_execution_test", {}))
48
+ self.nca_executions.load(config.get("analysis_execution_test", {}))
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -93,6 +93,8 @@ class IntegrationTestSuite:
93
93
  return len(failures) == 0
94
94
 
95
95
  def __print_results(self, start_time: datetime, failures: List[Dict[str, Any]]):
96
+ print("")
97
+ print("--------------------------------")
96
98
  print("Test Results:")
97
99
  skipped = sum([test["skipped_count"] for test in self.test_results])
98
100
 
@@ -101,8 +103,6 @@ class IntegrationTestSuite:
101
103
  print(
102
104
  f" {test_result['test_name']} {'succeeded' if test_result['success'] else 'failed'} duration: {duration}"
103
105
  )
104
- if not test_result["success"]:
105
- print(f" Errors: {test_result['errors']}")
106
106
 
107
107
  print(f"Test Suite completed in {datetime.now(UTC) - start_time}")
108
108
 
@@ -110,3 +110,10 @@ class IntegrationTestSuite:
110
110
  print(f" Successful: {len(self.test_results) - len(failures) - skipped}")
111
111
  print(f" Skipped: {skipped}")
112
112
  print(f" Failed: {len(failures)}")
113
+
114
+ if len(failures) > 0:
115
+ print("--------------------------------")
116
+
117
+ for test_result in self.test_results:
118
+ if not test_result["success"]:
119
+ print(f"Errors: {test_result['errors']}")
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -36,28 +36,29 @@ def main():
36
36
  )
37
37
  # load it so we can see what it looks like
38
38
  config.load(file_path=config_file)
39
-
39
+
40
40
  # override the configuration
41
41
  # override_config(config)
42
42
 
43
43
  its.test(test_config=config)
44
44
 
45
+
45
46
  def override_config(config: TestConfiguration):
46
47
  """Override the configuration for the tests"""
47
48
  username = os.getenv("TEST_USERNAME")
48
49
  password = os.getenv("TEST_PASSWORD")
49
- domain = os.getenv("TEST_DOMAIN")
50
+ host = os.getenv("TEST_HOST")
50
51
 
51
- if not username or not password or not domain:
52
+ if not username or not password or not host:
52
53
  raise RuntimeError(
53
- "TEST_USERNAME, TEST_PASSWORD, and TEST_DOMAIN must be set in the environment"
54
+ "TEST_USERNAME, TEST_PASSWORD, and TEST_HOST must be set in the environment"
54
55
  )
55
56
 
56
57
  config.logins.list.clear()
57
- config.logins.add(username=username, password=password, domain=domain)
58
+ config.logins.add(username=username, password=password, host=host)
58
59
 
59
60
  config.app_config.domains.list.clear()
60
- config.app_config.domains.add(domain=domain)
61
+ config.app_config.domains.add(host=host)
61
62
 
62
63
 
63
64
  if __name__ == "__main__":
@@ -9,7 +9,7 @@ The integration tests will require the following:
9
9
  ### Environment Vars
10
10
  |Variable Name|Description|
11
11
  |--|--|
12
- |APLOS_API_DOMAIN|The full domain. e.g. app.aplos-nca.com|
12
+ |APLOS_host|The full host name. e.g. app.aplos-nca.com|
13
13
 
14
14
 
15
15
  ### Users
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -27,10 +27,10 @@ class TestAppConfiguration(IntegrationTestBase):
27
27
 
28
28
  self.results.clear()
29
29
  for domain_config in self.config.app_config.domains.list:
30
- config: NCAAppConfiguration = NCAAppConfiguration(domain_config.domain)
30
+ config: NCAAppConfiguration = NCAAppConfiguration(domain_config.host)
31
31
 
32
32
  test_response: IntegrationTestResponse = IntegrationTestResponse()
33
- test_response.meta = {"domain": domain_config}
33
+ test_response.meta = {"host": domain_config}
34
34
 
35
35
  if not domain_config.enabled or not self.config.app_config.enabled:
36
36
  test_response.skipped = True
@@ -1,10 +1,10 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
- from aplos_nca_saas_sdk.nca_resources.nca_login import NCALogin
7
+ from aplos_nca_saas_sdk.nca_resources.nca_authenticator import NCAAuthenticator
8
8
 
9
9
 
10
10
  from aplos_nca_saas_sdk.integration_testing.integration_test_base import (
@@ -35,7 +35,7 @@ class TestAppLogin(IntegrationTestBase):
35
35
  self.results.append(test_response)
36
36
  continue
37
37
  try:
38
- nca_login = NCALogin(aplos_saas_domain=login.domain)
38
+ nca_login = NCAAuthenticator(host=login.host)
39
39
  token = nca_login.authenticate(
40
40
  username=login.username, password=login.password
41
41
  )
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -18,8 +18,12 @@ from aplos_nca_saas_sdk.integration_testing.integration_test_response import (
18
18
  IntegrationTestResponse,
19
19
  )
20
20
  from aplos_nca_saas_sdk.nca_resources.nca_file_upload import NCAFileUpload
21
- from aplos_nca_saas_sdk.nca_resources.nca_login import NCALogin
21
+ from aplos_nca_saas_sdk.nca_resources.nca_file_download import NCAFileDownload
22
+ from aplos_nca_saas_sdk.nca_resources.nca_authenticator import NCAAuthenticator
22
23
  from aplos_nca_saas_sdk.utilities.http_utility import HttpUtilities
24
+ from aplos_nca_saas_sdk.integration_testing.configs.file_upload_config import (
25
+ FileUploadConfig,
26
+ )
23
27
 
24
28
  logger = Logger()
25
29
 
@@ -35,31 +39,30 @@ class FileUploadTest(IntegrationTestBase):
35
39
 
36
40
  self.results.clear()
37
41
 
42
+ file_upload: FileUploadConfig
38
43
  for file_upload in self.config.file_uploads.list:
39
44
  test_response: IntegrationTestResponse = IntegrationTestResponse()
40
45
  test_response.name = self.name
41
46
  try:
42
47
  # Confirm Login
43
48
  nca_login = self.__login(file_upload.login)
44
- if not nca_login.jwt:
45
- test_response.error = "Failed to authenticate"
49
+ # if not nca_login.cognito.jwt:
50
+ # test_response.error = "Failed to authenticate"
51
+ # else:
52
+ # Confirm Upload
53
+ upload_response: Dict[str, Any] = self.__upload(
54
+ nca_login, file_upload.file_path
55
+ )
56
+ if upload_response is None:
57
+ test_response.error = "Failed to upload"
46
58
  else:
47
- # Confirm Upload
48
- upload_response: Dict[str, Any] = self.__upload(
49
- nca_login, file_upload.file_path
50
- )
51
- if upload_response is None:
52
- test_response.error = "Failed to upload"
53
- else:
54
- # Confirm conversion and download
55
- # Allow time buffer so file data is available
56
- file_id: str = upload_response.get("file_id", "")
57
- if not file_id:
58
- raise RuntimeError(
59
- "Failed to get a file_id from the upload"
60
- )
61
- time.sleep(3)
62
- self.__download(nca_login, file_id, test_response)
59
+ # Confirm conversion and download
60
+ # Allow time buffer so file data is available
61
+ file_id: str = upload_response.get("file_id", "")
62
+ if not file_id:
63
+ raise RuntimeError("Failed to get a file_id from the upload")
64
+ time.sleep(3)
65
+ self.__download(nca_login, file_id, test_response)
63
66
 
64
67
  except Exception as e: # pylint: disable=w0718
65
68
  test_response.error = str(e)
@@ -68,91 +71,37 @@ class FileUploadTest(IntegrationTestBase):
68
71
 
69
72
  return self.success()
70
73
 
71
- def __login(self, login: LoginConfig) -> NCALogin:
72
- nca_login = NCALogin(aplos_saas_domain=login.domain)
74
+ def __login(self, login: LoginConfig) -> NCAAuthenticator:
75
+ nca_login = NCAAuthenticator(host=login.host)
73
76
  nca_login.authenticate(username=login.username, password=login.password)
74
77
  return nca_login
75
78
 
76
- def __upload(self, nca_login: NCALogin, upload_file_path: str) -> Dict[str, Any]:
79
+ def __upload(self, auth: NCAAuthenticator, upload_file_path: str) -> Dict[str, Any]:
77
80
  logger.info({"message": "Uploading file", "file_path": upload_file_path})
78
81
 
79
- nca_file_upload = NCAFileUpload(nca_login)
82
+ nca_file_upload = NCAFileUpload(auth.host)
83
+ nca_file_upload.authenticator = auth
80
84
  upload_response: Dict[str, Any] = nca_file_upload.upload(upload_file_path)
81
85
  return upload_response
82
86
 
83
87
  def __download(
84
88
  self,
85
- nca_login: NCALogin,
89
+ nca_login: NCAAuthenticator,
86
90
  file_id: str,
87
91
  test_response: IntegrationTestResponse,
88
92
  ):
89
93
  logger.info({"message": "Downloading file", "file_id": file_id})
90
- file_data_endpoint = nca_login.config.endpoints.file_data(
91
- nca_login.cognito.tenant_id,
92
- nca_login.cognito.user_id,
93
- file_id,
94
- )
95
- file_info_endpoint = nca_login.config.endpoints.file(
96
- nca_login.cognito.tenant_id,
97
- nca_login.cognito.user_id,
98
- file_id,
99
- )
100
-
101
- max_wait_in_minutes: int = 3
102
- headers = HttpUtilities.get_headers(nca_login.jwt)
103
- current_time = datetime.now()
104
-
105
- # Create a timedelta object representing 3 minutes
106
- time_delta = timedelta(minutes=max_wait_in_minutes)
107
- # Add the timedelta to the current time
108
- max_time = current_time + time_delta
109
-
110
- complete = False
111
- while not complete:
112
- response = requests.get(file_info_endpoint, headers=headers, timeout=60)
113
- json_response: dict = response.json()
114
- errors: List[Dict[str, Any]] = []
115
- errors.extend(json_response.get("errors") or [])
116
- status = json_response.get("workable_state")
117
- complete = status == "ready"
118
-
119
- if status == "invalid" or len(errors) > 0:
120
- test_response.success = False
121
- test_response.error = (
122
- "File conversion failed."
123
- if len(errors) < 0
124
- else f"File conversion failed with errors ${errors}."
125
- )
126
- break
127
- if complete:
128
- break
129
- if not complete:
130
- time.sleep(5)
131
- if datetime.now() > max_time:
132
- test_response.success = False
133
- test_response.error = (
134
- "Timeout attempting to get conversion file status. "
135
- f"The current timeout limit is {max_wait_in_minutes} minutes. "
136
- "You may need to up the timeout period, or check for errors. "
137
- )
138
- break
139
-
140
- if test_response.error is not None:
141
- return
94
+ downloader: NCAFileDownload = NCAFileDownload(nca_login.host)
95
+ downloader.authenticator = nca_login
96
+ response = downloader.download(file_id)
142
97
 
143
- file_response = requests.get(file_data_endpoint, headers=headers, timeout=30)
144
-
145
- json_file_response: dict = file_response.json()
146
- data = json_file_response.get("data", None)
147
- error = json_file_response.get("error", None)
148
-
149
- if data is None:
98
+ status = response.get("workable_state")
99
+ if status != "ready":
150
100
  test_response.success = False
151
- test_response.error = "File download missing expected data. "
152
- if error is not None:
153
- test_response.success = False
154
- test_response.error = (
155
- test_response.error or ""
156
- ) + f"File download contained error ${error}"
101
+ test_response.error = f"File conversion failed. Status: {status}"
102
+ else:
103
+ test_response.success = True
104
+
105
+ test_response.response = response
157
106
 
158
- test_response.success = True
107
+ return response