def test_cred_only(self): os.environ['TASKCLUSTER_ACCESS_TOKEN'] = 'shave-and-a-haircut' self.assertEqual(subject.optionsFromEnvironment(), { 'credentials': { 'accessToken': 'shave-and-a-haircut', }, })
def test_cred_only(self): os.environ['TASKCLUSTER_ACCESS_TOKEN'] = 'shave-and-a-haircut' assert subject.optionsFromEnvironment() == { 'credentials': { 'accessToken': 'shave-and-a-haircut', }, }
def test_normalized_rooturl(self): """ If the environment contains a URL with a trailing slash, it is normalized by `optionsFromEnvironment`. """ os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.test/' assert subject.optionsFromEnvironment() == { 'rootUrl': 'https://tc.test' }
def test_default_rooturl(self): os.environ['TASKCLUSTER_CLIENT_ID'] = 'me' os.environ['TASKCLUSTER_ACCESS_TOKEN'] = 'shave-and-a-haircut' os.environ['TASKCLUSTER_CERTIFICATE'] = '{"bits":2}' assert subject.optionsFromEnvironment( {'rootUrl': 'https://other.example.com'}) == { 'rootUrl': 'https://other.example.com', 'credentials': { 'clientId': 'me', 'accessToken': 'shave-and-a-haircut', 'certificate': '{"bits":2}', }, }
def test_default_creds(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' os.environ['TASKCLUSTER_ACCESS_TOKEN'] = 'shave-and-a-haircut' os.environ['TASKCLUSTER_CERTIFICATE'] = '{"bits":2}' self.assertEqual( subject.optionsFromEnvironment({'credentials': {'clientId': 'them'}}), { 'rootUrl': 'https://tc.example.com', 'credentials': { 'clientId': 'them', 'accessToken': 'shave-and-a-haircut', 'certificate': '{"bits":2}', }, })
def test_all(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' os.environ['TASKCLUSTER_CLIENT_ID'] = 'me' os.environ['TASKCLUSTER_ACCESS_TOKEN'] = 'shave-and-a-haircut' os.environ['TASKCLUSTER_CERTIFICATE'] = '{"bits":2}' self.assertEqual( subject.optionsFromEnvironment(), { 'rootUrl': 'https://tc.example.com', 'credentials': { 'clientId': 'me', 'accessToken': 'shave-and-a-haircut', 'certificate': '{"bits":2}', }, })
def test_default_rooturl_overridden(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' assert subject.optionsFromEnvironment( {'rootUrl': 'https://other.example.com'}) == { 'rootUrl': 'https://tc.example.com' }
def test_rooturl_only(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' assert subject.optionsFromEnvironment() == { 'rootUrl': 'https://tc.example.com', }
def test_empty(self): self.clear_env() assert subject.optionsFromEnvironment() == {}
def test_empty(self): self.clear_env() self.assertEqual(subject.optionsFromEnvironment(), {})
def test_default_rooturl_overridden(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' self.assertEqual( subject.optionsFromEnvironment({'rootUrl': 'https://other.example.com'}), {'rootUrl': 'https://tc.example.com'})
def test_rooturl_only(self): os.environ['TASKCLUSTER_ROOT_URL'] = 'https://tc.example.com' self.assertEqual(subject.optionsFromEnvironment(), { 'rootUrl': 'https://tc.example.com', })