예제 #1
0
 def test_project_config_constructor(self, project_name, bucket_name,
                                     expected_bucket_name):
     """Test the direct construction of ProjectConfig."""
     test_config = common.ProjectConfig(project_name, 'test_client_id',
                                        'test_client_secret', bucket_name)
     self.assertEqual(project_name, test_config.project)
     self.assertEqual('test_client_id', test_config.client_id)
     self.assertEqual('test_client_secret', test_config.client_secret)
     self.assertEqual(expected_bucket_name, test_config.bucket)
     self.assertEqual('{}/configs'.format(expected_bucket_name),
                      test_config.configs)
     # Test that two objects with the same constructor args are equal.
     self.assertEqual(
         test_config,
         common.ProjectConfig(project_name, 'test_client_id',
                              'test_client_secret', bucket_name))
     # Test that two object with different constructor args are not equal.
     self.assertNotEqual(
         test_config,
         common.ProjectConfig(project_name, 'test_client_id',
                              'test_client_secret', 'INCORRECT'))
     # Test the string and representations for ProjectConfig.
     self.assertEqual('ProjectConfig for project: test_project.',
                      str(test_config))
     self.assertEqual(
         '<ProjectConfig({}, test_client_id, test_client_secret, {})>'.
         format(project_name, expected_bucket_name), repr(test_config))
예제 #2
0
 def test_project_config_constructor(self, project_name, bucket_name,
                                     expected_bucket_name):
     """Test the direct construction of ProjectConfig."""
     test_config = common.ProjectConfig('dev', project_name,
                                        'test_client_id',
                                        'test_client_secret', bucket_name,
                                        '/this/config/file.yaml')
     self.assertEqual(project_name, test_config.project)
     self.assertEqual('test_client_id', test_config.client_id)
     self.assertEqual('test_client_secret', test_config.client_secret)
     self.assertEqual(expected_bucket_name, test_config.bucket)
     self.assertEqual('configs/constants.json',
                      test_config.constants_storage_path)
     self.assertEqual('/this/config/file.yaml', test_config.path)
     # Test that two objects with the same constructor args are equal.
     self.assertEqual(
         test_config,
         common.ProjectConfig('dev', project_name, 'test_client_id',
                              'test_client_secret', bucket_name,
                              '/this/config/file.yaml'))
     # Test that two object with different constructor args are not equal.
     self.assertNotEqual(
         test_config,
         common.ProjectConfig('dev', project_name, 'test_client_id',
                              'test_client_secret', 'INCORRECT',
                              '/this/config/file.yaml'))
     # Test the string and representations for ProjectConfig.
     self.assertEqual("ProjectConfig for project 'test_project'.",
                      str(test_config))
     self.assertEqual(
         '<ProjectConfig(dev, {}, test_client_id, test_client_secret, {}, '
         '/this/config/file.yaml)>'.format(project_name,
                                           expected_bucket_name),
         repr(test_config))
예제 #3
0
 def test_manager_init(self):
     test_config = common.ProjectConfig('KEY', 'PROJECT', 'ID', 'SECRET',
                                        'BUCKET', self._blank_config_path)
     test_constants = app_constants.get_default_constants()
     test_manager = gng_impl._Manager(test_config, test_constants, None)
     self.assertEqual(str(test_manager), "_Manager for project 'PROJECT'")
     self.assertEqual(repr(test_manager),
                      '<_Manager.new(/testdata/blank_config.yaml, KEY)>')
예제 #4
0
 def test_project_config_from_yaml(self):
     """Test the construction of ProjectConfig when loaded from a config file."""
     expected_config = common.ProjectConfig('test_project',
                                            'test_client_id',
                                            'test_client_secret', None)
     config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'config.yaml')
     self.fs.CreateFile(config_file, contents=_CONFIG)
     test_config = common.ProjectConfig.from_yaml('dev', config_file)
     self.assertEqual(expected_config, test_config)
예제 #5
0
 def setUp(self):
   super(AuthTest, self).setUp()
   self._test_project = 'test_project'
   self._test_client_id = 'test_client_id'
   self._test_client_secret = 'test_client_secret'
   self._test_config = common.ProjectConfig(
       'test_key', self._test_project, self._test_client_id,
       self._test_client_secret, None, '/test/path.yaml')
   # Save the real modules for clean up.
   self.real_open = builtins.open
   # Create a fake file system and stub out builtin modules.
   self.fs = fake_filesystem.FakeFilesystem()
   self.os = fake_filesystem.FakeOsModule(self.fs)
   self.open = fake_filesystem.FakeFileOpen(self.fs)
   self.stubs = mox3_stubout.StubOutForTesting()
   self.stubs.SmartSet(builtins, 'open', self.open)
   self.stubs.SmartSet(auth, 'os', self.os)
예제 #6
0
 def test_write(self):
     expected_dict = {
         'project_id': 'test_project',
         'client_id': 'test_client_id',
         'client_secret': 'test_client_secret',
         'bucket': 'test_project.appspot.com',
     }
     self.fs.CreateFile('/this/config/file.yaml', contents=_EMPTY_CONFIG)
     test_config = common.ProjectConfig(
         'asdf',
         'test_project',
         'test_client_id',
         'test_client_secret',
         None,
         '/this/config/file.yaml',
     )
     test_config.write()
     with open('/this/config/file.yaml') as config_file:
         config = yaml.safe_load(config_file)
     self.assertEqual(config['asdf'], expected_dict)
예제 #7
0
 def test_from_prompts(self):
     expected_response = common.ProjectConfig(
         'test',
         'fake_project',
         'fake_client_id',
         'fake_client_secret',
         None,
         '/this/config/file.yaml',
     )
     prompt_return = [
         'fake_project', 'fake_client_id', 'fake_client_secret'
     ]
     with mock.patch.object(utils,
                            'prompt_string',
                            side_effect=prompt_return) as mock_prompt:
         self.assertEqual(
             common.ProjectConfig.from_prompts('test',
                                               '/this/config/file.yaml'),
             expected_response)
         self.assertEqual(mock_prompt.call_count, 3)
예제 #8
0
 def setUp(self):
   super(AppEngineTest, self).setUp()
   self.config = common.ProjectConfig(
       'TEST_PROJECT', 'TEST_CLIENT_ID', 'TEST_CLIENT_SECRET', 'TEST_BUCKET')
예제 #9
0
 def setUp(self):
     super(GoogleApiTest, self).setUp()
     self.config = common.ProjectConfig('TEST_KEY', 'TEST_PROJECT',
                                        'TEST_CLIENT_ID',
                                        'TEST_CLIENT_SECRET', 'TEST_BUCKET',
                                        '/this/path.yaml')
예제 #10
0
 def setUp(self):
     super(CloudStorageAPITest, self).setUp()
     self.config = common.ProjectConfig('TEST_PROJECT', 'TEST_CLIENT_ID',
                                        'TEST_CLIENT_SECRET', 'TEST_BUCKET')
예제 #11
0
 def setUp(self):
     super(DatastoreAPITest, self).setUp()
     self.config = common.ProjectConfig('TEST_KEY', 'TEST_PROJECT',
                                        'TEST_CLIENT_ID',
                                        'TEST_CLIENT_SECRET', 'TEST_BUCKET',
                                        '/test/path.yaml')