How to use test0Pass method in green

Best Python code snippet using green

turtleurbanclasses_tests.py

Source:turtleurbanclasses_tests.py Github

copy

Full Screen

...875 },876}877class ObjectCreateTest(unittest.TestCase):878 "testing HydroObject creation"879 def test0Pass(self):880 "testing creation from SUF-HYD data"881 def test1CreationGeslotenLeiding(self):882 "- just if GeslotenLeiding is created"883 repr = sampleStrings["SUFHYD"][GeslotenLeiding][0]884 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)885 self.assertEqual(obj.__class__, GeslotenLeiding)886 def test1CreationKnoop(self):887 "- just if Knoop is created"888 repr = sampleStrings["SUFHYD"][Knoop][0]889 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)890 self.assertEqual(obj.__class__, Knoop)891 repr = sampleStrings["SUFHYD"][Knoop][1]892 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)893 self.assertEqual(obj.__class__, Knoop)894 def test1CreationGemaal(self):895 "- just if Gemaal is created"896 repr = sampleStrings["SUFHYD"][Gemaal][0]897 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)898 assert isinstance(obj, Gemaal)899 def test1CreationGemaal1(self):900 "- just if Gemaal (Knoop) is created"901 repr = sampleStrings["SUFHYD"][Gemaal][1]902 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)903 self.assertEqual(obj.__class__, Gemaal_Knoop)904 def test1CreationGemaal2(self):905 "- just if Gemaal (Tak) is created"906 repr = sampleStrings["SUFHYD"][Gemaal][0]907 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)908 self.assertEqual(obj.__class__, Gemaal_Tak)909 def test1CreationOverstort1(self):910 "- just if Overstort (Knoop) is created"911 repr = sampleStrings["SUFHYD"][Overstort][0]912 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)913 self.assertEqual(obj.__class__, Overstort_Knoop)914 def test1CreationOverstort1a(self):915 "- Overstort (Knoop) is created from object that incorrectly gives gb2 and no kn2"916 repr = sampleStrings["SUFHYD"][Overstort][10]917 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)918 self.assertEqual(obj.__class__, Overstort_Knoop)919 def test1CreationOverstort2(self):920 "- just if Overstort (Tak) is created"921 repr = sampleStrings["SUFHYD"][Overstort][1]922 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)923 self.assertEqual(obj.__class__, Overstort_Tak)924 def test1CreationUitlaatMetKeerklep1(self):925 "- just if UitlaatMetKeerklep (Knoop) is created"926 repr = sampleStrings["SUFHYD"][UitlaatMetKeerklep][0]927 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)928 self.assertEqual(obj.__class__, UitlaatMetKeerklep_Knoop)929 def test1CreationUitlaatMetKeerklep2(self):930 "- just if UitlaatMetKeerklep (Tak) is created"931 repr = sampleStrings["SUFHYD"][UitlaatMetKeerklep][1]932 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)933 self.assertEqual(obj.__class__, UitlaatMetKeerklep_Tak)934 def test1CreationAfvoerendOppervlak1(self):935 "- just if AfvoerendOppervlak (Knoop) is created"936 repr = sampleStrings["SUFHYD"][AfvoerendOppervlak][0]937 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)938 self.assertEqual(obj.__class__, AfvoerendOppervlak_Knoop)939 def test1CreationAfvoerendOppervlak2(self):940 "- just if AfvoerendOppervlak (Tak) is created"941 repr = sampleStrings["SUFHYD"][AfvoerendOppervlak][1]942 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)943 self.assertEqual(obj.__class__, AfvoerendOppervlak_Tak)944 def test1CreationZ(self):945 "- batch testing creation"946 for i in sum(list(sampleStrings["SUFHYD"].values()), []):947 HydroObjectFactory.hydroObjectFromSUFHYD(i)948 def test2Fields(self):949 "- if Knoop got the string fields"950 repr = sampleStrings["SUFHYD"][Knoop][3]951 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)952 self.assertEqual(obj.fields["ide_knp"], "0000NUENEN")953 self.assertEqual(obj.fields["ide_geb"], " ")954 self.assertEqual(obj.fields["knp_xco"], " 166060600")955 def test3Attribs(self):956 "- if Knoop has the correct attributes"957 repr = sampleStrings["SUFHYD"][Knoop][3]958 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)959 self.assertEqual(obj.ide_knp, "0000NUENEN")960 self.assertEqual(obj.ide_geb, "")961 self.assertEqual(obj.knp_xco, 166060600)962 def test40AttribKnoop_afv_hel(self):963 "- if Knoop has integer afv_hel"964 repr = sampleStrings["SUFHYD"][Knoop][11]965 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)966 self.assertEqual(obj.afv_hel, 0)967 def test42AttribGeslotenLeiding_afv_hel(self):968 "- if GeslotenLeiding has float afv_hel"969 repr = sampleStrings["SUFHYD"][GeslotenLeiding][10]970 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)971 self.assertEqual(obj.afv_hel, 0.0)972 def test43AttribGeslotenLeiding_unknown(self):973 "- if GeslotenLeiding hellevoetsluis"974 repr = sampleStrings["SUFHYD"][GeslotenLeiding][11]975 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)976 self.assertEqual(obj.afv_hel, 0.0)977 def test44AttribGeslotenLeiding_space_in_id(self):978 "- if GeslotenLeiding accepts space in id"979 repr = sampleStrings["SUFHYD"][GeslotenLeiding][12]980 obj = HydroObjectFactory.hydroObjectFromSUFHYD(repr)981 self.assertEqual(obj.ide_kn2, "000 GLDRP")982 def test5ReproduceAfvoerendOppervlak(self):983 "- if AfvoerendOppervlak knows how to represent itself"984 input = sampleStrings["SUFHYD"][AfvoerendOppervlak][0]985 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)986 output = obj.toSufHyd()987 self.assertEqual(input.strip(), output.strip())988 def test5ReproduceBergendOppervlakKnoop(self):989 "- if BergendOppervlak knows how to represent itself"990 input = sampleStrings["SUFHYD"][BergendOppervlakKnoop][0]991 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)992 output = obj.toSufHyd()993 self.assertEqual(input.strip(), output.strip())994 def test5ReproduceDoorlaat(self):995 "- if Doorlaat knows how to represent itself"996 input = sampleStrings["SUFHYD"][Doorlaat][0]997 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)998 output = obj.toSufHyd()999 self.assertEqual(input.strip(), output.strip())1000 def test5ReproduceGemaal(self):1001 "- if Gemaal knows how to represent itself"1002 input = sampleStrings["SUFHYD"][Gemaal][0]1003 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1004 output = obj.toSufHyd()1005 self.assertEqual(input.strip(), output.strip())1006 def test5ReproduceGemaalMultiPump(self):1007 "- if Gemaal (more than one pump) knows how to represent itself"1008 for input in sampleStrings["SUFHYD"][Gemaal]:1009 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1010 output = obj.toSufHyd()1011 self.assertEqual(input.strip(), output.strip())1012 def test5ReproduceGeslotenLeiding(self):1013 "- if GeslotenLeiding knows how to represent itself"1014 input = sampleStrings["SUFHYD"][GeslotenLeiding][4]1015 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1016 output = obj.toSufHyd()1017 output = output.strip()1018 input = input.strip()1019 self.assertEqual(input.strip(), output.strip())1020 def test5ReproduceKnoop(self):1021 "- if Knoop knows how to represent itself"1022 input = sampleStrings["SUFHYD"][Knoop][2]1023 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1024 output = obj.toSufHyd()1025 self.assertEqual(input.strip(), output.strip())1026 def test5ReproduceOverstort(self):1027 "- if Overstort (Knoop) knows how to represent itself"1028 input = sampleStrings["SUFHYD"][Overstort][0]1029 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1030 output = obj.toSufHyd()1031 self.assertEqual(input.strip(), output.strip())1032 def test5ReproduceOverstort1(self):1033 "- if Overstort (Tak) knows how to represent itself"1034 input = sampleStrings["SUFHYD"][Overstort][1]1035 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1036 output = obj.toSufHyd()1037 self.assertEqual(input.strip(), output.strip())1038 def test5ReproduceUitlaatMetKeerklep(self):1039 "- if UitlaatMetKeerklep (Knoop) knows how to represent itself"1040 input = sampleStrings["SUFHYD"][UitlaatMetKeerklep][0]1041 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1042 output = obj.toSufHyd()1043 self.assertEqual(input.strip(), output.strip())1044 def test5ReproduceUitlaatMetKeerklep1(self):1045 "- if UitlaatMetKeerklep (Tak) knows how to represent itself"1046 input = sampleStrings["SUFHYD"][UitlaatMetKeerklep][1]1047 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1048 output = obj.toSufHyd()1049 self.assertEqual(input.strip(), output.strip())1050 def test5ReproduceOverstortShort(self):1051 "- if the last field is recognized"1052 input = sampleStrings["SUFHYD"][Overstort][0].strip()1053 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1054 output = obj.toSufHyd()1055 self.assertEqual(input.strip(), output.strip())1056 def test5ReproduceDWAVerloopPerInwoner(self):1057 "- if DWAVerloopPerInwoner knows how to represent itself"1058 for input in sampleStrings["SUFHYD"][DWAVerloopPerInwoner]:1059 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1060 output = obj.toSufHyd()1061 self.assertEqual(input.strip(), output.strip())1062 def test4CreatingDummyEnd(self):1063 "- if we can create an End object without having any string to parse"1064 obj = End()1065 self.assertEqual(obj.__class__, End)1066 self.assertEqual(obj.toSufHyd().strip(), "*END")1067 def test4CreationAlgemeneInformatie1(self):1068 "- only one AlgemeneInformatie is created from multiple lines"1069 repr = "\n".join(sampleStrings["SUFHYD"][AlgemeneInformatie])1070 objlist = HydroObjectFactory.hydroObjectListFromSUFHYD(repr)1071 self.assertEqual(len(objlist), 1)1072 self.assertEqual(objlist[0].__class__, AlgemeneInformatie)1073 def test4CreationAlgemeneInformatie2(self):1074 "- the single AlgemeneInformatie contains all information"1075 # just get the object that we know we can create!1076 repr = "\n".join(1077 [i.strip() for i in sampleStrings["SUFHYD"][AlgemeneInformatie]]1078 )1079 obj = HydroObjectFactory.hydroObjectListFromSUFHYD(repr)[0]1080 [k for k in AlgemeneInformatie.field_names if isSufHydKey(k)]1081 self.assertEqual(obj.alg_dat, "20050315")1082 self.assertEqual(obj.alg_opd, "")1083 self.assertEqual(obj.alg_uit, "")1084 self.assertEqual(obj.alg_oms, "dwa")1085 self.assertEqual(obj.alg_ove, r"exported from Sobek D:\Sobek\EHOVEN.lit\3")1086 def test61UnreadableCausesException0(self):1087 "- unknown sufhyd line causes RuntimeError"1088 input = "this is not a sufhyd line"1089 self.assertRaises(RuntimeError, HydroObjectFactory.hydroObjectFromSUFHYD, input)1090 def test62UnreadableCausesException1(self):1091 "- GeslotenLeiding can't be generated from *KNP"1092 input = sampleStrings["SUFHYD"][Knoop][0]1093 self.assertRaises(RuntimeError, GeslotenLeiding, "SUFHYD", input)1094 def test63UnreadableCausesException2(self):1095 "- wrong sufhyd line causes RuntimeError"1096 handler.flush()1097 input = "*OVS J1907W 3 17.8 0.941 16..45"1098 self.assertRaises(RuntimeError, HydroObjectFactory.hydroObjectFromSUFHYD, input)1099 self.assertEqual(len(handler.content), 1)1100 def test63UnreadableCausesException4(self):1101 "- wrong sufhyd line causes RuntimeError"1102 handler.flush()1103 input = "*KNP 8484560 -1.00 100 0.008 01 "1104 self.assertRaises(RuntimeError, HydroObjectFactory.hydroObjectFromSUFHYD, input)1105 self.assertEqual(len(handler.content), 1)1106 def test64NonBlockingUnreadable(self):1107 "- do not stop when seeing an unreadable line"1108 handler.flush()1109 input = []1110 input.extend(sampleStrings["SUFHYD"][Knoop])1111 input.append("*OVS J1907W 3 17.8 0.941 16..45")1112 input.extend(sampleStrings["SUFHYD"][GeslotenLeiding])1113 input.append("*END")1114 input_str = "\n".join(input)1115 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(input_str)1116 self.assertEqual(1117 len(obj_list),1118 len(sampleStrings["SUFHYD"][Knoop])1119 + len(sampleStrings["SUFHYD"][GeslotenLeiding])1120 + 1,1121 )1122 self.assertEqual(len(handler.content), 3)1123 def test650ReportingUnreadable(self):1124 "- the unreadable line is reported (WARNING), no class so no split"1125 handler.flush()1126 input = []1127 input.extend(sampleStrings["SUFHYD"][Knoop])1128 input.append(" *OVS J1907W 3 17.8 0.941 16..45")1129 input.extend(sampleStrings["SUFHYD"][GeslotenLeiding])1130 input.append("*END")1131 input_str = "\n".join(input)1132 handler.flush()1133 HydroObjectFactory.hydroObjectListFromSUFHYD(input_str)1134 expect = " *OVS J1907W 3 17.8 0.941 16..45"1135 records = [i for i in handler.content if i.find(expect) != -1]1136 self.assertEqual(len(records), 1)1137 self.assertEqual(records[0].split("|")[1], "WARNING")1138 def test651ReportingUnreadable(self):1139 "- the unreadable line is reported (WARNING), split according to most likely class"1140 input = []1141 input.extend(sampleStrings["SUFHYD"][Knoop])1142 input.append("*OVS J1907W 3 17.8 0.941 16..45")1143 input.extend(sampleStrings["SUFHYD"][GeslotenLeiding])1144 input.append("*END")1145 input_str = "\n".join(input)1146 handler.flush()1147 HydroObjectFactory.hydroObjectListFromSUFHYD(input_str)1148 expect = "|*OVS| | J1907W| | | | 3 | 17.8 | 0.941| 1|6.|.45||||||"1149 records = [i for i in handler.content if i.find(expect) != -1]1150 self.assertEqual(len(records), 1)1151 self.assertEqual(records[0].split("|")[1], "WARNING")1152 def test66ReportingUnreadableGeometry(self):1153 "- if geometry makes use of non existent nodes it is logged as WARNING"1154 input = []1155 input.extend(sampleStrings["SUFHYD"][Knoop][:-6])1156 input.extend(sampleStrings["SUFHYD"][GeslotenLeiding])1157 input.append("*END")1158 input_str = "\n".join(input)1159 handler.flush()1160 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(input_str)1161 HydroObjectFactory.propagateGeometries(obj_list)1162 expect = "*LEI:0000K16618->0000K16620"1163 records = [i for i in handler.content if i.find(expect) != -1]1164 self.assertEqual(len(records), 1)1165 self.assertEqual(records[0].split("|")[1], "WARNING")1166 def test70ObjectsHaveStartPointId(self):1167 "- all objects have a get_start_pointId"1168 for thisClass in list(sampleStrings["SUFHYD"].keys()):1169 obj = HydroObjectFactory.hydroObjectFromSUFHYD(1170 sampleStrings["SUFHYD"][thisClass][0]1171 )1172 obj.get_start_pointId()1173 def test71VertexNameDoesNotGetLeadingZeroes(self):1174 "- a vertex name shorter than 10 is NOT padded with leading zeroes - ticket 151"1175 input = "*OVS BYPASS2 33 3 0.941 1 10.40"1176 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1177 self.assertEqual(obj.get_start_pointId(), "BYPASS2")1178 def test72VertexNameCanBeJustAreaCode(self):1179 "- a destination vertex name with just area code is empty - ticket 150"1180 input = "*OVS 00 BYPASS2 00 33 3 0.941 1 10.40"1181 obj = HydroObjectFactory.hydroObjectFromSUFHYD(input)1182 self.assertEqual(obj.get_start_pointId(), "00_BYPASS2")1183 self.assertEqual(obj.get_end_pointId(), "")1184 self.assertEqual(obj.__class__, Overstort_Knoop)1185class FileReadTest(unittest.TestCase):1186 "testing reading sequence of HydroObject objects"1187 input = """\1188*KNP 0000NOORD1 164371100 388463700 19.14 0 100 100.000 00 5.001189*KNP 0000NOORD2 163804600 385965500 19.14 0 100 100.000 00 2.001190*KNP 000RWZINRD 162964800 385605500 15.41 0 100 1.000 00 8.001191*KNP 0000NUENEN 166060600 386760700 19.14 0 100 36.742 00 6.141192*KNP 000NUENEN2 166065600 386760700 19.14 0 100 4.000 00 6.141193*LEI 0000NOORD1 0000NOORD2 5.00 2.002561.63 1.500 2.000 021194*LEI 0000NOORD2 000RWZINRD 2.00 1.00 999.00 1.500 2.000 021195*LEI 0000NUENEN 000NUENEN2 6.14 6.14 50.00 1.000 041196*END1197"""1198 def test0Pass(self):1199 "testing reading/writing sequence of HydroObject objects"1200 def test1ReadingSequence(self):1201 "- if a sequence of lines is read into equal sized sequence of objects"1202 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(self.input)1203 self.assertEqual(len(obj_list), 9)1204 def test2ReadingSequence(self):1205 "- if a sequence of lines is read into corresponding sequence of objects"1206 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(self.input)1207 obj_types = [1208 Knoop,1209 Knoop,1210 Knoop,1211 Knoop,1212 Knoop,1213 GeslotenLeiding,1214 GeslotenLeiding,1215 GeslotenLeiding,1216 End,1217 ]1218 for i, j in map(None, obj_list, obj_types):1219 self.assertEqual(i.__class__, j)1220 def test3ReproducingSequence(self):1221 "- reading a sequence of lines and comparing the representation"1222 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(self.input)1223 obj_str_list = re.split("[\n\r]+", self.input)1224 for i, j in map(None, obj_list, obj_str_list):1225 if i:1226 output = i.toSufHyd()1227 else:1228 output = ""1229 self.assertEqual(output.strip(), j.strip())1230class ObjectCreateFromGMLTest(unittest.TestCase):1231 "testing HydroObject creation"1232 geslotenLeiding = sampleStrings["GML"][GeslotenLeiding][0]1233 def test0Pass(self):1234 "testing creation from GML data"1235 pass1236 def test1CreateKnoop(self):1237 "- can I choose the correct class (Knoop)?"1238 obj = HydroObjectFactory.hydroObjectFromGML(sampleStrings["GML"][Knoop][0])1239 self.assertEqual(obj.__class__, Knoop)1240 def test1CreateGeslotenLeiding(self):1241 "- can I choose the correct class (GeslotenLeiding)?"1242 obj = HydroObjectFactory.hydroObjectFromGML(1243 sampleStrings["GML"][GeslotenLeiding][0]1244 )1245 self.assertEqual(obj.__class__, GeslotenLeiding)1246 def test2CreateGeslotenLeiding(self):1247 "- are GeslotenLeiding string fields read correctly?"1248 obj = HydroObjectFactory.hydroObjectFromGML(1249 sampleStrings["GML"][GeslotenLeiding][0]1250 )1251 self.assertEqual(obj.fields["bob_kn2"], "2.00")1252 def test2CreateKnoop(self):1253 "- are Knoop string fields read correctly?"1254 obj = HydroObjectFactory.hydroObjectFromGML(sampleStrings["GML"][Knoop][0])1255 self.assertEqual(obj.fields["knp_xco"], "164371.100")1256 def test3CreateGeslotenLeiding(self):1257 "- are GeslotenLeiding attributes read correctly?"1258 obj = HydroObjectFactory.hydroObjectFromGML(1259 sampleStrings["GML"][GeslotenLeiding][0]1260 )1261 self.assertEqual(obj.bob_kn2, 2.00)1262 def test3CreateKnoop(self):1263 "- are Knoop attributes read correctly?"1264 obj = HydroObjectFactory.hydroObjectFromGML(sampleStrings["GML"][Knoop][0])1265 self.assertEqual(obj.knp_xco, 164371100)1266 def test4CreateKnoopIntegerCoordinate(self):1267 "- are Knoop coordinates read correctly even if integer valued?"1268 obj = HydroObjectFactory.hydroObjectFromGML(sampleStrings["GML"][Knoop][3])1269 self.assertEqual(obj.knp_yco, 490003000)1270 def test4CreateTakGemaal(self):1271 "- does Gemaal_Tak know of its end point?"1272 obj = HydroObjectFactory.hydroObjectFromGML(sampleStrings["GML"][Gemaal][1])1273 self.assertEqual(obj.__class__, Gemaal_Tak)1274 self.assertEqual(obj.ide_kn2, "0000DWA_72")1275 def test4CreateTakAfvoerendOppervlak(self):1276 "- does AfvoerendOppervlak_Tak know of its end point?"1277 obj = HydroObjectFactory.hydroObjectFromGML(1278 sampleStrings["GML"][AfvoerendOppervlak][1]1279 )1280 self.assertEqual(obj.__class__, AfvoerendOppervlak_Tak)1281 self.assertEqual(obj.ide_kn2, "0000DWA_56")1282class GMLFileReadTest(unittest.TestCase):1283 "testing HydroObject creation"1284 def test0Pass(self):1285 "testing creation from GML file"1286 pass1287 def test1ReadingSequence(self):1288 "- do we get a correctly sized sequence?"1289 handler.flush()1290 handler.setLevel(logging.ERROR)1291 fakeFile = "\n".join(sum(list(sampleStrings["GML"].values()), []) * 4)1292 obj_list = HydroObjectFactory.hydroObjectListFromGML(fakeFile)1293 self.assertEqual(1294 len(obj_list), len(sum(list(sampleStrings["GML"].values()), [])) * 41295 )1296 self.assertEqual(handler.content, [])1297 handler.setLevel(logging.DEBUG)1298 def test2ReadingSequence(self):1299 "- do we get a sequence with the correct types?"1300 fakeFile = (1301 sampleStrings["GML"][Knoop][0] + sampleStrings["GML"][GeslotenLeiding][0]1302 ) * 41303 expected = [Knoop, GeslotenLeiding] * 41304 obj_list = HydroObjectFactory.hydroObjectListFromGML(fakeFile)1305 for i, j in map(None, obj_list, expected):1306 self.assertEqual(i.__class__, j)1307 def test3inconsistentInput(self):1308 "- do we notice inconsistent ide_rec/fme:<type>?"1309 fakeFile = """\1310<gml:featureMember>1311<fme:AfvoerendOppervlak_Tak gml:id="id6d8bd245-d54f-4d62-906c-24e8515b157b">1312<fme:OBJECTID_1>1</fme:OBJECTID_1>1313<fme:FID_leid_s>38</fme:FID_leid_s>1314<fme:fid_>0</fme:fid_>1315<fme:objectid>0</fme:objectid>1316<fme:opmerking> </fme:opmerking>1317<fme:ide_rec>*LEI</fme:ide_rec>1318</fme:AfvoerendOppervlak_Tak>1319</gml:featureMember>1320"""1321 handler.flush()1322 HydroObjectFactory.hydroObjectListFromGML(fakeFile)1323 # self.assertEqual(obj_list, [])1324 expect = "does not match declared fme:"1325 records = [i for i in handler.content if i.find(expect) != -1]1326 self.assertEqual(len(records), 1)1327 self.assertEqual(records[0].split("|")[1], "WARNING")1328class GMLElementFromDescription(unittest.TestCase):1329 def test0Pass(self):1330 "testing generation of element describing a field"1331 pass1332 def test1AtomicTypeInt(self):1333 '- xsd: type is int, expect "integer"'1334 e = GmlElement("aan_inw", int, 4)1335 self.assertEqual(1336 e.toxsd(), '<element name="aan_inw" minOccurs="0" type="integer"/>'1337 )1338 pass1339 def test1AtomicTypeFloat(self):1340 '- xsd: type is float, expect "double"'1341 e = GmlElement("lei_len", float, 7, 2)1342 self.assertEqual(1343 e.toxsd(), '<element name="lei_len" minOccurs="0" type="double"/>'1344 )1345 pass1346 def test1SimpleTypeString(self):1347 "- xsd: type is str, expect simpleElement plus restriction..."1348 e = GmlElement("lei_typ", str, 2)1349 self.assertEqual(1350 e.toxsd(),1351 """\1352<element name="lei_typ" minOccurs="0">1353<simpleType>1354<restriction base="string">1355<maxLength value="2"/>1356</restriction>1357</simpleType>1358</element>""",1359 )1360 pass1361 def test2AtomicTypeInt(self):1362 "- checking xml representation of integer value"1363 e = GmlElement("aan_inw", int, 4)1364 e.setValue(25)1365 self.assertEqual(e.toxml(), "<fme:aan_inw>25</fme:aan_inw>")1366 pass1367 def test2AtomicTypeFloat(self):1368 "- checking xml representation of floating value"1369 e = GmlElement("lei_len", float, 7, 2)1370 e.setValue(40.02)1371 self.assertEqual(e.toxml(), "<fme:lei_len>40.02</fme:lei_len>")1372 pass1373 def test2AtomicTypeFloatRounded(self):1374 "- checking xml representation of floating value - with rounding error"1375 e = GmlElement("lei_len", float, 7, 2)1376 e.setValue(40.0199996)1377 self.assertEqual(e.toxml(), "<fme:lei_len>40.02</fme:lei_len>")1378 pass1379 def test2SimpleTypeString(self):1380 "- checking xml representation of string value"1381 e = GmlElement("lei_typ", str, 2)1382 e.setValue("RW")1383 self.assertEqual(e.toxml(), "<fme:lei_typ>RW</fme:lei_typ>")1384 pass1385 def test3KnoopXsdRepresentation(self):1386 """- complete xsd representation of Knoop"""1387 obj = Knoop(1388 "SUFHYD",1389 "*KNP 0000NOORD1 164371100 388463700 19.14 0 100 100.000 00 5.00 ",1390 )1391 self.assertEqual(obj.toxsd(), sampleStrings["XSD"][Knoop])1392 pass1393 def test3GeslotenLeidingXsdRepresentation(self):1394 """- complete xsd representation of GeslotenLeiding"""1395 obj = GeslotenLeiding(1396 "SUFHYD",1397 "*LEI 0000NOORD1 0000NOORD2 5.00 2.002561.63 1.500 2.000 02 ",1398 )1399 self.assertEqual(obj.toxsd(), sampleStrings["XSD"][GeslotenLeiding])1400 pass1401class GMLTextProductionSingleObjectTest(unittest.TestCase):1402 sufhyd_knoop = sampleStrings["SUFHYD"][Knoop][0]1403 gml_knoop = sampleStrings["GML"][Knoop][1]1404 def test0Pass(self):1405 "testing production of gml data"1406 pass1407 def test1AlmostEmptyKnoop(self):1408 "- a 'Knoop' object with very few attributes"1409 obj = Knoop("SUFHYD", sampleStrings["SUFHYD"][Knoop][0])1410 self.assertEqual(obj.toxml(), sampleStrings["GML"][Knoop][0] % obj.__dict__)1411 def test1AlmostEmptyGeslotenLeiding(self):1412 "- a 'GeslotenLeiding' object with very few attributes"1413 obj = GeslotenLeiding("SUFHYD", sampleStrings["SUFHYD"][GeslotenLeiding][0])1414 self.assertEqual(1415 obj.toxml(), sampleStrings["GML"][GeslotenLeiding][0] % obj.__dict__1416 )1417 def test2DWAVerloopPerInwoner(self):1418 "- a 'DWAVerloopPerInwoner' object with all attributes"1419 obj = DWAVerloopPerInwoner(1420 "SUFHYD", sampleStrings["SUFHYD"][DWAVerloopPerInwoner][0]1421 )1422 self.assertEqual(1423 obj.toxml(), sampleStrings["GML"][DWAVerloopPerInwoner][0] % obj.__dict__1424 )1425 def test2GemaalVertexHasGeoproperties(self):1426 "- a 'Gemaal' (Vertex) has Vertex geoproperties"1427 HydroObjectFactory.hydroObjectListFromSUFHYD(sampleStrings["SUFHYD"][Gemaal][0])1428 # obj.1429class GMLConsistentNetworkTest(unittest.TestCase):1430 elem_list = (1431 sampleStrings["SUFHYD"][Knoop] + sampleStrings["SUFHYD"][GeslotenLeiding]1432 )1433 fake_file = "\n".join(elem_list)1434 def test0Pass(self):1435 "production of gml data for a network with Knoop and GeslotenLeidingen"1436 pass1437 def test1ReadingTheData(self):1438 "- is the data read at all?"1439 obj_list = HydroObjectFactory.hydroObjectListFromSUFHYD(self.fake_file)1440 self.assertEqual(len(obj_list), len(self.elem_list))1441 pass1442 def test2DoEdgeElementsKnowAboutTheirExtremePoints(self):1443 "- do edge elements know about their extreme points?"1444 obj = HydroObjectFactory.hydroObjectFromSUFHYD(1445 sampleStrings["SUFHYD"][GeslotenLeiding][0]1446 )1447 self.assertEqual(obj.__class__, GeslotenLeiding)1448 self.assertEqual(obj.get_start_pointId(), "0000NOORD1")...

Full Screen

Full Screen

examples.py

Source:examples.py Github

copy

Full Screen

2import sys3import unittest4doctest_modules = ["green.examples"]5class TestStates(unittest.TestCase):6 def test0Pass(self):7 """8 This test will print output to stdout, and then pass.9 """10 print("Sunshine and daisies")11 def test1Fail(self):12 """13 This test will print output to stderr, and then fail an assertion.14 """15 sys.stderr.write("Doom and gloom.\n")16 self.assertTrue(False)17 def test2Error(self):18 """19 An Exception will be raised (and not caught) while running this test.20 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful