Skip to content

DSP Tests

Runs various smoke tests for the data submission portal

DspEarthchemTestSuite

Bases: DspTestSuite

DSP tests for Earthchem backend

Source code in dsp/dsp.py
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
class DspEarthchemTestSuite(DspTestSuite):
    """DSP tests for Earthchem backend"""

    repo_name = "EarthChem"

    @classmethod
    def required_elements_template(self, auto_text):
        data_file_release = {
            "datePublished": datetime.datetime.today().strftime("%Y-%m-%d"),
        }
        basic_info = {
            "DatasetTitle": auto_text + " Title",
            "AbstractorDescription": auto_text + " Description/Abstract",
            "DataTypes": ["Chemistry"],
            "Keywords": [auto_text + " Keywords"],
        }
        lead_author = {
            "FirstName": auto_text + "FirstName",
            "LastName": auto_text + "LastName",
            "Email": f"{auto_text}@gmail.com",
        }
        spatial = {"SpatialCoverage": ["Global"]}
        funding_source = {
            "AwardNumber": auto_text + "AwardNumber",
        }

        required_elements = {
            "DataFileReleaseInformation": data_file_release,
            "group-BasicInformation": basic_info,
            "SpatialCoverageInformation": spatial,
            "LeadAuthor": lead_author,
            "FundingSource": funding_source,
        }
        return required_elements

    def earthchem_then_login_orcid(self):
        """Select Earthchem repo then authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(
            self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
        )
        OrcidWindow.to_origin_window(self.driver)

        # new Earthchem auth window
        if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
            SubmitLandingPage.to_repo_auth_window(self.driver)
            EarthchemAuthWindow.authorize_via_orcid(self.driver)
            EarthchemAuthWindow.to_origin_window(self.driver, wait=True)

    def earthchem_then_login_username_password(self):
        """Select Earthchem repo then authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(
            self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
        )
        OrcidWindow.to_origin_window(self.driver)

        # new Earthchem auth window
        SubmitLandingPage.to_repo_auth_window(self.driver)
        EarthchemAuthWindow.authorize_email_password(
            self.driver, email=EARTHCHEM_USERNAME, password=EARTHCHEM_PASSWORD
        )
        EarthchemAuthWindow.to_origin_window(self.driver, wait=True)

    def login_orcid_to_submit(self):
        """Authenticate with orcid then select repo"""
        super().login_orcid_to_submit(self.repo_name)

        # first time that a user auths to ECL, there is an extra window
        if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
            SubmitLandingPage.to_repo_auth_window(self.driver)
            EarthchemAuthWindow.authorize_via_orcid(self.driver)
            OrcidWindow.fill_credentials(
                self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
            )
            OrcidWindow.to_origin_window(self.driver, wait=True)

    def login_and_autofill_earthchem_required(self, auto_text):
        """A shortcut to fill required fields of submit page
        So that additional non-required fields can easily be checked
        """
        # self.earthchem_then_login_username_password()
        self.login_orcid_to_submit()
        SubmitEarthchem.autofill_required_elements(
            self.driver, self.required_elements_template(auto_text)
        )

    def submit(self, sort_text):
        """
        Save an EarthChem record

        ECL is unique in that it has multiple options for submit vs finish_later. This funtions name is confusing...here we are overriding the default TestSuite submit()
        This would be more aptly named 'finish_later()'
        """
        SubmitEarthchem.finish_submission_later(self.driver)

        MySubmissions.enter_text_in_search(self.driver, sort_text)
        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

        MySubmissions.edit_top_submission(self.driver)

    def test_ec_000001_orcid_auth_then_submit(self):
        """Authenticate with Orcid, then navigate to Earthchem submit page"""
        self.login_orcid_to_submit()
        header = SubmitEarthchem.get_header_text(self.driver)
        self.assertIn(self.repo_name, header)
        alert = SubmitEarthchem.get_alert_text(self.driver)
        self.assertIn("Instructions", alert)

    def test_ec_000002_repo_then_orcid_auth(self):
        """Navigate to Earthchem submit, then authenticate with orcid"""
        self.earthchem_then_login_orcid()
        header = SubmitEarthchem.get_header_text(self.driver)
        self.assertIn(self.repo_name, header)

    def test_ec_000003_save_required_fields(self):
        """Confirm successful save of required fields for Earthchem Repo"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        self.assertTrue(SubmitEarthchem.is_finishable(self.driver))
        SubmitEarthchem.finish_submission_later(self.driver)
        self.assertEqual("My Submissions", MySubmissions.get_title(self.driver))
        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

    def test_ec_000004_required_fields_persist(self):
        """Check that required fields persist after save"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_and_autofill_earthchem_required(auto_text)
        SubmitEarthchem.finish_submission_later(self.driver)
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)
        check = EditEarthchemSubmission.check_required_elements(self.driver, template)
        self.assertTrue(check)

    @unittest.skip("Lead Author became a required field so is tested elsewhere")
    def test_ec_000005_lead_author_persists(self):
        """Confirm that Lead Author info persists from save to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        section = "LeadAuthor"
        nth = 0
        dict = {
            "FirstName": auto_text + "FirstName",
            "LastName": auto_text + "LastName",
            "Email": f"{auto_text}@gmail.com",
        }
        SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_ec_000006_co_author_persist(self):
        """Confirm that Co-Author info persists from save to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        section = "Co-Authors"
        nth = 0
        dict = {
            "FirstName": auto_text + "FirstName",
            "LastName": auto_text + "LastName",
            "Email": f"{auto_text}@gmail.com",
        }
        SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_ec_000007_related_resource_persists(self):
        """Confirm that Related Resource Info persists from save to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        section = "RelatedInformation"
        nth = 0
        dict = {
            "PublicationDOI": auto_text + "PublicationDOI",
            # "RelatedInformation": "(R2R) - Cruise DOI"
        }

        # This section is nested...
        SubmitEarthchem.expand_section_by_did(self.driver, data_id="RelatedResources")
        SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_ec_000008_funding_source_persists(self):
        """Confirm that Funding Source Info persists from save to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        section = "FundingSource"
        nth = 0
        dict = {
            # "Selectone": "U.S. Department of Energy",
            "AwardNumber": auto_text
            + "AwardNumber"
        }
        SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
        self.check(section, nth, dict)

    def test_ec_000009_license_persists(self):
        """Confirm that License Info persists from save to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        section = "License"
        nth = 0
        dict = {"License": "(CC0-1.0) - Creative Commons No Rights Reserved"}
        SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
        try:
            self.fill_ids_submit_and_check(auto_text, section, nth, dict)
        except AssertionError:
            license = SubmitEarthchem.get_license(self.driver)
            self.assertEqual(license, dict["License"])

    def test_ec_000010_able_to_view_in_repository(self):
        """
        From My Submissions, confirm that we can "view in repository" ECL submission, after saving
        """
        # TODO: set production ECL env via GH workflow
        # https://github.com/cznethub/dspback/issues/118
        if "localhost" in self.base_url_arg or "test" in self.base_url_arg:
            self.skipTest("Viewing ECL submissions not supported in test environment")
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_and_autofill_earthchem_required(auto_text)
        SubmitEarthchem.finish_submission_later(self.driver)

        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.view_top_submission(self.driver)
        MySubmissions.to_earthchem_repo(self.driver)
        EarthchemResourcePage.authenticate_if_needed(self.driver)

        self.assertEqual(
            EarthchemResourcePage.get_title(self.driver),
            template["group-BasicInformation"]["DatasetTitle"],
        )

    def test_ec_000011_submit_for_review_required_fields(self):
        """
        From My Submissions, confirm that we can "view in repository" ECL submission, after SUBMITTING FOR REVIEW
        """
        # TODO: set production ECL env via GH workflow
        # https://github.com/cznethub/dspback/issues/118
        if "localhost" in self.base_url_arg or "test" in self.base_url_arg:
            self.skipTest("Viewing ECL submissions not supported in test environment")
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_earthchem_required(auto_text)
        SubmitEarthchem.submit_for_review(self.driver)

        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

        MySubmissions.view_top_submission(self.driver)
        MySubmissions.to_earthchem_repo(self.driver)

        EarthchemResourcePage.authenticate_if_needed(self.driver)
        self.assertIn(auto_text, EarthchemResourcePage.get_title(self.driver))

earthchem_then_login_orcid()

Select Earthchem repo then authenticate with orcid

Source code in dsp/dsp.py
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def earthchem_then_login_orcid(self):
    """Select Earthchem repo then authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(
        self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
    )
    OrcidWindow.to_origin_window(self.driver)

    # new Earthchem auth window
    if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
        SubmitLandingPage.to_repo_auth_window(self.driver)
        EarthchemAuthWindow.authorize_via_orcid(self.driver)
        EarthchemAuthWindow.to_origin_window(self.driver, wait=True)

earthchem_then_login_username_password()

Select Earthchem repo then authenticate with orcid

