Skip to content

Commit c31784a

Browse files
authored
chore: pytestify test_connection_ (#1650)
* chore: pytestify test_connection_ Embrace pytest's testing methodology in test_connection_ * chore: parameterize test * chore: add type hints to tests --------- Co-authored-by: Jordan Woods <[email protected]>
1 parent 7bd23f4 commit c31784a

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

test/test_connection_.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
1-
import unittest
21
import tableauserverclient as TSC
32

3+
import pytest
44

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"
115

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]
1711

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)
2312

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
2918

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

Comments
 (0)