|
1 | | -import unittest |
| 1 | +import pytest |
2 | 2 |
|
3 | 3 | import tableauserverclient as TSC |
4 | 4 |
|
5 | 5 |
|
6 | | -class SiteModelTests(unittest.TestCase): |
7 | | - def test_invalid_name(self): |
8 | | - self.assertRaises(ValueError, TSC.SiteItem, None, "url") |
9 | | - self.assertRaises(ValueError, TSC.SiteItem, "", "url") |
10 | | - site = TSC.SiteItem("site", "url") |
11 | | - with self.assertRaises(ValueError): |
12 | | - site.name = None |
| 6 | +def test_invalid_name(): |
| 7 | + with pytest.raises(ValueError): |
| 8 | + TSC.SiteItem(None, "url") |
| 9 | + with pytest.raises(ValueError): |
| 10 | + TSC.SiteItem("", "url") |
| 11 | + site = TSC.SiteItem("site", "url") |
| 12 | + with pytest.raises(ValueError): |
| 13 | + site.name = None |
13 | 14 |
|
14 | | - with self.assertRaises(ValueError): |
15 | | - site.name = "" |
| 15 | + with pytest.raises(ValueError): |
| 16 | + site.name = "" |
16 | 17 |
|
17 | | - def test_invalid_admin_mode(self): |
18 | | - site = TSC.SiteItem("site", "url") |
19 | | - with self.assertRaises(ValueError): |
20 | | - site.admin_mode = "Hello" |
21 | 18 |
|
22 | | - def test_invalid_content_url(self): |
23 | | - with self.assertRaises(ValueError): |
24 | | - site = TSC.SiteItem(name="蚵仔煎", content_url="蚵仔煎") |
| 19 | +def test_invalid_admin_mode(): |
| 20 | + site = TSC.SiteItem("site", "url") |
| 21 | + with pytest.raises(ValueError): |
| 22 | + site.admin_mode = "Hello" |
25 | 23 |
|
26 | | - with self.assertRaises(ValueError): |
27 | | - site = TSC.SiteItem(name="蚵仔煎", content_url=None) |
28 | 24 |
|
29 | | - def test_set_valid_content_url(self): |
30 | | - # Default Site |
31 | | - site = TSC.SiteItem(name="Default", content_url="") |
32 | | - self.assertEqual(site.content_url, "") |
| 25 | +def test_invalid_content_url(): |
| 26 | + with pytest.raises(ValueError): |
| 27 | + site = TSC.SiteItem(name="蚵仔煎", content_url="蚵仔煎") |
33 | 28 |
|
34 | | - # Unicode Name and ascii content_url |
35 | | - site = TSC.SiteItem(name="蚵仔煎", content_url="omlette") |
36 | | - self.assertEqual(site.content_url, "omlette") |
| 29 | + with pytest.raises(ValueError): |
| 30 | + site = TSC.SiteItem(name="蚵仔煎", content_url=None) |
37 | 31 |
|
38 | | - def test_invalid_disable_subscriptions(self): |
39 | | - site = TSC.SiteItem("site", "url") |
40 | | - with self.assertRaises(ValueError): |
41 | | - site.disable_subscriptions = "Hello" |
42 | 32 |
|
43 | | - with self.assertRaises(ValueError): |
44 | | - site.disable_subscriptions = None |
| 33 | +def test_set_valid_content_url(): |
| 34 | + # Default Site |
| 35 | + site = TSC.SiteItem(name="Default", content_url="") |
| 36 | + assert site.content_url == "" |
45 | 37 |
|
46 | | - def test_invalid_revision_history_enabled(self): |
47 | | - site = TSC.SiteItem("site", "url") |
48 | | - with self.assertRaises(ValueError): |
49 | | - site.revision_history_enabled = "Hello" |
| 38 | + # Unicode Name and ascii content_url |
| 39 | + site = TSC.SiteItem(name="蚵仔煎", content_url="omlette") |
| 40 | + assert site.content_url == "omlette" |
50 | 41 |
|
51 | | - with self.assertRaises(ValueError): |
52 | | - site.revision_history_enabled = None |
53 | 42 |
|
54 | | - def test_invalid_state(self): |
55 | | - site = TSC.SiteItem("site", "url") |
56 | | - with self.assertRaises(ValueError): |
57 | | - site.state = "Hello" |
| 43 | +def test_invalid_disable_subscriptions(): |
| 44 | + site = TSC.SiteItem("site", "url") |
| 45 | + with pytest.raises(ValueError): |
| 46 | + site.disable_subscriptions = "Hello" |
58 | 47 |
|
59 | | - def test_invalid_subscribe_others_enabled(self): |
60 | | - site = TSC.SiteItem("site", "url") |
61 | | - with self.assertRaises(ValueError): |
62 | | - site.subscribe_others_enabled = "Hello" |
| 48 | + with pytest.raises(ValueError): |
| 49 | + site.disable_subscriptions = None |
63 | 50 |
|
64 | | - with self.assertRaises(ValueError): |
65 | | - site.subscribe_others_enabled = None |
| 51 | + |
| 52 | +def test_invalid_revision_history_enabled(): |
| 53 | + site = TSC.SiteItem("site", "url") |
| 54 | + with pytest.raises(ValueError): |
| 55 | + site.revision_history_enabled = "Hello" |
| 56 | + |
| 57 | + with pytest.raises(ValueError): |
| 58 | + site.revision_history_enabled = None |
| 59 | + |
| 60 | + |
| 61 | +def test_invalid_state(): |
| 62 | + site = TSC.SiteItem("site", "url") |
| 63 | + with pytest.raises(ValueError): |
| 64 | + site.state = "Hello" |
| 65 | + |
| 66 | + |
| 67 | +def test_invalid_subscribe_others_enabled(): |
| 68 | + site = TSC.SiteItem("site", "url") |
| 69 | + with pytest.raises(ValueError): |
| 70 | + site.subscribe_others_enabled = "Hello" |
| 71 | + |
| 72 | + with pytest.raises(ValueError): |
| 73 | + site.subscribe_others_enabled = None |
0 commit comments