Source code in dsp/dsp.py
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
def earthchem_then_login_username_password(self):
    """Select Earthchem repo then authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(
        self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
    )
    OrcidWindow.to_origin_window(self.driver)

    # new Earthchem auth window
    SubmitLandingPage.to_repo_auth_window(self.driver)
    EarthchemAuthWindow.authorize_email_password(
        self.driver, email=EARTHCHEM_USERNAME, password=EARTHCHEM_PASSWORD
    )
    EarthchemAuthWindow.to_origin_window(self.driver, wait=True)

login_and_autofill_earthchem_required(auto_text)

A shortcut to fill required fields of submit page So that additional non-required fields can easily be checked

Source code in dsp/dsp.py
1151
1152
1153
1154
1155
1156
1157
1158
1159
def login_and_autofill_earthchem_required(self, auto_text):
    """A shortcut to fill required fields of submit page
    So that additional non-required fields can easily be checked
    """
    # self.earthchem_then_login_username_password()
    self.login_orcid_to_submit()
    SubmitEarthchem.autofill_required_elements(
        self.driver, self.required_elements_template(auto_text)
    )

login_orcid_to_submit()

Authenticate with orcid then select repo

Source code in dsp/dsp.py
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
def login_orcid_to_submit(self):
    """Authenticate with orcid then select repo"""
    super().login_orcid_to_submit(self.repo_name)

    # first time that a user auths to ECL, there is an extra window
    if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
        SubmitLandingPage.to_repo_auth_window(self.driver)
        EarthchemAuthWindow.authorize_via_orcid(self.driver)
        OrcidWindow.fill_credentials(
            self.driver, EARTHCHEM_USERNAME, EARTHCHEM_PASSWORD
        )
        OrcidWindow.to_origin_window(self.driver, wait=True)

submit(sort_text)

Save an EarthChem record

ECL is unique in that it has multiple options for submit vs finish_later. This funtions name is confusing...here we are overriding the default TestSuite submit() This would be more aptly named 'finish_later()'

Source code in dsp/dsp.py
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
def submit(self, sort_text):
    """
    Save an EarthChem record

    ECL is unique in that it has multiple options for submit vs finish_later. This funtions name is confusing...here we are overriding the default TestSuite submit()
    This would be more aptly named 'finish_later()'
    """
    SubmitEarthchem.finish_submission_later(self.driver)

    MySubmissions.enter_text_in_search(self.driver, sort_text)
    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

    MySubmissions.edit_top_submission(self.driver)

test_ec_000001_orcid_auth_then_submit()

Authenticate with Orcid, then navigate to Earthchem submit page

Source code in dsp/dsp.py
1175
1176
1177
1178
1179
1180
1181
def test_ec_000001_orcid_auth_then_submit(self):
    """Authenticate with Orcid, then navigate to Earthchem submit page"""
    self.login_orcid_to_submit()
    header = SubmitEarthchem.get_header_text(self.driver)
    self.assertIn(self.repo_name, header)
    alert = SubmitEarthchem.get_alert_text(self.driver)
    self.assertIn("Instructions", alert)

test_ec_000002_repo_then_orcid_auth()

Navigate to Earthchem submit, then authenticate with orcid

Source code in dsp/dsp.py
1183
1184
1185
1186
1187
def test_ec_000002_repo_then_orcid_auth(self):
    """Navigate to Earthchem submit, then authenticate with orcid"""
    self.earthchem_then_login_orcid()
    header = SubmitEarthchem.get_header_text(self.driver)
    self.assertIn(self.repo_name, header)

test_ec_000003_save_required_fields()

Confirm successful save of required fields for Earthchem Repo

Source code in dsp/dsp.py
1189
1190
1191
1192
1193
1194
1195
1196
def test_ec_000003_save_required_fields(self):
    """Confirm successful save of required fields for Earthchem Repo"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    self.assertTrue(SubmitEarthchem.is_finishable(self.driver))
    SubmitEarthchem.finish_submission_later(self.driver)
    self.assertEqual("My Submissions", MySubmissions.get_title(self.driver))
    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

test_ec_000004_required_fields_persist()

Check that required fields persist after save

Source code in dsp/dsp.py
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
def test_ec_000004_required_fields_persist(self):
    """Check that required fields persist after save"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_and_autofill_earthchem_required(auto_text)
    SubmitEarthchem.finish_submission_later(self.driver)
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)
    check = EditEarthchemSubmission.check_required_elements(self.driver, template)
    self.assertTrue(check)

test_ec_000005_lead_author_persists()

Confirm that Lead Author info persists from save to edit

Source code in dsp/dsp.py
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
@unittest.skip("Lead Author became a required field so is tested elsewhere")
def test_ec_000005_lead_author_persists(self):
    """Confirm that Lead Author info persists from save to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    section = "LeadAuthor"
    nth = 0
    dict = {
        "FirstName": auto_text + "FirstName",
        "LastName": auto_text + "LastName",
        "Email": f"{auto_text}@gmail.com",
    }
    SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_ec_000006_co_author_persist()

Confirm that Co-Author info persists from save to edit

Source code in dsp/dsp.py
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
def test_ec_000006_co_author_persist(self):
    """Confirm that Co-Author info persists from save to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    section = "Co-Authors"
    nth = 0
    dict = {
        "FirstName": auto_text + "FirstName",
        "LastName": auto_text + "LastName",
        "Email": f"{auto_text}@gmail.com",
    }
    SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

Confirm that Related Resource Info persists from save to edit

Source code in dsp/dsp.py
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
def test_ec_000007_related_resource_persists(self):
    """Confirm that Related Resource Info persists from save to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    section = "RelatedInformation"
    nth = 0
    dict = {
        "PublicationDOI": auto_text + "PublicationDOI",
        # "RelatedInformation": "(R2R) - Cruise DOI"
    }

    # This section is nested...
    SubmitEarthchem.expand_section_by_did(self.driver, data_id="RelatedResources")
    SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_ec_000008_funding_source_persists()

Confirm that Funding Source Info persists from save to edit

Source code in dsp/dsp.py
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
def test_ec_000008_funding_source_persists(self):
    """Confirm that Funding Source Info persists from save to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    section = "FundingSource"
    nth = 0
    dict = {
        # "Selectone": "U.S. Department of Energy",
        "AwardNumber": auto_text
        + "AwardNumber"
    }
    SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
    self.check(section, nth, dict)

test_ec_000009_license_persists()

Confirm that License Info persists from save to edit

Source code in dsp/dsp.py
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
def test_ec_000009_license_persists(self):
    """Confirm that License Info persists from save to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    section = "License"
    nth = 0
    dict = {"License": "(CC0-1.0) - Creative Commons No Rights Reserved"}
    SubmitEarthchem.expand_section_by_did(self.driver, data_id=section)
    try:
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)
    except AssertionError:
        license = SubmitEarthchem.get_license(self.driver)
        self.assertEqual(license, dict["License"])

test_ec_000010_able_to_view_in_repository()

From My Submissions, confirm that we can "view in repository" ECL submission, after saving

Source code in dsp/dsp.py
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
def test_ec_000010_able_to_view_in_repository(self):
    """
    From My Submissions, confirm that we can "view in repository" ECL submission, after saving
    """
    # TODO: set production ECL env via GH workflow
    # https://github.com/cznethub/dspback/issues/118
    if "localhost" in self.base_url_arg or "test" in self.base_url_arg:
        self.skipTest("Viewing ECL submissions not supported in test environment")
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_and_autofill_earthchem_required(auto_text)
    SubmitEarthchem.finish_submission_later(self.driver)

    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.view_top_submission(self.driver)
    MySubmissions.to_earthchem_repo(self.driver)
    EarthchemResourcePage.authenticate_if_needed(self.driver)

    self.assertEqual(
        EarthchemResourcePage.get_title(self.driver),
        template["group-BasicInformation"]["DatasetTitle"],
    )

test_ec_000011_submit_for_review_required_fields()

From My Submissions, confirm that we can "view in repository" ECL submission, after SUBMITTING FOR REVIEW

Source code in dsp/dsp.py
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
def test_ec_000011_submit_for_review_required_fields(self):
    """
    From My Submissions, confirm that we can "view in repository" ECL submission, after SUBMITTING FOR REVIEW
    """
    # TODO: set production ECL env via GH workflow
    # https://github.com/cznethub/dspback/issues/118
    if "localhost" in self.base_url_arg or "test" in self.base_url_arg:
        self.skipTest("Viewing ECL submissions not supported in test environment")
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_earthchem_required(auto_text)
    SubmitEarthchem.submit_for_review(self.driver)

    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

    MySubmissions.view_top_submission(self.driver)
    MySubmissions.to_earthchem_repo(self.driver)

    EarthchemResourcePage.authenticate_if_needed(self.driver)
    self.assertIn(auto_text, EarthchemResourcePage.get_title(self.driver))

DspExternalTestSuite

Bases: DspTestSuite

DSP tests for External (No Repo)

