|
1 | | -import unittest |
2 | 1 | import tableauserverclient as TSC |
3 | 2 |
|
| 3 | +import pytest |
4 | 4 |
|
5 | | -class DatasourceModelTests(unittest.TestCase): |
6 | | - def test_require_boolean_query_tag_fails(self): |
7 | | - conn = TSC.ConnectionItem() |
8 | | - conn._connection_type = "postgres" |
9 | | - with self.assertRaises(ValueError): |
10 | | - conn.query_tagging = "no" |
11 | 5 |
|
12 | | - def test_set_query_tag_normal_conn(self): |
13 | | - conn = TSC.ConnectionItem() |
14 | | - conn._connection_type = "postgres" |
15 | | - conn.query_tagging = True |
16 | | - self.assertEqual(conn.query_tagging, True) |
| 6 | +def test_require_boolean_query_tag_fails() -> None: |
| 7 | + conn = TSC.ConnectionItem() |
| 8 | + conn._connection_type = "postgres" |
| 9 | + with pytest.raises(ValueError): |
| 10 | + conn.query_tagging = "no" # type: ignore[assignment] |
17 | 11 |
|
18 | | - def test_ignore_query_tag_for_hyper(self): |
19 | | - conn = TSC.ConnectionItem() |
20 | | - conn._connection_type = "hyper" |
21 | | - conn.query_tagging = True |
22 | | - self.assertEqual(conn.query_tagging, None) |
23 | 12 |
|
24 | | - def test_ignore_query_tag_for_teradata(self): |
25 | | - conn = TSC.ConnectionItem() |
26 | | - conn._connection_type = "teradata" |
27 | | - conn.query_tagging = True |
28 | | - self.assertEqual(conn.query_tagging, None) |
| 13 | +def test_set_query_tag_normal_conn() -> None: |
| 14 | + conn = TSC.ConnectionItem() |
| 15 | + conn._connection_type = "postgres" |
| 16 | + conn.query_tagging = True |
| 17 | + assert conn.query_tagging |
29 | 18 |
|
30 | | - def test_ignore_query_tag_for_snowflake(self): |
31 | | - conn = TSC.ConnectionItem() |
32 | | - conn._connection_type = "snowflake" |
33 | | - conn.query_tagging = True |
34 | | - self.assertEqual(conn.query_tagging, None) |
| 19 | + |
| 20 | +@pytest.mark.parametrize("conn_type", ["hyper", "teradata", "snowflake"]) |
| 21 | +def test_ignore_query_tag(conn_type: str) -> None: |
| 22 | + conn = TSC.ConnectionItem() |
| 23 | + conn._connection_type = conn_type |
| 24 | + conn.query_tagging = True |
| 25 | + assert conn.query_tagging is None |
0 commit comments