aplos-nca-saas-sdk 0.0.11__py3-none-any.whl → 0.0.12__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 (28) hide show
  1. aplos_nca_saas_sdk/aws_resources/aws_cognito.py +11 -5
  2. aplos_nca_saas_sdk/integration_testing/configs/{app_settings.py → app_settings_config.py} +8 -8
  3. aplos_nca_saas_sdk/integration_testing/configs/config_sample.json +27 -14
  4. aplos_nca_saas_sdk/integration_testing/configs/file_upload_config.py +94 -0
  5. aplos_nca_saas_sdk/integration_testing/configs/{login.py → login_config.py} +23 -11
  6. aplos_nca_saas_sdk/integration_testing/configs/nca_execution_config.py +186 -0
  7. aplos_nca_saas_sdk/integration_testing/files/executions/config1.json +46 -0
  8. aplos_nca_saas_sdk/integration_testing/integration_test_base.py +8 -1
  9. aplos_nca_saas_sdk/integration_testing/integration_test_configurations.py +10 -6
  10. aplos_nca_saas_sdk/integration_testing/main.py +1 -2
  11. aplos_nca_saas_sdk/integration_testing/tests/app_login_test.py +1 -1
  12. aplos_nca_saas_sdk/integration_testing/tests/file_upload_test.py +13 -10
  13. aplos_nca_saas_sdk/integration_testing/tests/nca_analysis_test.py +89 -0
  14. aplos_nca_saas_sdk/nca_resources/{nca_executions.py → nca_analysis.py} +148 -87
  15. aplos_nca_saas_sdk/nca_resources/nca_file_upload.py +5 -5
  16. aplos_nca_saas_sdk/nca_resources/nca_login.py +4 -4
  17. aplos_nca_saas_sdk/utilities/commandline_args.py +6 -28
  18. aplos_nca_saas_sdk/utilities/environment_vars.py +7 -0
  19. aplos_nca_saas_sdk/utilities/file_utility.py +33 -0
  20. aplos_nca_saas_sdk/utilities/http_utility.py +22 -6
  21. aplos_nca_saas_sdk/version.py +1 -1
  22. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.12.dist-info}/METADATA +1 -1
  23. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.12.dist-info}/RECORD +26 -23
  24. aplos_nca_saas_sdk/integration_testing/configs/file_upload.py +0 -104
  25. aplos_nca_saas_sdk/integration_testing/tests/app_validation_test.py +0 -5
  26. /aplos_nca_saas_sdk/integration_testing/tests/{app_execution_test.py → validation_test.py} +0 -0
  27. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.12.dist-info}/WHEEL +0 -0
  28. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.12.dist-info}/licenses/LICENSE +0 -0
@@ -36,18 +36,11 @@ class CommandlineArgs:
36
36
  )
37
37
 
38
38
  self.parser.add_argument("-a", "--api-url", required=False, help="The api url")
39
- self.parser.add_argument(
40
- "-i", "--client-id", required=False, help="The client id to cognito"
41
- )
42
39
 
43
40
  self.parser.add_argument(
44
41
  "-v", "--verbose", required=False, help="Detailed logging information"
45
42
  )
46
43
 
47
- self.parser.add_argument(
48
- "-r", "--region", required=False, help="AWS Region. For Cognito Login"
49
- )
50
-
51
44
  self.parser.add_argument(
52
45
  "-s",
53
46
  "--skip",
@@ -69,12 +62,12 @@ class CommandlineArgs:
69
62
  help="The full path to an environment file (.env file).",
70
63
  )
71
64
 
65
+ # auth information
72
66
  self.username: str | None = None
73
67
  self.password: str | None = None
74
68
  self.api_domain: str | None = None
75
- self.cognito_client_id: str | None = None
76
- self.aws_region: str | None = None
77
69
 
70
+ # excuction setup
78
71
  self.config_file: str | None = None
79
72
  self.config_file_default: str | None = None
80
73
  self.analysis_file: str | None = None
