def test_change_element_value(): """ Test changing and elements value """ expected_project = { "ProjID": "1", "UserName": "******", "DateCreated": "2014-04-22T10:00:00.0000-00:00", "ProjName": "updated-my-project" } project = waterxml.create_project_dict() project = waterxml.fill_dict(waterxml_tree=fixture["xml_tree1"], data_dict=project, element="Project", keys=project.keys()) waterxml.change_element_value(waterxml_tree=fixture["xml_tree1"], element="Project", child="ProjName", new_value="-".join( ["updated", project["ProjName"]])) project_updated = waterxml.create_project_dict() actual_project = waterxml.fill_dict(waterxml_tree=fixture["xml_tree1"], data_dict=project_updated, element="Project", keys=project.keys()) # print results np.testing.assert_equal(actual_project, expected_project)
def test_change_element_value(): """ Test changing and elements value """ expected_project = {"ProjID": "1", "UserName": "******", "DateCreated": "2014-04-22T10:00:00.0000-00:00", "ProjName": "updated-my-project"} project = waterxml.create_project_dict() project = waterxml.fill_dict(waterxml_tree = fixture["xml_tree1"], data_dict = project, element = "Project", keys = project.keys()) waterxml.change_element_value(waterxml_tree = fixture["xml_tree1"], element = "Project", child = "ProjName" , new_value = "-".join(["updated", project["ProjName"]])) project_updated = waterxml.create_project_dict() actual_project = waterxml.fill_dict(waterxml_tree = fixture["xml_tree1"], data_dict = project_updated, element = "Project", keys = project.keys()) # print results np.testing.assert_equal(actual_project, expected_project)
def test_fill_dict(): expected_project = {"ProjID": "1", "UserName": "******", "DateCreated": "2014-04-22T10:00:00.0000-00:00", "ProjName": "my-project"} expected_study = {"StudyID": "1", "StudyDescription": "Test simulation", "StudyLocDecDeg": "40.5, -75.9"} project = waterxml.create_project_dict() study = waterxml.create_study_dict() actual_project = waterxml.fill_dict(waterxml_tree = fixture["xml_tree1"], data_dict = project, element = "Project", keys = project.keys()) actual_study = waterxml.fill_dict(waterxml_tree = fixture["xml_tree1"], data_dict = study, element = "Study", keys = study.keys()) nose.tools.assert_equals(actual_project["ProjID"], expected_project["ProjID"]) nose.tools.assert_equals(actual_project["UserName"], expected_project["UserName"]) nose.tools.assert_equals(actual_project["DateCreated"], expected_project["DateCreated"]) nose.tools.assert_equals(actual_project["ProjName"], expected_project["ProjName"]) nose.tools.assert_equals(actual_study["StudyID"], expected_study["StudyID"]) nose.tools.assert_equals(actual_study["StudyDescription"], expected_study["StudyDescription"]) nose.tools.assert_equals(actual_study["StudyLocDecDeg"], expected_study["StudyLocDecDeg"])
def test_fill_dict(): expected_project = { "ProjID": "1", "UserName": "******", "DateCreated": "2014-04-22T10:00:00.0000-00:00", "ProjName": "my-project" } expected_study = { "StudyID": "1", "StudyDescription": "Test simulation", "StudyLocDecDeg": "40.5, -75.9" } project = waterxml.create_project_dict() study = waterxml.create_study_dict() actual_project = waterxml.fill_dict(waterxml_tree=fixture["xml_tree1"], data_dict=project, element="Project", keys=project.keys()) actual_study = waterxml.fill_dict(waterxml_tree=fixture["xml_tree1"], data_dict=study, element="Study", keys=study.keys()) nose.tools.assert_equals(actual_project["ProjID"], expected_project["ProjID"]) nose.tools.assert_equals(actual_project["UserName"], expected_project["UserName"]) nose.tools.assert_equals(actual_project["DateCreated"], expected_project["DateCreated"]) nose.tools.assert_equals(actual_project["ProjName"], expected_project["ProjName"]) nose.tools.assert_equals(actual_study["StudyID"], expected_study["StudyID"]) nose.tools.assert_equals(actual_study["StudyDescription"], expected_study["StudyDescription"]) nose.tools.assert_equals(actual_study["StudyLocDecDeg"], expected_study["StudyLocDecDeg"])