Source code in dsp/dsp.py
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
class DspExternalTestSuite(DspTestSuite):
    """DSP tests for External (No Repo)"""

    @classmethod
    def required_elements_template(self, auto_text):
        basic_info = {
            "Nameortitle": auto_text + " Nameortitle",
            "Url": "http://basicinfourl.com/" + auto_text,
            "Descriptionorabstract": auto_text + " Descriptionorabstract",
            "SubjectKeywords": [auto_text + " SubjectKeywords"],
        }
        date_published = {"Date": "2022-04-05T00:04"}
        creator = {
            "Name": "Meister, Jim",
            "Organization": (
                "Freie Universität Berlin;Agricultural University of Warsaw"
            ),
            "Email": "concretejackbill@gmail.com",
            "ORCID": "0000-0003-0813-0443",
        }
        funding_agency = {
            "Fundingagencyname": auto_text + " Fundingagencyname",
            "Awardnumberoridentifier*": auto_text + " Awardnumberoridentifier",
            "Awardname": auto_text + " Awardname",
        }
        provider = {
            "ProviderName": auto_text + " ProviderName",
            "Url": "http://providerurl.com/" + auto_text,
        }

        # created separately so that we can check individually if needed
        required_elements = {
            "BasicInformation": basic_info,
            "Datepublished": date_published,
            "Creators": creator,
            "Fundingagencyinformation": funding_agency,
            "Provider": provider,
        }
        return required_elements

    def login_orcid_and_external(self):
        """Authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, "RegisterDataset")

        SubmitLandingPage.select_external_dataset(self.driver)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver)
        SubmitExternal.wait_until_loaded(self.driver)

    def login_and_autofill_external_required(self, auto_text):
        """A shortcut to fill required fields of submit page
        So that additional non-required fields can easily be checked
        """
        self.login_orcid_and_external()
        SubmitExternal.open_tab(self.driver, "Datepublished", tab_number=2)
        SubmitExternal.autofill_required_elements(
            self.driver, self.required_elements_template(auto_text)
        )

    def test_ex_000001_authenticate_then_submit_page(self):
        """
        Check authentication to submit page

        First, authenticate with Orcid, then navigate to the submit page
        """
        self.login_orcid_and_external()
        header = SubmitExternal.get_header_text(self.driver)
        self.assertIn("External", header)

    def test_ex_000002_submit_instructions_shown(self):
        """Check that instructions are shown on the Submit page"""
        self.login_orcid_and_external()
        alert = SubmitExternal.get_alert_text(self.driver)
        self.assertIn("Instructions", alert)

    def test_ex_000003_submit_required_fields(self):
        """Confirm successful submit of required fields for External Repo"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        # self.login_and_autofill_external_required(auto_text)
        self.login_orcid_and_external()

        SubmitExternal.open_tab(self.driver, "Datepublished", tab_number=2)
        template = self.required_elements_template(auto_text)
        SubmitExternal.autofill_required_elements(self.driver, template)

        self.assertTrue(SubmitExternal.is_finishable(self.driver))
        SubmitExternal.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)

        top_name = MySubmissions.get_top_submission_name(self.driver)

        self.assertEqual(template["BasicInformation"]["Nameortitle"], top_name)

        MySubmissions.edit_top_submission(self.driver)
        self.assertEqual(
            "Register Dataset from External Repository",
            EditExternalSubmission.get_header_title(self.driver),
        )
        self.assertTrue(
            EditExternalSubmission.check_required_elements(self.driver, template)
        )

    def test_ex_000004_contributors_info_persists(self):
        """Confirm that Contributors info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_external_required(auto_text)
        section = "Contributors"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            # "Phone": "1234567890",
            # "Address": "contributor address " + auto_text,
            "Organization": "contributor org " + auto_text,
            "Email": auto_text + "@gmail.com",
            # "Homepage": "http://contibutor-homepage.com/" + auto_text,
        }
        SubmitExternal.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    @unittest.expectedFailure
    def test_ex_000005_temporal_coverage_persists(self):
        """Confirm that Temporal coverage persists from submit to edit"""

        # TODO: this test fails because the start/end inputs don't have data-ids
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_external_required(auto_text)
        section = "Temporalcoverage"
        nth = 0
        dict = {
            "Start": "2022-03-25T01:00",
            "End": "2022-04-25T02:00",
            "Name": auto_text + "Meister, Jim",
        }
        success_filling = SubmitExternal.fill_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(success_filling)
        SubmitExternal.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        match = EditExternalSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    def test_ex_000006_spatial_coverage_persists(self):
        """Confirm that Spatial Point Coverage info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_external_required(auto_text)
        section = "Spatialcoverage"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            "East": "20",
            "North": "-20",
        }
        SubmitExternal.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    @unittest.skip("Test needs to be fixed")
    def test_ex_000007_related_resources_persists(self):
        """Confirm that Related Resources info persists from submit to edit"""
        # TODO: fix this test
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_external_required(auto_text)
        dict = {"RelationType": "This resource requires", "Value": auto_text + " value"}
        nth = 0
        section = "Relatedresources"
        SubmitExternal.fill_related_resources(
            self.driver, dict["RelationType"], dict["Value"], nth
        )
        SubmitExternal.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        relation = EditExternalSubmission.get_nth_relation_type(self.driver, nth)

        self.assertEqual(relation.pop(), dict.pop("RelationType"))
        match = EditExternalSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    @unittest.skip("Test needs to be fixed")
    def test_ex_000008_multiple_related_resources_persist(self):
        """Confirm that multiple Related Resources info persists from submit to edit"""
        # TODO: fix this test
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_external_required(auto_text)
        section = "Relatedresources"
        ns = [0, 1]
        array = True
        dicts = [None] * len(ns)
        for nth in ns:
            dicts[nth] = {
                "RelationType": "This resource requires",
                "Value": f"{auto_text} value {nth}",
            }
            SubmitExternal.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitExternal.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)
        self.submit(auto_text)

        for nth in ns:
            relation = EditExternalSubmission.get_nth_relation_type(self.driver, nth)
            self.assertEqual(relation.pop(), dicts[nth].pop("RelationType"))

        self.check_array_fieldset_unknown_order(section, ns, dicts, array)

login_and_autofill_external_required(auto_text)

A shortcut to fill required fields of submit page So that additional non-required fields can easily be checked

Source code in dsp/dsp.py
744
745
746
747
748
749
750
751
752
def login_and_autofill_external_required(self, auto_text):
    """A shortcut to fill required fields of submit page
    So that additional non-required fields can easily be checked
    """
    self.login_orcid_and_external()
    SubmitExternal.open_tab(self.driver, "Datepublished", tab_number=2)
    SubmitExternal.autofill_required_elements(
        self.driver, self.required_elements_template(auto_text)
    )

login_orcid_and_external()

Authenticate with orcid

Source code in dsp/dsp.py
729
730
731
732
733
734
735
736
737
738
739
740
741
742
def login_orcid_and_external(self):
    """Authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.select_repo_by_id(self.driver, "RegisterDataset")

    SubmitLandingPage.select_external_dataset(self.driver)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver)
    SubmitExternal.wait_until_loaded(self.driver)

test_ex_000001_authenticate_then_submit_page()

Check authentication to submit page

First, authenticate with Orcid, then navigate to the submit page

Source code in dsp/dsp.py
754
755
756
757
758
759
760
761
762
def test_ex_000001_authenticate_then_submit_page(self):
    """
    Check authentication to submit page

    First, authenticate with Orcid, then navigate to the submit page
    """
    self.login_orcid_and_external()
    header = SubmitExternal.get_header_text(self.driver)
    self.assertIn("External", header)

test_ex_000002_submit_instructions_shown()

Check that instructions are shown on the Submit page

Source code in dsp/dsp.py
764
765
766
767
768
def test_ex_000002_submit_instructions_shown(self):
    """Check that instructions are shown on the Submit page"""
    self.login_orcid_and_external()
    alert = SubmitExternal.get_alert_text(self.driver)
    self.assertIn("Instructions", alert)

test_ex_000003_submit_required_fields()

Confirm successful submit of required fields for External Repo

Source code in dsp/dsp.py
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
def test_ex_000003_submit_required_fields(self):
    """Confirm successful submit of required fields for External Repo"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    # self.login_and_autofill_external_required(auto_text)
    self.login_orcid_and_external()

    SubmitExternal.open_tab(self.driver, "Datepublished", tab_number=2)
    template = self.required_elements_template(auto_text)
    SubmitExternal.autofill_required_elements(self.driver, template)

    self.assertTrue(SubmitExternal.is_finishable(self.driver))
    SubmitExternal.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)

    top_name = MySubmissions.get_top_submission_name(self.driver)

    self.assertEqual(template["BasicInformation"]["Nameortitle"], top_name)

    MySubmissions.edit_top_submission(self.driver)
    self.assertEqual(
        "Register Dataset from External Repository",
        EditExternalSubmission.get_header_title(self.driver),
    )
    self.assertTrue(
        EditExternalSubmission.check_required_elements(self.driver, template)
    )

test_ex_000004_contributors_info_persists()

Confirm that Contributors info persists from submit to edit