@@ -103,8 +96,7 @@ class CommandlineArgs:
103
96
  # anything with a dash (in the args) is accessed with an underscore
104
97
  self.analysis_file = args.analyis_file
105
98
  self.api_domain = args.api_domain
106
- self.cognito_client_id = args.client_id
107
- self.aws_region = args.region
99
+
108
100
  self.metadata_file = args.metadata_file
109
101
  self.skip = args.skip
110
102
  self.output_directory = args.output_directory
@@ -128,25 +120,13 @@ class CommandlineArgs:
128
120
  self.password = self.prompt_for_input(
129
121
  "password", env.password, is_sensitive=True
130
122
  )
131
- if not self.aws_region:
132
- if self.skip and env.aws_region:
133
- self.aws_region = env.aws_region
134
- else:
135
- self.aws_region = self.prompt_for_input("AWS Region", env.aws_region)
123
+
136
124
  if not self.api_domain:
137
125
  if self.skip and env.api_domain:
138
126
  self.api_domain = env.api_domain
139
127
  else:
140
128
  self.api_domain = self.prompt_for_input("Api Domain", env.api_domain)
141
129
 
142
- if not self.cognito_client_id:
143
- if self.skip and env.client_id:
144
- self.cognito_client_id = env.client_id
145
- else:
146
- self.cognito_client_id = self.prompt_for_input(
147
- "Cognito Client Id", env.client_id
148
- )
149
-
150
130
  if not self.analysis_file:
151
131
  if self.skip and self.analysis_file_default or env.analysis_file:
152
132
  self.analysis_file = self.analysis_file_default or env.analysis_file
