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