|
1 |
| -from django.test import TestCase |
2 |
| - |
3 | 1 | from feincms3.embedding import embed
|
4 | 2 |
|
5 | 3 |
|
6 |
| -class EmbeddingTest(TestCase): |
7 |
| - def test_no_handlers(self): |
8 |
| - """Embed video without handlers""" |
9 |
| - self.assertEqual(embed("stuff"), None) |
| 4 | +def test_no_handlers(): |
| 5 | + """Embed video without handlers""" |
| 6 | + assert embed("stuff") is None |
| 7 | + |
10 | 8 |
|
11 |
| - def test_youtube(self): |
12 |
| - """YouTube video embedding works""" |
13 |
| - self.assertEqual( |
14 |
| - embed("https://www.youtube.com/watch?v=dQw4w9WgXcQ"), |
15 |
| - """\ |
| 9 | +def test_youtube(): |
| 10 | + """YouTube video embedding works""" |
| 11 | + assert ( |
| 12 | + embed("https://www.youtube.com/watch?v=dQw4w9WgXcQ") |
| 13 | + == """\ |
16 | 14 | <div class="responsive-embed widescreen youtube"><iframe \
|
17 | 15 | src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0" frameborder="0" \
|
18 |
| -allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""", |
19 |
| - ) |
| 16 | +allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""" |
| 17 | + ) |
20 | 18 |
|
21 |
| - self.assertEqual( |
22 |
| - embed("https://youtu.be/y7-s5ZvC_2A"), |
23 |
| - """\ |
| 19 | + assert ( |
| 20 | + embed("https://youtu.be/y7-s5ZvC_2A") |
| 21 | + == """\ |
24 | 22 | <div class="responsive-embed widescreen youtube"><iframe \
|
25 | 23 | src="https://www.youtube.com/embed/y7-s5ZvC_2A?rel=0" frameborder="0" \
|
26 |
| -allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""", |
27 |
| - ) |
28 |
| - |
29 |
| - self.assertTrue( |
30 |
| - embed("https://www.youtube.com/watch?v=4zGnNmncJWg&feature=emb_title") |
31 |
| - ) |
32 |
| - self.assertTrue( |
33 |
| - embed( |
34 |
| - "https://www.youtube.com/watch?v=DYu_bGbZiiQ&list=RDJMOOG7rWTPg&index=7" |
35 |
| - ) |
36 |
| - ) |
37 |
| - self.assertTrue(embed("https://www.youtube.com/watch/ZumRshfKdtM")) |
38 |
| - self.assertTrue(embed("https://www.youtube.com/shorts/ZumRshfKdtM")) |
39 |
| - |
40 |
| - self.assertEqual( |
41 |
| - embed("https://www.youtube.com/live/ljSZ0xrJjCs"), |
42 |
| - """\ |
43 |
| -<div class="responsive-embed widescreen youtube"><iframe src="https://www.youtube.com/embed/ljSZ0xrJjCs?rel=0" frameborder="0" allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""", |
44 |
| - ) |
45 |
| - |
46 |
| - def test_vimeo(self): |
47 |
| - """Vimeo video embedding works""" |
48 |
| - self.assertEqual( |
49 |
| - embed("https://vimeo.com/455728498"), |
50 |
| - """\ |
| 24 | +allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""" |
| 25 | + ) |
| 26 | + |
| 27 | + assert embed("https://www.youtube.com/watch?v=4zGnNmncJWg&feature=emb_title") |
| 28 | + assert embed( |
| 29 | + "https://www.youtube.com/watch?v=DYu_bGbZiiQ&list=RDJMOOG7rWTPg&index=7" |
| 30 | + ) |
| 31 | + assert embed("https://www.youtube.com/watch/ZumRshfKdtM") |
| 32 | + assert embed("https://www.youtube.com/shorts/ZumRshfKdtM") |
| 33 | + |
| 34 | + assert ( |
| 35 | + embed("https://www.youtube.com/live/ljSZ0xrJjCs") |
| 36 | + == """\ |
| 37 | +<div class="responsive-embed widescreen youtube"><iframe src="https://www.youtube.com/embed/ljSZ0xrJjCs?rel=0" frameborder="0" allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""" |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +def test_vimeo(): |
| 42 | + """Vimeo video embedding works""" |
| 43 | + assert ( |
| 44 | + embed("https://vimeo.com/455728498") |
| 45 | + == """\ |
51 | 46 | <div class="responsive-embed widescreen vimeo"><iframe \
|
52 | 47 | src="https://player.vimeo.com/video/455728498" frameborder="0" \
|
53 |
| -allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""", |
54 |
| - ) |
| 48 | +allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""" |
| 49 | + ) |
55 | 50 |
|
56 |
| - self.assertTrue(embed("https://player.vimeo.com/video/417955670")) |
| 51 | + assert embed("https://player.vimeo.com/video/417955670") |
57 | 52 |
|
58 |
| - self.assertEqual( |
59 |
| - embed("https://vimeo.com/12345678/3213124324"), |
60 |
| - """\ |
| 53 | + assert ( |
| 54 | + embed("https://vimeo.com/12345678/3213124324") |
| 55 | + == """\ |
61 | 56 | <div class="responsive-embed widescreen vimeo"><iframe \
|
62 | 57 | src="https://player.vimeo.com/video/12345678" frameborder="0" \
|
63 |
| -allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""", |
64 |
| - ) |
| 58 | +allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""" |
| 59 | + ) |
0 commit comments