'):body.index('
')]
self.assertNotIn("map__message", frame)
# the words say what is shown, and never call the track a line
self.assertIn("Only the start and the end are shown. There is no track for this trail here, "
"and the site does not guess one.", body)
self.assertNotIn("dotted", body)
caption = body[body.index("")]
self.assertNotIn("line", caption.lower())
def test_no_track_element_for_a_trail_with_no_track(self):
for rec in (sketch_rec(), sketch_rec(end=None, shape="loop")):
self.assertEqual(build.trail_outputs(rec["id"], {}, rec), ["sketch.json"])
self.assertEqual([f["geometry"]["type"] for f in build.termini_features(rec)],
["Point"] * len(hike.termini(rec)))
_t, _d, body, _m = trail.render(rec, GH)
self.assertNotIn("map.json", body)
self.assertNotIn("line.geojson", body)
self.assertNotIn('class="fallback__line', body)
def test_a_loop_with_one_point_shows_one_marker_for_both_ends(self):
_t, _d, body, needs_map = trail.render(sketch_rec(end=None, shape="loop"), GH)
self.assertTrue(needs_map)
self.assertEqual(body.count('class="terminus-item"'), 1)
self.assertIn('data-label="Start and end: Start Town"', body)
self.assertIn("Only the place where it starts and ends is shown.", body)
self.assertIn("A trail is listed without a GPX when no track for it may be passed on.", body)
def test_a_point_to_point_trail_with_one_point_keeps_the_empty_frame(self):
for rec in (sketch_rec(end=None), sketch_rec(start=None)):
_t, _d, body, needs_map = trail.render(rec, GH)
self.assertFalse(needs_map)
self.assertIn("map--empty", body)
self.assertNotIn("sketch.json", body)
self.assertNotIn("terminus-item", body)
self.assertIn("No map is drawn: there is no track for this trail here, and the site does not guess one.",
body)
def test_trail_page_without_a_point_keeps_the_empty_frame(self):
_t, _d, body, needs_map = trail.render(make("plain", "Plain Trail"), GH)
self.assertFalse(needs_map)
self.assertIn("map--empty", body)
self.assertNotIn("sketch.json", body)
self.assertIn("No map is drawn: there is no track for this trail here, and the site does not guess one.", body)
self.assertIn("Nothing drawn", body)
class ScriptAndDocsTest(unittest.TestCase):
def test_script_has_the_dotted_sketch_and_the_sort_state(self):
with open(os.path.join(WEB, "assets", "app.js"), encoding="utf-8") as f:
js = f.read()
for part in ("dash: [0, 2]", "olt-sketch-points", "No GPX here. The dotted line only joins",
"placeTermini", "terminus__label", "map__termini",
"normalizeSortKey", "replaceState", "data-sort-col", "'long': 'length-desc'",
"fallback__ring", "fallback__line--sketch"):
self.assertIn(part, js, part)
def test_data_page_describes_sketches(self):
text = " ".join(what for _, what, _ in docs.BULK_FILES)
self.assertIn("sketch", text.lower())
self.assertIn("not a track", text.lower())
if __name__ == "__main__":
unittest.main()