Source code in dsp/dsp.py
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
def test_ex_000004_contributors_info_persists(self):
    """Confirm that Contributors info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_external_required(auto_text)
    section = "Contributors"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        # "Phone": "1234567890",
        # "Address": "contributor address " + auto_text,
        "Organization": "contributor org " + auto_text,
        "Email": auto_text + "@gmail.com",
        # "Homepage": "http://contibutor-homepage.com/" + auto_text,
    }
    SubmitExternal.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_ex_000005_temporal_coverage_persists()

Confirm that Temporal coverage persists from submit to edit

Source code in dsp/dsp.py
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
@unittest.expectedFailure
def test_ex_000005_temporal_coverage_persists(self):
    """Confirm that Temporal coverage persists from submit to edit"""

    # TODO: this test fails because the start/end inputs don't have data-ids
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_external_required(auto_text)
    section = "Temporalcoverage"
    nth = 0
    dict = {
        "Start": "2022-03-25T01:00",
        "End": "2022-04-25T02:00",
        "Name": auto_text + "Meister, Jim",
    }
    success_filling = SubmitExternal.fill_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(success_filling)
    SubmitExternal.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    match = EditExternalSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

test_ex_000006_spatial_coverage_persists()

Confirm that Spatial Point Coverage info persists from submit to edit

Source code in dsp/dsp.py
845
846
847
848
849
850
851
852
853
854
855
856
857
def test_ex_000006_spatial_coverage_persists(self):
    """Confirm that Spatial Point Coverage info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_external_required(auto_text)
    section = "Spatialcoverage"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        "East": "20",
        "North": "-20",
    }
    SubmitExternal.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

Confirm that Related Resources info persists from submit to edit

Source code in dsp/dsp.py
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
@unittest.skip("Test needs to be fixed")
def test_ex_000007_related_resources_persists(self):
    """Confirm that Related Resources info persists from submit to edit"""
    # TODO: fix this test
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_external_required(auto_text)
    dict = {"RelationType": "This resource requires", "Value": auto_text + " value"}
    nth = 0
    section = "Relatedresources"
    SubmitExternal.fill_related_resources(
        self.driver, dict["RelationType"], dict["Value"], nth
    )
    SubmitExternal.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    relation = EditExternalSubmission.get_nth_relation_type(self.driver, nth)

    self.assertEqual(relation.pop(), dict.pop("RelationType"))
    match = EditExternalSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

Confirm that multiple Related Resources info persists from submit to edit

Source code in dsp/dsp.py
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
@unittest.skip("Test needs to be fixed")
def test_ex_000008_multiple_related_resources_persist(self):
    """Confirm that multiple Related Resources info persists from submit to edit"""
    # TODO: fix this test
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_external_required(auto_text)
    section = "Relatedresources"
    ns = [0, 1]
    array = True
    dicts = [None] * len(ns)
    for nth in ns:
        dicts[nth] = {
            "RelationType": "This resource requires",
            "Value": f"{auto_text} value {nth}",
        }
        SubmitExternal.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitExternal.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)
    self.submit(auto_text)

    for nth in ns:
        relation = EditExternalSubmission.get_nth_relation_type(self.driver, nth)
        self.assertEqual(relation.pop(), dicts[nth].pop("RelationType"))

    self.check_array_fieldset_unknown_order(section, ns, dicts, array)

DspHydroshareTestSuite

Bases: DspTestSuite

DSP tests for the Hydroshare repository

Source code in dsp/dsp.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
class DspHydroshareTestSuite(DspTestSuite):
    """DSP tests for the Hydroshare repository"""

    repo_name = "HydroShare"

    @classmethod
    def required_elements_template(self, auto_text):
        basic_info = {
            "Title": auto_text + " Title",
            "Abstract": auto_text + " Abstract",
            "Subjectkeywords": [auto_text + " SubjectKeywords"],
        }
        funding_agency = {
            "Agencyname": auto_text + " Agencyname",
            "Awardtitle": auto_text + " Awardtitle",
            "Awardnumber": auto_text + " Awardnumber",
        }

        # created separately so that we can check individually if needed
        required_elements = {
            "BasicInformation": basic_info,
            "Fundingagencyinformation": funding_agency,
        }
        return required_elements

    def login_orcid_and_hs(self):
        """Authenticate with orcid and then HS credentials"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.wait_until_element_exist(
            self.driver, SubmitLandingPage.repositories_header
        )
        SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver)

        # new HS auth window
        SubmitLandingPage.to_repo_auth_window(self.driver)
        HydroshareAuthWindow.authorize_repo(self.driver, HS_USERNAME, HS_PASSWORD)
        HydroshareAuthWindow.to_origin_window(self.driver)
        SubmitHydroshare.wait_until_loaded(self.driver)

    def login_and_autofill_hs_required(self, auto_text):
        """A shortcut to fill required fields of HS submit page
        So that additional non-required fields can easily be checked
        """
        self.login_orcid_and_hs()
        template = self.required_elements_template(auto_text)
        SubmitHydroshare.autofill_required_elements(self.driver, template)

    def test_hs_000001_anon_nav_my_sumissions_shows_orcid(self):
        """Ensure anonymous navigation to my submissions shows orcid login modal"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_my_submissions(self.driver)
        login_visible = MySubmissions.is_visible_orcid_modal(self.driver)
        self.assertTrue(login_visible)

    def test_hs_000002_auth_then_nav_to_submit(self):
        """
        Check authentication to submit page

        Logs in with Orcid, then navigates to the HS repository for submission
        """
        self.login_orcid_and_hs()
        header = SubmitHydroshare.get_header_text(self.driver)
        self.assertIn("Submit", header)

    def test_hs_000003_find_submit_instructions(self):
        """Check that instructions are shown on the Submit page"""
        self.login_orcid_and_hs()
        # SubmitLandingPage.to_repo_form(self.driver, self.repo_name)
        alert = SubmitHydroshare.get_alert_text(self.driver)
        self.assertIn("Instructions", alert)

    def test_hs_000004_submit_required_fields(self):
        """Confirm successful submit of basic required fields to HS"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_orcid_and_hs()
        SubmitHydroshare.autofill_required_elements(self.driver, template)
        self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        self.assertEqual(
            "Edit Submission", EditHSSubmission.get_header_title(self.driver)
        )
        check = EditHSSubmission.check_required_elements(self.driver, template)
        self.assertTrue(check)

    def test_hs_000005_cant_submit_without_each_required(self):
        """Confirm that one can't submit to HS without each required field"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        self.assertTrue(SubmitHydroshare.is_finishable(self.driver))

        template = self.required_elements_template(auto_text)
        for section, dict in template.items():
            for data_id, value in dict.items():
                SubmitHydroshare.unfill_text_by_data_id(
                    self.driver, data_id, section=section, nth=0, array=False
                )
                self.assertRaises(
                    BaseException, SubmitHydroshare.is_finishable(self.driver)
                )
                SubmitHydroshare.expand_section_by_did(self.driver, section)
                SubmitHydroshare.fill_input_by_data_id(
                    self.driver, data_id, value, section, nth=0
                )
                self.assertTrue(SubmitHydroshare.is_finishable(self.driver))

    def test_hs_000006_creator_populates_from_hs(self):
        """
        Confirm that CREATOR is populated from HS profile

        Completing a submission to HS should cause the 'creator' field to be populated
        with info from HS profile
        """
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        section = "Creators"
        nth = 0
        dict = {
            "Name": "test, czhub",
            # "Phone": "4444444444", phone is no longer showing up on beta HS
            "Organization": ("test"),
            "Email": "czhub.test@gmail.com",
        }
        match = EditHSSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    def test_hs_000007_required_fields_persist(self):
        """Check that required fields persist after submit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_and_autofill_hs_required(auto_text)
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        check = EditHSSubmission.check_required_elements(self.driver, template)
        self.assertTrue(check)

    @unittest.expectedFailure
    def test_hs_000008_temporal_coverage_persists(self):
        """Confirm that Temporal coverage persists from submit to edit"""
        # TODO: this test fails because the temporal fields don't have data ids
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Periodcoverage"
        nth = 0
        dict = {
            "Start": "2022-03-25T01:00",
            "End": "2022-04-25T02:00",
            "Name": auto_text + "Meister, Jim",
        }
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(success_filling)
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        match = EditHSSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    def test_hs_000009_funding_agency_persists(self):
        """Confirm that Funding Agency info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Fundingagencyinformation"
        nth = 0
        dict = {
            "FundingAgencyUrl": "http://funding-agency.com/" + auto_text,
        }
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_hs_000010_contributors_info_persists(self):
        """Confirm that Contributors info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Contributors"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            "Phone": "1234567890",
            "Address": "contributor address " + auto_text,
            "Organization": "contributor org " + auto_text,
            "Email": auto_text + "@gmail.com",
            "Homepage": "http://contibutor-homepage.com/" + auto_text,
        }
        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_hs_000011_spatial_coverage_persists(self):
        """Confirm that Spatial Point Coverage info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Spatialcoverage"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            "East": "20",
            "North": "-20",
        }
        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_hs_000012_additional_metadata_persists(self):
        """Confirm that additional metadata info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Additionalmetadata"
        nth = 0
        dict = {"Key": auto_text + " key", "Value": auto_text + " value"}
        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        self.fill_ids_submit_and_check(auto_text, section, nth, dict)

    def test_hs_000013_related_resources_persists(self):
        """Confirm that Related Resources info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        dict = {"RelationType": "This resource includes", "Value": auto_text + " value"}
        nth = 0
        section = "Relatedresources"
        SubmitHydroshare.fill_related_resources(
            self.driver, dict["RelationType"], dict["Value"], nth
        )
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        relation = EditHSSubmission.get_nth_relation_type(self.driver, nth)
        self.assertEqual(relation.pop(), dict.pop("RelationType"))
        match = EditHSSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    def test_hs_000014_spatial_box_coverate_persists(self):
        """Confirm that Spatial Box Coverage info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Spatialcoverage"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            "Northlimit": "20",
            "Eastlimit": "120",
            "Southlimit": "-20",
            "Westlimit": "-120",
        }
        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        SubmitHydroshare.open_tab(self.driver, section, tab_number=2)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(success_filling)
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        EditHSSubmission.open_tab(self.driver, section, tab_number=2)
        match = EditHSSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(match)

    @unittest.expectedFailure
    def test_hs_000015_invalid_spatial_coverage_rejects(self):
        """
        Confirm that invalid Spatial Box Coverage info doesn't submit

        Attempts to submit Box Coverage that doesn't make geographic sense and ensures
        that the invalid info is not accepted
        """
        # TODO: this test fails pending issue
        # https://github.com/cznethub/dspfront/issues/55
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Spatialcoverage"
        nth = 0
        dict = {
            "Name": auto_text + "Contributor name2-input",
            "Northlimit": "-20",
            "Southlimit": "20",
            "Eastlimit": "120",
            "Westlimit": "-120",
        }
        SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
        SubmitHydroshare.open_tab(self.driver, section, tab_number=2)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(success_filling)
        self.assertFalse(SubmitHydroshare.is_finishable(self.driver))

    def test_hs_000016_submissions_sorted(self):
        """
        Confirm that submissions are sorted after submission

        The most recent submission should be at the top of the page initially
        """
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_orcid_and_hs()
        SubmitHydroshare.autofill_required_elements(self.driver, template)
        self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)

        check = EditHSSubmission.check_required_elements(self.driver, template)
        self.assertTrue(check)

    def test_hs_000017_multiple_creators_persist(self):
        """Confirm that multiple Creators info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Creators"
        ns = [0, 1]
        reversed = False
        dicts = [None] * len(ns)
        array = True
        for nth in ns:
            dicts[nth] = {
                "Name": f"{auto_text} name {nth}",
                "Phone": "1234567890",
                "Address": f"creator address {auto_text} {nth}",
                "Organization": f"creator org {auto_text} {nth}",
                "Email": f"{auto_text}{nth}@gmail.com",
                "Homepage": f"http://contibutor-homepage.com/{auto_text}{nth}",
            }
            SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)

        self.submit(auto_text)
        for nth in ns:
            # Shift creators by 1: HS inserts the submitter as a creator
            if reversed:
                self.check(section, nth+1, dicts.pop(), array)
            else:
                self.check(section, nth+1, dicts[nth], array)

    def test_hs_000018_multiple_contributors_persist(self):
        """Confirm that multiple Contributors info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Contributors"
        ns = [0, 1]
        array = True
        dicts = [None] * len(ns)
        for nth in ns:
            dicts[nth] = {
                "Name": f"{auto_text} name {nth}",
                "Phone": "1234567890",
                "Address": f"contributor address {auto_text} {nth}",
                "Organization": f"contributor org {auto_text} {nth}",
                "Email": f"{auto_text}{nth}@gmail.com",
                "Homepage": f"http://contibutor-homepage.com/{auto_text}{nth}",
            }
            SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)

        self.submit(auto_text)
        self.check_array_fieldset_unknown_order(section, ns, dicts, array)

    def test_hs_000019_multiple_metadata_persists(self):
        """
        Confirm that multiple Additional Metadata info persists from submit to edit
        """
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Additionalmetadata"
        ns = [0, 1]
        dicts = [None] * len(ns)
        array = True
        for nth in ns:
            dicts[nth] = {
                "Key": f"{auto_text} key {nth}",
                "Value": f"{auto_text} value {nth}",
            }
            SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)

        self.submit(auto_text)
        self.check_array_fieldset_unknown_order(section, ns, dicts, array)

    def test_hs_000020_multiple_related_resources_persist(self):
        """Confirm that multiple Related Resources info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_hs_required(auto_text)
        section = "Relatedresources"
        ns = [0, 1]
        array = True
        dicts = [None] * len(ns)
        for nth in ns:
            dicts[nth] = {
                "RelationType": "This resource includes",
                "Value": f"{auto_text} value {nth}",
            }
            SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)

        self.submit(auto_text)

        for nth in ns:
            relation = EditHSSubmission.get_nth_relation_type(self.driver, nth)
            self.assertEqual(relation.pop(), dicts[nth].pop("RelationType"))

        self.check_array_fieldset_unknown_order(section, ns, dicts, array)

    def test_hs_000021_multiple_funding_agencies_persist(self):
        """Confirm that multiple Funding Agencies info persists from submit to edit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_orcid_and_hs()
        template = {
            "BasicInformation": {
                "Title": auto_text + " Title",
                "Abstract": auto_text + " Abstract",
                "Subjectkeywords": [auto_text + " SubjectKeywords"],
            }
        }
        SubmitHydroshare.autofill_required_elements(self.driver, template)
        section = "Fundingagencyinformation"
        ns = [0, 1]
        dicts = [None] * len(ns)
        array = True
        for nth in ns:
            dicts[nth] = {
                "Agencyname": f"{auto_text} Funding Agency Name {nth}",
                "Awardtitle": f"{auto_text} Funding Agency title2-input {nth}",
                "Awardnumber": f"5{nth}",
                "FundingAgencyUrl": f"http://funding-agency.com/{auto_text}/{nth}",
            }
            SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
            success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
                self.driver, dicts[nth], section, nth, array
            )
            self.assertTrue(success_filling)

        self.submit(auto_text)

        self.check_array_fieldset_unknown_order(section, ns, dicts, array)

    def test_hs_000022_able_to_view_in_repository(self):
        """
        From My Submissions, confirm that we can "view in repository" HS submission
        """
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_orcid_and_hs()
        SubmitHydroshare.autofill_required_elements(self.driver, template)
        self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
        SubmitHydroshare.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.view_top_submission(self.driver)

        MySubmissions.to_hs_repo(self.driver)
        self.assertEqual(
            HSResourcePage.get_title(self.driver), template["BasicInformation"]["Title"]
        )

login_and_autofill_hs_required(auto_text)

A shortcut to fill required fields of HS submit page So that additional non-required fields can easily be checked

Source code in dsp/dsp.py
228
229
230
231
232
233
234
def login_and_autofill_hs_required(self, auto_text):
    """A shortcut to fill required fields of HS submit page
    So that additional non-required fields can easily be checked
    """
    self.login_orcid_and_hs()
    template = self.required_elements_template(auto_text)
    SubmitHydroshare.autofill_required_elements(self.driver, template)

login_orcid_and_hs()

Authenticate with orcid and then HS credentials

Source code in dsp/dsp.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
def login_orcid_and_hs(self):
    """Authenticate with orcid and then HS credentials"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.wait_until_element_exist(
        self.driver, SubmitLandingPage.repositories_header
    )
    SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver)

    # new HS auth window
    SubmitLandingPage.to_repo_auth_window(self.driver)
    HydroshareAuthWindow.authorize_repo(self.driver, HS_USERNAME, HS_PASSWORD)
    HydroshareAuthWindow.to_origin_window(self.driver)
    SubmitHydroshare.wait_until_loaded(self.driver)

test_hs_000001_anon_nav_my_sumissions_shows_orcid()

Ensure anonymous navigation to my submissions shows orcid login modal

Source code in dsp/dsp.py
236
237
238
239
240
241
def test_hs_000001_anon_nav_my_sumissions_shows_orcid(self):
    """Ensure anonymous navigation to my submissions shows orcid login modal"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_my_submissions(self.driver)
    login_visible = MySubmissions.is_visible_orcid_modal(self.driver)
    self.assertTrue(login_visible)

test_hs_000002_auth_then_nav_to_submit()

Check authentication to submit page

Logs in with Orcid, then navigates to the HS repository for submission

Source code in dsp/dsp.py
243
244
245
246
247
248
249
250
251
def test_hs_000002_auth_then_nav_to_submit(self):
    """
    Check authentication to submit page

    Logs in with Orcid, then navigates to the HS repository for submission
    """
    self.login_orcid_and_hs()
    header = SubmitHydroshare.get_header_text(self.driver)
    self.assertIn("Submit", header)

test_hs_000003_find_submit_instructions()

Check that instructions are shown on the Submit page

Source code in dsp/dsp.py
253
254
255
256
257
258
def test_hs_000003_find_submit_instructions(self):
    """Check that instructions are shown on the Submit page"""
    self.login_orcid_and_hs()
    # SubmitLandingPage.to_repo_form(self.driver, self.repo_name)
    alert = SubmitHydroshare.get_alert_text(self.driver)
    self.assertIn("Instructions", alert)

test_hs_000004_submit_required_fields()

Confirm successful submit of basic required fields to HS

Source code in dsp/dsp.py
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
def test_hs_000004_submit_required_fields(self):
    """Confirm successful submit of basic required fields to HS"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_orcid_and_hs()
    SubmitHydroshare.autofill_required_elements(self.driver, template)
    self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    self.assertEqual(
        "Edit Submission", EditHSSubmission.get_header_title(self.driver)
    )
    check = EditHSSubmission.check_required_elements(self.driver, template)
    self.assertTrue(check)

test_hs_000005_cant_submit_without_each_required()

Confirm that one can't submit to HS without each required field

