@@ -35,10 +35,7 @@ def test_default():
3535 'log_url' : os .getenv ('DD_LOGS_CONFIG_LOGS_DD_URL' , '' ),
3636 },
3737 },
38- 'github' : {
39- 'user' : get_github_user (),
40- 'token' : get_github_token (),
41- },
38+ 'github' : {},
4239 'pypi' : {
4340 'user' : '' ,
4441 'auth' : '' ,
@@ -714,10 +711,7 @@ def test_default(self):
714711 assert config .github .user == config .github .user == get_github_user ()
715712 assert config .github .token == config .github .token == get_github_token ()
716713 assert config .raw_data == {
717- 'github' : {
718- 'user' : get_github_user (),
719- 'token' : get_github_token (),
720- },
714+ 'github' : {},
721715 }
722716
723717 def test_not_table (self , helpers ):
@@ -1409,3 +1403,74 @@ def test_styles_spinner_set_lazy_error(self, helpers):
14091403 ),
14101404 ):
14111405 _ = config .terminal .styles .spinner
1406+
1407+
1408+ class TestGitHubConfig :
1409+ def test_default_github_config_empty_raw_data (self ):
1410+ config = RootConfig ({})
1411+ config .parse_fields ()
1412+
1413+ # GitHub config should be empty in raw_data when not explicitly set
1414+ assert config .raw_data ['github' ] == {}
1415+
1416+ # But properties should still work via environment variables
1417+ assert config .github .user == get_github_user ()
1418+ assert config .github .token == get_github_token ()
1419+
1420+ # After accessing properties, raw_data should still be empty
1421+ assert config .raw_data ['github' ] == {}
1422+
1423+ def test_explicit_github_config_in_raw_data (self ):
1424+ config = RootConfig ({'github' : {'user' : 'explicit_user' , 'token' : 'explicit_token' }})
1425+
1426+ # When explicitly set, values should be in raw_data
1427+ assert config .raw_data ['github' ]['user' ] == 'explicit_user'
1428+ assert config .raw_data ['github' ]['token' ] == 'explicit_token'
1429+
1430+ # Properties should return explicit values
1431+ assert config .github .user == 'explicit_user'
1432+ assert config .github .token == 'explicit_token'
1433+
1434+ def test_partial_github_config_explicit_user_only (self ):
1435+ config = RootConfig ({'github' : {'user' : 'explicit_user' }})
1436+
1437+ # Only explicitly set field should be in raw_data
1438+ assert config .raw_data ['github' ]['user' ] == 'explicit_user'
1439+ assert 'token' not in config .raw_data ['github' ]
1440+
1441+ # Properties should work - explicit user, env var token
1442+ assert config .github .user == 'explicit_user'
1443+ assert config .github .token == get_github_token ()
1444+
1445+ # raw_data should still only have explicit field
1446+ assert config .raw_data ['github' ]['user' ] == 'explicit_user'
1447+ assert 'token' not in config .raw_data ['github' ]
1448+
1449+ def test_partial_github_config_explicit_token_only (self ):
1450+ config = RootConfig ({'github' : {'token' : 'explicit_token' }})
1451+
1452+ # Only explicitly set field should be in raw_data
1453+ assert 'user' not in config .raw_data ['github' ]
1454+ assert config .raw_data ['github' ]['token' ] == 'explicit_token'
1455+
1456+ # Properties should work - env var user, explicit token
1457+ assert config .github .user == get_github_user ()
1458+ assert config .github .token == 'explicit_token'
1459+
1460+ # raw_data should still only have explicit field
1461+ assert 'user' not in config .raw_data ['github' ]
1462+ assert config .raw_data ['github' ]['token' ] == 'explicit_token'
1463+
1464+ def test_github_config_with_environment_variables (self , monkeypatch ):
1465+ # Mock environment variables
1466+ monkeypatch .setenv ('DD_GITHUB_USER' , 'env_user' )
1467+ monkeypatch .setenv ('DD_GITHUB_TOKEN' , 'env_token' )
1468+
1469+ config = RootConfig ({})
1470+
1471+ # Properties should return environment variable values
1472+ assert config .github .user == 'env_user'
1473+ assert config .github .token == 'env_token'
1474+
1475+ # raw_data should still be empty
1476+ assert config .raw_data ['github' ] == {}
0 commit comments