@@ -1483,6 +1483,49 @@ def test___str__(self):
1483
1483
table1 = self ._make_one (TableReference (dataset , "table1" ))
1484
1484
self .assertEqual (str (table1 ), "project1.dataset1.table1" )
1485
1485
1486
+ def test_max_staleness_getter (self ):
1487
+ """Test getting max_staleness property."""
1488
+ dataset = DatasetReference ("test-project" , "test_dataset" )
1489
+ table_ref = dataset .table ("test_table" )
1490
+ table = self ._make_one (table_ref )
1491
+ # Initially None
1492
+ self .assertIsNone (table .max_staleness )
1493
+ # Set max_staleness using setter
1494
+ table .max_staleness = "1h"
1495
+ self .assertEqual (table .max_staleness , "1h" )
1496
+
1497
+ def test_max_staleness_setter (self ):
1498
+ """Test setting max_staleness property."""
1499
+ dataset = DatasetReference ("test-project" , "test_dataset" )
1500
+ table_ref = dataset .table ("test_table" )
1501
+ table = self ._make_one (table_ref )
1502
+ # Set valid max_staleness
1503
+ table .max_staleness = "30m"
1504
+ self .assertEqual (table .max_staleness , "30m" )
1505
+ # Set to None
1506
+ table .max_staleness = None
1507
+ self .assertIsNone (table .max_staleness )
1508
+
1509
+ def test_max_staleness_setter_invalid_type (self ):
1510
+ """Test setting max_staleness with an invalid type raises ValueError."""
1511
+ dataset = DatasetReference ("test-project" , "test_dataset" )
1512
+ table_ref = dataset .table ("test_table" )
1513
+ table = self ._make_one (table_ref )
1514
+ # Try setting invalid type
1515
+ with self .assertRaises (ValueError ):
1516
+ table .max_staleness = 123 # Not a string
1517
+
1518
+ def test_max_staleness_to_api_repr (self ):
1519
+ """Test max_staleness is correctly represented in API representation."""
1520
+ dataset = DatasetReference ("test-project" , "test_dataset" )
1521
+ table_ref = dataset .table ("test_table" )
1522
+ table = self ._make_one (table_ref )
1523
+ # Set max_staleness
1524
+ table .max_staleness = "1h"
1525
+ # Convert to API representation
1526
+ resource = table .to_api_repr ()
1527
+ self .assertEqual (resource .get ("maxStaleness" ), "1h" )
1528
+
1486
1529
1487
1530
class Test_row_from_mapping (unittest .TestCase , _SchemaBase ):
1488
1531
PROJECT = "prahj-ekt"
0 commit comments