Source code in dsp/dsp.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
def test_hs_000005_cant_submit_without_each_required(self):
    """Confirm that one can't submit to HS without each required field"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    self.assertTrue(SubmitHydroshare.is_finishable(self.driver))

    template = self.required_elements_template(auto_text)
    for section, dict in template.items():
        for data_id, value in dict.items():
            SubmitHydroshare.unfill_text_by_data_id(
                self.driver, data_id, section=section, nth=0, array=False
            )
            self.assertRaises(
                BaseException, SubmitHydroshare.is_finishable(self.driver)
            )
            SubmitHydroshare.expand_section_by_did(self.driver, section)
            SubmitHydroshare.fill_input_by_data_id(
                self.driver, data_id, value, section, nth=0
            )
            self.assertTrue(SubmitHydroshare.is_finishable(self.driver))

test_hs_000006_creator_populates_from_hs()

Confirm that CREATOR is populated from HS profile

Completing a submission to HS should cause the 'creator' field to be populated with info from HS profile

Source code in dsp/dsp.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
def test_hs_000006_creator_populates_from_hs(self):
    """
    Confirm that CREATOR is populated from HS profile

    Completing a submission to HS should cause the 'creator' field to be populated
    with info from HS profile
    """
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    section = "Creators"
    nth = 0
    dict = {
        "Name": "test, czhub",
        # "Phone": "4444444444", phone is no longer showing up on beta HS
        "Organization": ("test"),
        "Email": "czhub.test@gmail.com",
    }
    match = EditHSSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

test_hs_000007_required_fields_persist()

Check that required fields persist after submit

Source code in dsp/dsp.py
328
329
330
331
332
333
334
335
336
337
338
339
340
def test_hs_000007_required_fields_persist(self):
    """Check that required fields persist after submit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_and_autofill_hs_required(auto_text)
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    check = EditHSSubmission.check_required_elements(self.driver, template)
    self.assertTrue(check)

test_hs_000008_temporal_coverage_persists()

Confirm that Temporal coverage persists from submit to edit

Source code in dsp/dsp.py
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
@unittest.expectedFailure
def test_hs_000008_temporal_coverage_persists(self):
    """Confirm that Temporal coverage persists from submit to edit"""
    # TODO: this test fails because the temporal fields don't have data ids
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Periodcoverage"
    nth = 0
    dict = {
        "Start": "2022-03-25T01:00",
        "End": "2022-04-25T02:00",
        "Name": auto_text + "Meister, Jim",
    }
    success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(success_filling)
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    match = EditHSSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

test_hs_000009_funding_agency_persists()

Confirm that Funding Agency info persists from submit to edit

Source code in dsp/dsp.py
370
371
372
373
374
375
376
377
378
379
def test_hs_000009_funding_agency_persists(self):
    """Confirm that Funding Agency info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Fundingagencyinformation"
    nth = 0
    dict = {
        "FundingAgencyUrl": "http://funding-agency.com/" + auto_text,
    }
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_hs_000010_contributors_info_persists()

Confirm that Contributors info persists from submit to edit

Source code in dsp/dsp.py
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
def test_hs_000010_contributors_info_persists(self):
    """Confirm that Contributors info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Contributors"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        "Phone": "1234567890",
        "Address": "contributor address " + auto_text,
        "Organization": "contributor org " + auto_text,
        "Email": auto_text + "@gmail.com",
        "Homepage": "http://contibutor-homepage.com/" + auto_text,
    }
    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_hs_000011_spatial_coverage_persists()

Confirm that Spatial Point Coverage info persists from submit to edit

Source code in dsp/dsp.py
398
399
400
401
402
403
404
405
406
407
408
409
410
def test_hs_000011_spatial_coverage_persists(self):
    """Confirm that Spatial Point Coverage info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Spatialcoverage"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        "East": "20",
        "North": "-20",
    }
    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

test_hs_000012_additional_metadata_persists()

Confirm that additional metadata info persists from submit to edit

Source code in dsp/dsp.py
412
413
414
415
416
417
418
419
420
def test_hs_000012_additional_metadata_persists(self):
    """Confirm that additional metadata info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Additionalmetadata"
    nth = 0
    dict = {"Key": auto_text + " key", "Value": auto_text + " value"}
    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    self.fill_ids_submit_and_check(auto_text, section, nth, dict)

Confirm that Related Resources info persists from submit to edit

Source code in dsp/dsp.py
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
def test_hs_000013_related_resources_persists(self):
    """Confirm that Related Resources info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    dict = {"RelationType": "This resource includes", "Value": auto_text + " value"}
    nth = 0
    section = "Relatedresources"
    SubmitHydroshare.fill_related_resources(
        self.driver, dict["RelationType"], dict["Value"], nth
    )
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    relation = EditHSSubmission.get_nth_relation_type(self.driver, nth)
    self.assertEqual(relation.pop(), dict.pop("RelationType"))
    match = EditHSSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

test_hs_000014_spatial_box_coverate_persists()

Confirm that Spatial Box Coverage info persists from submit to edit

Source code in dsp/dsp.py
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
def test_hs_000014_spatial_box_coverate_persists(self):
    """Confirm that Spatial Box Coverage info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Spatialcoverage"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        "Northlimit": "20",
        "Eastlimit": "120",
        "Southlimit": "-20",
        "Westlimit": "-120",
    }
    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    SubmitHydroshare.open_tab(self.driver, section, tab_number=2)
    success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(success_filling)
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    EditHSSubmission.open_tab(self.driver, section, tab_number=2)
    match = EditHSSubmission.check_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(match)

test_hs_000015_invalid_spatial_coverage_rejects()

Confirm that invalid Spatial Box Coverage info doesn't submit

Attempts to submit Box Coverage that doesn't make geographic sense and ensures that the invalid info is not accepted

Source code in dsp/dsp.py
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
@unittest.expectedFailure
def test_hs_000015_invalid_spatial_coverage_rejects(self):
    """
    Confirm that invalid Spatial Box Coverage info doesn't submit

    Attempts to submit Box Coverage that doesn't make geographic sense and ensures
    that the invalid info is not accepted
    """
    # TODO: this test fails pending issue
    # https://github.com/cznethub/dspfront/issues/55
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Spatialcoverage"
    nth = 0
    dict = {
        "Name": auto_text + "Contributor name2-input",
        "Northlimit": "-20",
        "Southlimit": "20",
        "Eastlimit": "120",
        "Westlimit": "-120",
    }
    SubmitHydroshare.expand_section_by_did(self.driver, data_id=section)
    SubmitHydroshare.open_tab(self.driver, section, tab_number=2)
    success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(success_filling)
    self.assertFalse(SubmitHydroshare.is_finishable(self.driver))

test_hs_000016_submissions_sorted()

Confirm that submissions are sorted after submission

The most recent submission should be at the top of the page initially

Source code in dsp/dsp.py
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
def test_hs_000016_submissions_sorted(self):
    """
    Confirm that submissions are sorted after submission

    The most recent submission should be at the top of the page initially
    """
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_orcid_and_hs()
    SubmitHydroshare.autofill_required_elements(self.driver, template)
    self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)

    check = EditHSSubmission.check_required_elements(self.driver, template)
    self.assertTrue(check)

test_hs_000017_multiple_creators_persist()

Confirm that multiple Creators info persists from submit to edit

Source code in dsp/dsp.py
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
def test_hs_000017_multiple_creators_persist(self):
    """Confirm that multiple Creators info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Creators"
    ns = [0, 1]
    reversed = False
    dicts = [None] * len(ns)
    array = True
    for nth in ns:
        dicts[nth] = {
            "Name": f"{auto_text} name {nth}",
            "Phone": "1234567890",
            "Address": f"creator address {auto_text} {nth}",
            "Organization": f"creator org {auto_text} {nth}",
            "Email": f"{auto_text}{nth}@gmail.com",
            "Homepage": f"http://contibutor-homepage.com/{auto_text}{nth}",
        }
        SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)

    self.submit(auto_text)
    for nth in ns:
        # Shift creators by 1: HS inserts the submitter as a creator
        if reversed:
            self.check(section, nth+1, dicts.pop(), array)
        else:
            self.check(section, nth+1, dicts[nth], array)

test_hs_000018_multiple_contributors_persist()

Confirm that multiple Contributors info persists from submit to edit

Source code in dsp/dsp.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
def test_hs_000018_multiple_contributors_persist(self):
    """Confirm that multiple Contributors info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Contributors"
    ns = [0, 1]
    array = True
    dicts = [None] * len(ns)
    for nth in ns:
        dicts[nth] = {
            "Name": f"{auto_text} name {nth}",
            "Phone": "1234567890",
            "Address": f"contributor address {auto_text} {nth}",
            "Organization": f"contributor org {auto_text} {nth}",
            "Email": f"{auto_text}{nth}@gmail.com",
            "Homepage": f"http://contibutor-homepage.com/{auto_text}{nth}",
        }
        SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)

    self.submit(auto_text)
    self.check_array_fieldset_unknown_order(section, ns, dicts, array)

test_hs_000019_multiple_metadata_persists()

Confirm that multiple Additional Metadata info persists from submit to edit