@@ -196,8 +176,6 @@ class CommandlineArgs:
196
176
  required_fields = [
197
177
  self.username,
198
178
  self.password,
199
- self.aws_region,
200
- self.cognito_client_id,
201
179
  self.analysis_file,
202
180
  self.config_file,
203
181
  self.api_domain,
@@ -314,9 +292,9 @@ def main():
314
292
  pwd = "************" if args.password else "empty"
315
293
  print(f"username = {args.username}")
316
294
  print(f"password = {pwd}")
317
- print(f"aws_region = {args.aws_region}")
295
+
318
296
  print(f"api_domain = {args.api_domain}")
319
- print(f"cognito_client_id = {args.cognito_client_id}")
297
+
320
298
  print(f"config_file = {args.config_file}")
321
299
  print(f"metadata_file = {args.metadata_file}")
322
300
  print(f"analysis_file = {args.analysis_file}")
@@ -21,3 +21,10 @@ class EnvironmentVars:
21
21
  self.api_domain = self.api_domain.replace("https://", "")
22
22
 
23
23
  self.aplos_api_url = f"https://{self.api_domain}"
24
+
25
+ @staticmethod
26
+ def is_running_in_aws_lambda():
27
+ """
28
+ A quick way to check if we are running in an AWS Lambda Environment
29
+ """
30
+ return "AWS_LAMBDA_FUNCTION_NAME" in os.environ
@@ -0,0 +1,33 @@
1
+ """
2
+ Copyright 2024 Aplos Analytics
3
+ All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
+ Property of Aplos Analytics, Utah, USA
5
+ """
6
+
7
+ import os
8
+
9
+
10
+ from aplos_nca_saas_sdk.utilities.environment_services import EnvironmentServices
11
+
12
+
13
+ class FileUtility:
14
+ """General File Utilities"""
15
+
16
+ @staticmethod
17
+ def load_filepath(file_path: str) -> str:
18
+ """Load the file_path"""
19
+ if not file_path:
20
+ raise RuntimeError("file_path is required")
21
+ elif file_path.startswith("${module}"):
22
+ # find the path
23
+ es: EnvironmentServices = EnvironmentServices()
24
+ root = es.find_module_path()
25
+ if not root:
26
+ raise RuntimeError(
27
+ "Unable to find the module path. Please use the ${module} syntax to define the file path"
28
+ )
29
+ file_path = file_path.replace("${module}", root)
30
+
31
+ # get the correct os path separator
32
+ file_path = os.path.normpath(file_path)
33
+ return file_path
@@ -1,3 +1,12 @@
1
+ """
2
+ Copyright 2024 Aplos Analytics
3
+ All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
+ Property of Aplos Analytics, Utah, USA
5
+ """
6
+
7
+ from typing import Optional
8
+
9
+
1
10
  class Routes:
2
11
  """NCA Saas Routes"""
3
12
 
@@ -9,13 +18,20 @@ class HttpUtilities:
9
18
  """Http Utilties"""
10
19
 
11
20
  @staticmethod
12
- def build_url(domain_name: str) -> str:
21
+ def build_url(
22
+ domain_name: str, tenant_id: Optional[str] = None, user_id: Optional[str] = None
23
+ ) -> str:
13
24
  """Build the url"""
14
- domain_name = domain_name.strip()
15
- if domain_name.startswith("http"):
16
- return domain_name
17
- else:
18
- return f"https://{domain_name}"
25
+ url = domain_name.strip()
26
+ if not domain_name.startswith("http"):
27
+ url = f"https://{domain_name}"
28
+
29
+ if tenant_id:
30
+ url = f"{url}/tenants/{tenant_id}"
31
+ if user_id:
32
+ url = f"{url}/users/{user_id}"
33
+
34
+ return url
19
35
 
20
36
  @staticmethod
21
37
  def get_headers(jwt: str) -> dict:
@@ -1,4 +1,4 @@
1
1
  # Aplos NCA SaaS SDK Version File
2
2
  # This is automatically generated during the build process.
3
3
  # DO NOT UPDATE IT DIRECTLY. IT WILL BE OVERWRITTEN.
4
- __version__ = '0.0.11'
4
+ __version__ = '0.0.12'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aplos_nca_saas_sdk
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: Aplos NCA SaaS SDK
5
5
  Project-URL: Homepage, https://aplosanalytics.com/
6
6
  Project-URL: Documentation, https://docs.aplosanalytics.com/
@@ -1,23 +1,25 @@
1
1
  aplos_nca_saas_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- aplos_nca_saas_sdk/version.py,sha256=LFRDGTgR7bT3F8MO6qouK3Rx8voAo9u7FIZ1tVqlWkY,172
3
- aplos_nca_saas_sdk/aws_resources/aws_cognito.py,sha256=pxyEdIoeeT7of_hjxYlplOnyLQpo3I-dnc5mHeGP47c,6427
2
+ aplos_nca_saas_sdk/version.py,sha256=QS4DGcLLszsg6Z09amX7jk4z-YffH_BMp_53BNMfeCw,172
3
+ aplos_nca_saas_sdk/aws_resources/aws_cognito.py,sha256=zCfgruORpJnoP6DlF_XW_IfyUfiwPYoWf581aIZi3NM,6584
4
4
  aplos_nca_saas_sdk/aws_resources/aws_s3_presigned_payload.py,sha256=rbTaeUgPpRsw1KV0YjnmkD5sQvlYet9XBj6Ie7nXz5Y,1987
5
5
  aplos_nca_saas_sdk/aws_resources/aws_s3_presigned_upload.py,sha256=ZCAPNtXMXE2-mA9iWJ1xe_DVgeZGv8r0iCLDnJKNmA8,4290
6
6
  aplos_nca_saas_sdk/files/analysis_files/single_ev/configuration_single_ev.json,sha256=lLnRV0jwzaSn32D8NlOekOF5oGFfUwugUlvlwoKz540,986
7
7
  aplos_nca_saas_sdk/files/analysis_files/single_ev/meta_data.json,sha256=p1KYOAe5Cl3rjtfF1t96oRG-QtFJJCo9otReRPNtvIk,447
8
8
  aplos_nca_saas_sdk/files/analysis_files/single_ev/single_ev.csv,sha256=qFSAlgLOmERsabMmp1X6PAZa-8yFthZlHacM_f7_AOY,6528
9
- aplos_nca_saas_sdk/integration_testing/integration_test_base.py,sha256=DZxTADqxA6VDIdnbddyxku_OAzWBZaeEJobJ-9yZ0Wc,2609
10
- aplos_nca_saas_sdk/integration_testing/integration_test_configurations.py,sha256=EW3fgRqYVAygskvu68szjRuqW2yRkUxIEWko2QHoSSE,1303
9
+ aplos_nca_saas_sdk/integration_testing/integration_test_base.py,sha256=xmxpsUwue_UC7ETr219Oaj24gZKpD6NoPRfg9DeKvk0,2793
10
+ aplos_nca_saas_sdk/integration_testing/integration_test_configurations.py,sha256=oN9-ne8vtwLprHUqfuWOJ2uKyjvsAHhmdVD7zSNGIC8,1618
11
11
  aplos_nca_saas_sdk/integration_testing/integration_test_factory.py,sha256=qEI0m-kpLL8XTBgQu8Sr-GJ6agRormZ6bhYtQzxaUt4,2198
12
12
  aplos_nca_saas_sdk/integration_testing/integration_test_response.py,sha256=T5cLdrhN9Dncu3SFZ3JpUnpQGGJ_VpvTO3uEz0KjfY0,814
13
13
  aplos_nca_saas_sdk/integration_testing/integration_test_suite.py,sha256=fztqfDzdHe-XvWgtGaqCyk4FvCKVfKd1cXbo3mru7Ys,4212
14
- aplos_nca_saas_sdk/integration_testing/main.py,sha256=n2q5NPqM6BwQy-qKHYs4WJV9n3YYZqtg_TTX5JHaV5I,2051
14
+ aplos_nca_saas_sdk/integration_testing/main.py,sha256=8mWJCHp9CSjfDv8qAXdDhK8B2XhPGrIOkZHgHM8ACHE,2054
15
15
  aplos_nca_saas_sdk/integration_testing/readme.md,sha256=sX-_gzx17UUF-ZqvCWq0R5zcqgOMC4JjQKnjgxQH9vM,629
16
16
  aplos_nca_saas_sdk/integration_testing/configs/_config_base.py,sha256=O48Y1r8JFe2KvSMTY5EttZAz1-hQsU6-Su6CzDUKDmE,347
17
- aplos_nca_saas_sdk/integration_testing/configs/app_settings.py,sha256=qq04xPowq4-4EY0Cf8zzVqmgUfrHk3RAtHOOcyFifEw,2618
18
- aplos_nca_saas_sdk/integration_testing/configs/config_sample.json,sha256=uAfW9YN2zREi6wNSKs2JWtHsbg9_Dsy7oYRFi1KgwRY,3118
19
- aplos_nca_saas_sdk/integration_testing/configs/file_upload.py,sha256=eqKXmrzIpjJRGZTx_Tj_CCYS4iZUAaNNx_HAsdxcerY,3560
20
- aplos_nca_saas_sdk/integration_testing/configs/login.py,sha256=DGcjH4WuyG0oPxdIJBi3qpymzGaLEJjCoRfbQT0PcK4,3002
17
+ aplos_nca_saas_sdk/integration_testing/configs/app_settings_config.py,sha256=nlBflWWhFbc-FOq7Bpw6cKyULO6VT_Oe1sUq4lKhHWk,2672
18
+ aplos_nca_saas_sdk/integration_testing/configs/config_sample.json,sha256=PryYwS3FoQXii53UuAFTN1-yj-PjwhFEDanmJ20wlVo,3586
19
+ aplos_nca_saas_sdk/integration_testing/configs/file_upload_config.py,sha256=wbApZi1ROwgprIlOvpwtYbQ_YSoGhvBEC2KB4Ddq0Pg,3061
20
+ aplos_nca_saas_sdk/integration_testing/configs/login_config.py,sha256=FBmmpdDgIO2ldhJ6yHf-ioWXiFmfd3s_i4VXR4pm4Ig,3564
21
+ aplos_nca_saas_sdk/integration_testing/configs/nca_execution_config.py,sha256=qMsmcn-nMlPlWFBgpdzfnX_eNigp_sTX6lqR2lZmvyw,5764
22
+ aplos_nca_saas_sdk/integration_testing/files/executions/config1.json,sha256=m6-wSzfrB-7w4CgIGpmT9y0_zevp-Q6So9eXU9HsVpQ,945
21
23
  aplos_nca_saas_sdk/integration_testing/files/uploads/input1.csv,sha256=9TGDiMkft7ltFFKk_8RyzuhuloIpe_fZs0Nw0PN3BkM,263
22
24
  aplos_nca_saas_sdk/integration_testing/files/uploads/input1.dat,sha256=9TGDiMkft7ltFFKk_8RyzuhuloIpe_fZs0Nw0PN3BkM,263
23
25
  aplos_nca_saas_sdk/integration_testing/files/uploads/input1.sas7bdat,sha256=bh4w5QPHwjgLEhk752BmUwztkcBmx8iAywZdiiWZuw0,16384
@@ -25,20 +27,21 @@ aplos_nca_saas_sdk/integration_testing/files/uploads/input1.xls,sha256=ymFgWvoUC
25
27
  aplos_nca_saas_sdk/integration_testing/files/uploads/input1.xlsx,sha256=i8pOYfA-muNxrtCKfUfi4Hi3JvSx49ZgtfvIUQTzRJo,10481
26
28
  aplos_nca_saas_sdk/integration_testing/files/uploads/input1.xpt,sha256=vve5eYrs3nEuGGQgm710tzzYkhrn3cfcy3--CVe4IGs,1920
27
29
  aplos_nca_saas_sdk/integration_testing/tests/app_configuration_test.py,sha256=rayFz4YcSpBVXr9aZYQSncBg7ohdYjEZpxIc1P7vrNA,1568
28
- aplos_nca_saas_sdk/integration_testing/tests/app_execution_test.py,sha256=bDyVvtOKSJdy0sdCVYVuCdUrQYhn8D3peCmM1OCkSVg,145
29
- aplos_nca_saas_sdk/integration_testing/tests/app_login_test.py,sha256=yCuJzNyQmm_yq7Olt4P-Wrher697fsElI8J8G87f0fU,1682
30
- aplos_nca_saas_sdk/integration_testing/tests/app_validation_test.py,sha256=bDyVvtOKSJdy0sdCVYVuCdUrQYhn8D3peCmM1OCkSVg,145
31
- aplos_nca_saas_sdk/integration_testing/tests/file_upload_test.py,sha256=aXC7EBqgxOzOxkb4WbNUpBGu6q2QQ1p8QFRPvg3ryOo,5666
30
+ aplos_nca_saas_sdk/integration_testing/tests/app_login_test.py,sha256=FMKfx4MFoVnfimNUjVsvLqT1FQnt3W-Nd7vvSvPSeg8,1636
31
+ aplos_nca_saas_sdk/integration_testing/tests/file_upload_test.py,sha256=CBQ80gLX4QpKgUghgsV-2nN94zMhlXsBbFGY2bYY0QQ,5906
32
+ aplos_nca_saas_sdk/integration_testing/tests/nca_analysis_test.py,sha256=2YvbKZKqPLqbeCMFAmg6Ksey2a6Xn0ZVhDIs5gwwrw0,3258
33
+ aplos_nca_saas_sdk/integration_testing/tests/validation_test.py,sha256=bDyVvtOKSJdy0sdCVYVuCdUrQYhn8D3peCmM1OCkSVg,145
34
+ aplos_nca_saas_sdk/nca_resources/nca_analysis.py,sha256=JDI9F6MEpu8WdoZsSnCoU_twFpkKBwn1KIEiMwTvsvw,14877
32
35
  aplos_nca_saas_sdk/nca_resources/nca_app_configuration.py,sha256=mRK_OK2k0q4o4pH11tpeR3yKve7sgw3XTtQ0HG9KKFU,1877
33
36
  aplos_nca_saas_sdk/nca_resources/nca_endpoints.py,sha256=bOY2m9sTMu6UP-eE8rLiPKm22M-j7nLBV2xQFJHa71Q,2247
34
- aplos_nca_saas_sdk/nca_resources/nca_executions.py,sha256=8yasCC7OEOLhC1CRgjVy4rkUl-WgUrDhXPvZj7QR_7E,12852
35
- aplos_nca_saas_sdk/nca_resources/nca_file_upload.py,sha256=E5UKgRvPZUzv_V-9-YhNPmcyHArS3AhAU-7UoMAe8Is,1909
36
- aplos_nca_saas_sdk/nca_resources/nca_login.py,sha256=wTwuQhntyGKgm6C96ock3uyG8bFWCaMzG-0GJgQ3Ouo,3031
37
- aplos_nca_saas_sdk/utilities/commandline_args.py,sha256=WKIPNKMMMpEk580xXMQY7sGwxZP-uX6DVqD-8SX3NKM,11721
37
+ aplos_nca_saas_sdk/nca_resources/nca_file_upload.py,sha256=Kl0E3hJn9_vpcrDf_9fXyJ_44XRAL2w6OapNY29t-gg,1824
38
+ aplos_nca_saas_sdk/nca_resources/nca_login.py,sha256=d6pflBj73n3KEV_byyVwq5zqkujKWMd9sxf9-xlF6NU,3035
39
+ aplos_nca_saas_sdk/utilities/commandline_args.py,sha256=oY20-VqeXhvSbD3kkU3llO_1mkiRWLpMXCHRbIQfJjE,10645
38
40
  aplos_nca_saas_sdk/utilities/environment_services.py,sha256=iytCg55G5EoBC9VPZJyLp5bNKy3_P9sYD9v4dCVorRw,3250
39
- aplos_nca_saas_sdk/utilities/environment_vars.py,sha256=pfcfX2eYmwYrmY-PZIHCONU9ds_-6GZmb-JibGROJGI,812
40
- aplos_nca_saas_sdk/utilities/http_utility.py,sha256=7VGWeSOuJbjnUQkzNA6cquKv0g2FJoHsBnDSgE2Buic,696
41
- aplos_nca_saas_sdk-0.0.11.dist-info/METADATA,sha256=5O9l45xZaC7vZKk1C-Q93nvysAnA9XPXwSw3KUmia7w,3792
42
- aplos_nca_saas_sdk-0.0.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
- aplos_nca_saas_sdk-0.0.11.dist-info/licenses/LICENSE,sha256=pAZXnNE2dxxwXFIduGyn1gpvPefJtUYOYZOi3yeGG94,1068
44
- aplos_nca_saas_sdk-0.0.11.dist-info/RECORD,,
41
+ aplos_nca_saas_sdk/utilities/environment_vars.py,sha256=f-1oqODH-3wFrRONqmnkiL5AiybHe23g9FL4JAUkWEs,1023
42
+ aplos_nca_saas_sdk/utilities/file_utility.py,sha256=OuVNmkyYNtf7UUHAaQkWEp9Gz8Zo0BsZcNsrUQ4qMXk,1020
43
+ aplos_nca_saas_sdk/utilities/http_utility.py,sha256=G7fX_VQz0UwHbMYdcSh0KNfGcx2tpCx8bBTj_Iy0-Ww,1061
44
+ aplos_nca_saas_sdk-0.0.12.dist-info/METADATA,sha256=O5Q6XDLZcv-7bdP27uxurYjn6jzcfa8fq9IkM62597c,3792
45
+ aplos_nca_saas_sdk-0.0.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
+ aplos_nca_saas_sdk-0.0.12.dist-info/licenses/LICENSE,sha256=pAZXnNE2dxxwXFIduGyn1gpvPefJtUYOYZOi3yeGG94,1068
47
+ aplos_nca_saas_sdk-0.0.12.dist-info/RECORD,,
@@ -1,104 +0,0 @@
1
- """
2
- Copyright 2024 Aplos Analytics
3
- All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
- Property of Aplos Analytics, Utah, USA
5
- """
6
-
7
- import os
8
- from typing import List, Dict, Any
9
- from aplos_nca_saas_sdk.integration_testing.configs._config_base import ConfigBase
10
- from aplos_nca_saas_sdk.integration_testing.configs.login import Login
11
- from aplos_nca_saas_sdk.utilities.environment_services import EnvironmentServices
12
-
13
-
14
- class FileUpload(ConfigBase):
15
- """
16
- File Upload: Defines the login that the application configuration tests will check against
17
-
18
- """
19
-
20
- def __init__(self, login: Login, filepath: str):
21
- super().__init__()
22
- if login is None:
23
- raise RuntimeError("Login is required")
24
- self.__login = login
25
- if filepath is None:
26
- raise RuntimeError("Filepath is required")
27
- self.__filepath = filepath
28
-
29
- @property
30
- def login(self) -> Login:
31
- """The users login"""
32
- return self.__login
33
-
34
- @property
35
- def filepath(self) -> str:
36
- """The file path to file being uploaded"""
37
- path = self.__load_filepath(self.__filepath)
38
-
39
- if not os.path.exists(path):
40
- raise RuntimeError(f"The Upload File was not found: {path}")
41
-
42
- return path
43
-
44
- def __load_filepath(self, filepath: str) -> str:
45
- """Load the filepath"""
46
- if filepath is None:
47
- raise RuntimeError("Filepath is required")
48
- elif filepath.startswith("${module}"):
49
- # find the path
50
- es: EnvironmentServices = EnvironmentServices()
51
- root = es.find_module_path()
52
- filepath = filepath.replace("${module}", root)
53
-
54
- # get the correct os path separator
55
- filepath = os.path.normpath(filepath)
56
- return filepath
57
-
58
-
59
- class FileUploads(ConfigBase):
60
- """
61
- File Uploads: Defines the files that the application file upload tests will check against
62
-
63
- """
64
-
65
- def __init__(self):
66
- super().__init__()
67
- self.__fileuploads: List[FileUpload] = []
68
-
69
- @property
70
- def list(self) -> List[FileUpload]:
71
- """List the file uploads"""
72
- return filter(lambda x: x.enabled, self.__fileuploads)
73
-
74
- def add(self, *, filepath: str, login: Login, enabled: bool = True):
75
- """Add a file upload"""
76
- fileupload = FileUpload(login, filepath)
77
- fileupload.enabled = enabled
78
- self.__fileuploads.append(fileupload)
79
-
80
- def load(self, test_config: Dict[str, Any]):
81
- """Load the file uploads from a list of dictionaries"""
82
-
83
- super().load(test_config)
84
- test_config_login: Login = self.try_load_login(test_config.get("login", None))
85
- fileuploads: List[Dict[str, Any]] = test_config.get("files", [])
86
- login: Login = None
87
- for fileupload in fileuploads:
88
- enabled = bool(fileupload.get("enabled", True))
89
- if "login" in fileupload:
90
- login = self.try_load_login(fileupload["login"])
91
- else:
92
- login = test_config_login
93
-
94
- self.add(filepath=fileupload["file"], login=login, enabled=enabled)
95
-
96
- def try_load_login(self, login_config: Dict[str, Any]) -> Login | None:
97
- """Attempts to intialize a Login from a configuration object"""
98
- login: Login = None
99
- if login_config is not None:
100
- username = login_config.get("username", None)
101
- password = login_config.get("password", None)
102
- domain = login_config.get("domain", None)
103
- login = Login(username, password, domain)
104
- return login
@@ -1,5 +0,0 @@
1
- """
2
- Copyright 2024 Aplos Analytics
3
- All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
- Property of Aplos Analytics, Utah, USA
5
- """