Source code in dsp/dsp.py
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
def test_hs_000019_multiple_metadata_persists(self):
    """
    Confirm that multiple Additional Metadata info persists from submit to edit
    """
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Additionalmetadata"
    ns = [0, 1]
    dicts = [None] * len(ns)
    array = True
    for nth in ns:
        dicts[nth] = {
            "Key": f"{auto_text} key {nth}",
            "Value": f"{auto_text} value {nth}",
        }
        SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)

    self.submit(auto_text)
    self.check_array_fieldset_unknown_order(section, ns, dicts, array)

Confirm that multiple Related Resources info persists from submit to edit

Source code in dsp/dsp.py
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
def test_hs_000020_multiple_related_resources_persist(self):
    """Confirm that multiple Related Resources info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_hs_required(auto_text)
    section = "Relatedresources"
    ns = [0, 1]
    array = True
    dicts = [None] * len(ns)
    for nth in ns:
        dicts[nth] = {
            "RelationType": "This resource includes",
            "Value": f"{auto_text} value {nth}",
        }
        SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)

    self.submit(auto_text)

    for nth in ns:
        relation = EditHSSubmission.get_nth_relation_type(self.driver, nth)
        self.assertEqual(relation.pop(), dicts[nth].pop("RelationType"))

    self.check_array_fieldset_unknown_order(section, ns, dicts, array)

test_hs_000021_multiple_funding_agencies_persist()

Confirm that multiple Funding Agencies info persists from submit to edit

Source code in dsp/dsp.py
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
def test_hs_000021_multiple_funding_agencies_persist(self):
    """Confirm that multiple Funding Agencies info persists from submit to edit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_orcid_and_hs()
    template = {
        "BasicInformation": {
            "Title": auto_text + " Title",
            "Abstract": auto_text + " Abstract",
            "Subjectkeywords": [auto_text + " SubjectKeywords"],
        }
    }
    SubmitHydroshare.autofill_required_elements(self.driver, template)
    section = "Fundingagencyinformation"
    ns = [0, 1]
    dicts = [None] * len(ns)
    array = True
    for nth in ns:
        dicts[nth] = {
            "Agencyname": f"{auto_text} Funding Agency Name {nth}",
            "Awardtitle": f"{auto_text} Funding Agency title2-input {nth}",
            "Awardnumber": f"5{nth}",
            "FundingAgencyUrl": f"http://funding-agency.com/{auto_text}/{nth}",
        }
        SubmitHydroshare.add_form_array_item_by_did(self.driver, data_id=section)
        success_filling = SubmitHydroshare.fill_inputs_by_data_ids(
            self.driver, dicts[nth], section, nth, array
        )
        self.assertTrue(success_filling)

    self.submit(auto_text)

    self.check_array_fieldset_unknown_order(section, ns, dicts, array)

test_hs_000022_able_to_view_in_repository()

From My Submissions, confirm that we can "view in repository" HS submission

Source code in dsp/dsp.py
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
def test_hs_000022_able_to_view_in_repository(self):
    """
    From My Submissions, confirm that we can "view in repository" HS submission
    """
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_orcid_and_hs()
    SubmitHydroshare.autofill_required_elements(self.driver, template)
    self.assertTrue(SubmitHydroshare.is_finishable(self.driver))
    SubmitHydroshare.finish_submission(self.driver)

    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.view_top_submission(self.driver)

    MySubmissions.to_hs_repo(self.driver)
    self.assertEqual(
        HSResourcePage.get_title(self.driver), template["BasicInformation"]["Title"]
    )

DspTestSuite

Bases: BaseTestSuite

Python unittest setup for functional tests

Source code in dsp/dsp.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
class DspTestSuite(BaseTestSuite, metaclass=ErrorCatcher):
    """Python unittest setup for functional tests"""

    def setUp(self):
        super(DspTestSuite, self).setUp()
        self.driver.set_window_size(1200, 1080)
        if not self.base_url_arg:
            self.driver.get(BASE_URL)
        else:
            self.driver.get(self.base_url_arg)

    def tearDown(self):
        try:
            Dsp.show_mobile_nav(self.driver)
            Dsp.drawer_to_my_submissions(self.driver)
            MySubmissions.delete_submissions(self.driver, silent=True)
        except Exception:
            # Allow exceptions during attempted submissions cleaning
            pass
        super(DspTestSuite, self).tearDown()

    def login_orcid(self):
        """Authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_nav_login.click(self.driver)
        Dsp.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver, wait=True)

    def login_orcid_to_submit(self, repo):
        self.login_orcid()
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, repo)

    def fill_ids_submit_and_check(self, sort_text, section, nth, dict, array=False):
        """Fill additional fields of submit page based on 'data-id'
        Then submit the form, search in 'My Submissions',
        and check that all of the fields match what was entered
        """
        success_filling = GeneralSubmitToRepo.fill_inputs_by_data_ids(
            self.driver, dict, section, nth
        )
        self.assertTrue(success_filling)
        self.submit_and_check(sort_text, section, nth, dict, array)

    def submit_and_check(self, sort_text, section, nth, dict, array=False):
        self.submit(sort_text)
        self.check(section, nth, dict, array)

    def submit(self, sort_text):
        GeneralSubmitToRepo.finish_submission(self.driver)

        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")
        MySubmissions.enter_text_in_search(self.driver, sort_text)
        MySubmissions.edit_top_submission(self.driver)

    def check(self, section, nth, dict, array=False):
        match = GeneralEditSubmission.check_inputs_by_data_ids(
            self.driver, dict, section, nth, array
        )
        self.assertTrue(match)

    def check_array_fieldset_unknown_order(self, section, ns, dicts, array):
        reversed = False
        for nth in ns:
            if not reversed:
                try:
                    self.check(section, nth, dicts[nth], array)
                except AssertionError:
                    reversed = True
                    ns.insert(0, nth)
                    print("\n Array items were reversed during this test")
            else:
                self.check(section, nth, dicts.pop(), array)

    def test_base_000001_home_page(self):
        """
        Check home page load
        """

        self.assertTrue(Dsp.app_contains_text("Critical Zone Collaborative Network"))

fill_ids_submit_and_check(sort_text, section, nth, dict, array=False)

Fill additional fields of submit page based on 'data-id' Then submit the form, search in 'My Submissions', and check that all of the fields match what was entered

Source code in dsp/dsp.py
133
134
135
136
137
138
139
140
141
142
def fill_ids_submit_and_check(self, sort_text, section, nth, dict, array=False):
    """Fill additional fields of submit page based on 'data-id'
    Then submit the form, search in 'My Submissions',
    and check that all of the fields match what was entered
    """
    success_filling = GeneralSubmitToRepo.fill_inputs_by_data_ids(
        self.driver, dict, section, nth
    )
    self.assertTrue(success_filling)
    self.submit_and_check(sort_text, section, nth, dict, array)

login_orcid()

Authenticate with orcid

Source code in dsp/dsp.py
118
119
120
121
122
123
124
125
def login_orcid(self):
    """Authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_nav_login.click(self.driver)
    Dsp.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver, wait=True)

test_base_000001_home_page()

Check home page load

Source code in dsp/dsp.py
174
175
176
177
178
179
def test_base_000001_home_page(self):
    """
    Check home page load
    """

    self.assertTrue(Dsp.app_contains_text("Critical Zone Collaborative Network"))

DspZenodoTestSuite

Bases: DspTestSuite

DSP tests for Zenodo backend

Source code in dsp/dsp.py
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
class DspZenodoTestSuite(DspTestSuite):
    """DSP tests for Zenodo backend"""

    repo_name = "Zenodo"

    @classmethod
    def required_elements_template(self, auto_text):
        basic_info = {
            "Title": auto_text + " Title",
            "Description/Abstract": auto_text + " Description/Abstract",
            "Keywords": [auto_text + " Keywords"],
        }
        # as of the following commit
        # https://github.com/cznethub/dspfront/commit/2ef4408e40dfb74d837c9699adaeb7879c843d74
        # funding agency is required but it is pre-filled now...
        # funding_agency = {
        #     "Agencyname": auto_text + " Fundingagencyname",
        #     "Awardtitle": auto_text + " Awardtitle",
        #     "Awardnumber": auto_text + " Awardnumberoridentifier",
        #     "AgencyURL": "http://funding-agency.com/" + auto_text,
        # }

        required_elements = {
            "BasicInformation": basic_info,
            # "FundingAgencyMetadata": funding_agency,
        }
        return required_elements

    def zenodo_then_login_orcid(self):
        """Select Zenodo repo then authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver)

        # new Zenodo auth window
        SubmitLandingPage.to_repo_auth_window(self.driver)

        ZenodoAuthWindow.authorize_via_orcid(self.driver)
        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver)

    def zenodo_then_login_username_password(self):
        """Select Zenodo repo then authenticate with orcid"""
        Dsp.show_mobile_nav(self.driver)
        Dsp.drawer_to_submit(self.driver)
        SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

        # new ORCID window
        SubmitLandingPage.to_orcid_window(self.driver)

        OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
        OrcidWindow.to_origin_window(self.driver)

        # new Zenodo auth window
        SubmitLandingPage.to_repo_auth_window(self.driver)
        ZenodoAuthWindow.authorize_email_password(
            self.driver, email=USERNAME, password=PASSWORD
        )
        ZenodoAuthWindow.to_origin_window(self.driver, wait=True)

    def login_orcid_to_submit(self):
        """Authenticate with orcid the select repo"""
        super().login_orcid_to_submit(self.repo_name)
        if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
            SubmitLandingPage.to_repo_auth_window(self.driver)
            ZenodoAuthWindow.authorize_email_password(
                self.driver, email=USERNAME, password=PASSWORD
            )
            ZenodoAuthWindow.to_origin_window(self.driver, wait=True)

    def login_and_autofill_zenodo_required(self, auto_text):
        """A shortcut to fill required fields of submit page
        So that additional non-required fields can easily be checked
        """
        self.zenodo_then_login_username_password()
        SubmitZenodo.autofill_required_elements(
            self.driver, self.required_elements_template(auto_text)
        )

    def test_ze_000001_orcid_then_submit(self):
        """Check authentication with Orcid, then navigate to submit page"""
        self.login_orcid_to_submit()
        header = SubmitZenodo.get_header_text(self.driver)
        self.assertIn(self.repo_name, header)
        alert = SubmitZenodo.get_alert_text(self.driver)
        self.assertIn("Instructions", alert)

    @unittest.skip("Fails pending https://github.com/cznethub/dspfront/issues/57")
    def test_ze_000002_repo_then_auth_w_orcid(self):
        """Navigate to Zenodo submit first, then auth with orcid"""
        self.zenodo_then_login_orcid()
        header = SubmitZenodo.get_header_text(self.driver)
        self.assertIn(self.repo_name, header)

    def test_ze_000003_nav_to_repo_then_auth_user_pw(self):
        """Navigate to Zenodo submit, then auth with uname/pw"""
        self.zenodo_then_login_username_password()
        header = SubmitZenodo.get_header_text(self.driver)
        self.assertIn(self.repo_name, header)

    def test_ze_000004_submit_required_fields(self):
        """Confirm successful submit of required fields for Zenodo Repo"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        self.login_and_autofill_zenodo_required(auto_text)
        self.assertTrue(SubmitZenodo.is_finishable(self.driver))
        SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)
        self.assertEqual("My Submissions", MySubmissions.get_title(self.driver))
        MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

    def test_ze_000005_required_fields_persist(self):
        """Check that required fields persist after submit"""
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_and_autofill_zenodo_required(auto_text)
        SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)

        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.edit_top_submission(self.driver)
        self.assertEqual(
            "Edit Submission", EditZenodoSubmission.get_header_title(self.driver)
        )
        check = EditZenodoSubmission.check_required_elements(self.driver, template)
        self.assertTrue(check)

    def test_ze_000006_able_to_view_in_repository(self):
        """
        From My Submissions, confirm that we can "view in repository" zenodo submission
        """
        auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
        template = self.required_elements_template(auto_text)
        self.login_and_autofill_zenodo_required(auto_text)
        SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)

        MySubmissions.enter_text_in_search(self.driver, auto_text)
        MySubmissions.view_top_submission(self.driver)
        MySubmissions.to_zenodo_repo(self.driver)
        self.assertEqual(
            ZenodoResourcePage.get_title(self.driver),
            template["BasicInformation"]["Title"],
        )

login_and_autofill_zenodo_required(auto_text)

A shortcut to fill required fields of submit page So that additional non-required fields can easily be checked

Source code in dsp/dsp.py
990
991
992
993
994
995
996
997
def login_and_autofill_zenodo_required(self, auto_text):
    """A shortcut to fill required fields of submit page
    So that additional non-required fields can easily be checked
    """
    self.zenodo_then_login_username_password()
    SubmitZenodo.autofill_required_elements(
        self.driver, self.required_elements_template(auto_text)
    )

login_orcid_to_submit()

Authenticate with orcid the select repo

Source code in dsp/dsp.py
980
981
982
983
984
985
986
987
988
def login_orcid_to_submit(self):
    """Authenticate with orcid the select repo"""
    super().login_orcid_to_submit(self.repo_name)
    if RepoAuthWindow.submit_to_repo_authorize.exists(self.driver):
        SubmitLandingPage.to_repo_auth_window(self.driver)
        ZenodoAuthWindow.authorize_email_password(
            self.driver, email=USERNAME, password=PASSWORD
        )
        ZenodoAuthWindow.to_origin_window(self.driver, wait=True)

test_ze_000001_orcid_then_submit()

Check authentication with Orcid, then navigate to submit page

Source code in dsp/dsp.py
 999
1000
1001
1002
1003
1004
1005
def test_ze_000001_orcid_then_submit(self):
    """Check authentication with Orcid, then navigate to submit page"""
    self.login_orcid_to_submit()
    header = SubmitZenodo.get_header_text(self.driver)
    self.assertIn(self.repo_name, header)
    alert = SubmitZenodo.get_alert_text(self.driver)
    self.assertIn("Instructions", alert)

test_ze_000002_repo_then_auth_w_orcid()

Navigate to Zenodo submit first, then auth with orcid

Source code in dsp/dsp.py
1007
1008
1009
1010
1011
1012
@unittest.skip("Fails pending https://github.com/cznethub/dspfront/issues/57")
def test_ze_000002_repo_then_auth_w_orcid(self):
    """Navigate to Zenodo submit first, then auth with orcid"""
    self.zenodo_then_login_orcid()
    header = SubmitZenodo.get_header_text(self.driver)
    self.assertIn(self.repo_name, header)

test_ze_000003_nav_to_repo_then_auth_user_pw()

Navigate to Zenodo submit, then auth with uname/pw

Source code in dsp/dsp.py
1014
1015
1016
1017
1018
def test_ze_000003_nav_to_repo_then_auth_user_pw(self):
    """Navigate to Zenodo submit, then auth with uname/pw"""
    self.zenodo_then_login_username_password()
    header = SubmitZenodo.get_header_text(self.driver)
    self.assertIn(self.repo_name, header)

test_ze_000004_submit_required_fields()

Confirm successful submit of required fields for Zenodo Repo

Source code in dsp/dsp.py
1020
1021
1022
1023
1024
1025
1026
1027
def test_ze_000004_submit_required_fields(self):
    """Confirm successful submit of required fields for Zenodo Repo"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    self.login_and_autofill_zenodo_required(auto_text)
    self.assertTrue(SubmitZenodo.is_finishable(self.driver))
    SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)
    self.assertEqual("My Submissions", MySubmissions.get_title(self.driver))
    MySubmissions.wait_until_app_contains_text(self.driver, "My Submissions")

test_ze_000005_required_fields_persist()

Check that required fields persist after submit

Source code in dsp/dsp.py
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
def test_ze_000005_required_fields_persist(self):
    """Check that required fields persist after submit"""
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_and_autofill_zenodo_required(auto_text)
    SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)

    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.edit_top_submission(self.driver)
    self.assertEqual(
        "Edit Submission", EditZenodoSubmission.get_header_title(self.driver)
    )
    check = EditZenodoSubmission.check_required_elements(self.driver, template)
    self.assertTrue(check)

test_ze_000006_able_to_view_in_repository()

From My Submissions, confirm that we can "view in repository" zenodo submission

Source code in dsp/dsp.py
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
def test_ze_000006_able_to_view_in_repository(self):
    """
    From My Submissions, confirm that we can "view in repository" zenodo submission
    """
    auto_text = time.strftime("%d_%b_%Y_%H-%M-%S", time.gmtime())
    template = self.required_elements_template(auto_text)
    self.login_and_autofill_zenodo_required(auto_text)
    SubmitZenodo.finish_submission(self.driver, USERNAME, PASSWORD)

    MySubmissions.enter_text_in_search(self.driver, auto_text)
    MySubmissions.view_top_submission(self.driver)
    MySubmissions.to_zenodo_repo(self.driver)
    self.assertEqual(
        ZenodoResourcePage.get_title(self.driver),
        template["BasicInformation"]["Title"],
    )

zenodo_then_login_orcid()

Select Zenodo repo then authenticate with orcid

Source code in dsp/dsp.py
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
def zenodo_then_login_orcid(self):
    """Select Zenodo repo then authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver)

    # new Zenodo auth window
    SubmitLandingPage.to_repo_auth_window(self.driver)

    ZenodoAuthWindow.authorize_via_orcid(self.driver)
    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver)

zenodo_then_login_username_password()

Select Zenodo repo then authenticate with orcid

Source code in dsp/dsp.py
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
def zenodo_then_login_username_password(self):
    """Select Zenodo repo then authenticate with orcid"""
    Dsp.show_mobile_nav(self.driver)
    Dsp.drawer_to_submit(self.driver)
    SubmitLandingPage.select_repo_by_id(self.driver, self.repo_name)

    # new ORCID window
    SubmitLandingPage.to_orcid_window(self.driver)

    OrcidWindow.fill_credentials(self.driver, USERNAME, PASSWORD)
    OrcidWindow.to_origin_window(self.driver)

    # new Zenodo auth window
    SubmitLandingPage.to_repo_auth_window(self.driver)
    ZenodoAuthWindow.authorize_email_password(
        self.driver, email=USERNAME, password=PASSWORD
    )
    ZenodoAuthWindow.to_origin_window(self.driver, wait=True)