Пример #1
0
 def test_override_then_manage_repo(self):
     override_repo('github.com/app/a', self.temp_specs_path)
     self.assertItemsEqual(get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY),
                           {get_specs_repo().remote_path: self.temp_specs_path,
                            'github.com/app/a': self.temp_specs_path})
     manage_repo('github.com/app/a')
     self.assertItemsEqual(get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY),
                           {get_specs_repo().remote_path: self.temp_specs_path})
Пример #2
0
 def test_override_then_manage_repo(self):
     override_repo('github.com/app/a', self.temp_specs_path)
     self.assertItemsEqual(
         get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY), {
             get_specs_repo().remote_path: self.temp_specs_path,
             'github.com/app/a': self.temp_specs_path
         })
     manage_repo('github.com/app/a')
     self.assertItemsEqual(
         get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY),
         {get_specs_repo().remote_path: self.temp_specs_path})
Пример #3
0
 def test_override_repos_from_directory(self):
     override_repos_from_directory(self.temp_repos_path)
     self.assertItemsEqual(get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY),
                           {get_specs_repo().remote_path: self.temp_specs_path,
                            'github.com/app/a': os.path.join(self.temp_repos_path, 'a'),
                            'github.com/app/b': os.path.join(self.temp_repos_path, 'b'),
                            'github.com/lib/a': os.path.join(self.temp_repos_path, 'a')})
Пример #4
0
    def setUp(self):
        if not os.getenv("DUSTY_ALLOW_INTEGRATION_TESTS"):
            raise RuntimeError(
                "You must set the env var DUSTY_ALLOW_INTEGRATION_TESTS to run integration tests. "
                "This may affect your local config, do not run integration tests on your actual "
                "machine unless you know what you're doing!"
            )
        self.handler = DustyClientTestingSocketHandler()
        client_logger.addHandler(self.handler)
        self.previous_config = get_config()
        self._clear_stdout()
        self.overridden_specs_path = tempfile.mkdtemp()
        write_default_config()
        save_config_value(constants.CONFIG_SETUP_KEY, True)
        save_config_value(constants.CONFIG_SPECS_REPO_KEY, "github.com/gamechanger/dusty-example-specs")

        self.tests_user = os.getenv("DUSTY_INTEGRATION_TESTS_USER", self.current_user)
        save_config_value(constants.CONFIG_MAC_USERNAME_KEY, self.tests_user)

        override_repo(get_specs_repo().remote_path, self.overridden_specs_path)
        self.fake_local_repo_location = "/tmp/fake-repo"
        self._set_up_fake_local_repo("/tmp/fake-repo")
        self._clear_stdout()
        self.exec_docker_processes = []
        reset_memoize_cache()
Пример #5
0
 def test_override_repos_from_directory(self):
     override_repos_from_directory(self.temp_repos_path)
     self.assertItemsEqual(
         get_config_value(constants.CONFIG_REPO_OVERRIDES_KEY), {
             get_specs_repo().remote_path: self.temp_specs_path,
             'github.com/app/a': os.path.join(self.temp_repos_path, 'a'),
             'github.com/app/b': os.path.join(self.temp_repos_path, 'b'),
             'github.com/lib/a': os.path.join(self.temp_repos_path, 'a')
         })
Пример #6
0
 def test_override_then_manage_all(self, fake_manage_repo):
     override_repo('github.com/app/a', self.temp_specs_path)
     override_repo('github.com/app/b', self.temp_specs_path)
     manage_all_repos()
     fake_manage_repo.assert_has_calls([
         call('github.com/app/a'),
         call('github.com/app/b'),
         call(get_specs_repo().remote_path)
     ],
                                       any_order=True)
Пример #7
0
 def test_save_value_changes_value(self):
     save_value('docker_user', '~/here')
     list_config_values()
     self.assertItemsEqual(json.loads(self.last_client_output.replace('\'', '\"').replace('False', 'false').replace('True', 'true')),
                           {constants.CONFIG_BUNDLES_KEY: [],
                            constants.CONFIG_REPO_OVERRIDES_KEY: {get_specs_repo(): self.temp_specs_path},
                            'docker_user': '******',
                            constants.CONFIG_SPECS_REPO_KEY: 'github.com/org/dusty-specs',
                            constants.CONFIG_SETUP_KEY: False,
                            constants.CONFIG_VM_MEM_SIZE: '2048'})
Пример #8
0
 def setUp(self):
     super(TestManageConfigCommands, self).setUp()
     self.old_config_path = dusty.constants.CONFIG_PATH
     self.old_config_settings = dusty.constants.CONFIG_SETTINGS
     dusty.constants.CONFIG_SETTINGS = {k: '' for k in [constants.CONFIG_BUNDLES_KEY, constants.CONFIG_REPO_OVERRIDES_KEY, constants.CONFIG_SPECS_REPO_KEY, 'docker_user']}
     self.expected_config = {constants.CONFIG_BUNDLES_KEY: [],
                             constants.CONFIG_REPO_OVERRIDES_KEY: {get_specs_repo(): self.temp_specs_path},
                             constants.CONFIG_SPECS_REPO_KEY: 'github.com/org/dusty-specs',
                             constants.CONFIG_SETUP_KEY: False,
                             constants.CONFIG_VM_MEM_SIZE: '2048'}
Пример #9
0
 def test_save_value_changes_value(self):
     save_value('docker_user', '~/here')
     list_config_values()
     self.assertItemsEqual(json.loads(self.last_client_output.replace('\'', '\"').replace('False', 'false').replace('True', 'true')),
                           {constants.CONFIG_BUNDLES_KEY: [],
                            constants.CONFIG_ENV_KEY: {},
                            constants.CONFIG_REPO_OVERRIDES_KEY: {get_specs_repo(): self.temp_specs_path},
                            'docker_user': '******',
                            constants.CONFIG_SPECS_REPO_KEY: 'github.com/org/dusty-specs',
                            constants.CONFIG_SETUP_KEY: False,
                            constants.CONFIG_VM_MEM_SIZE: '2048'})
Пример #10
0
 def setUp(self):
     super(TestManageConfigCommands, self).setUp()
     self.old_config_path = dusty.constants.CONFIG_PATH
     self.old_config_settings = dusty.constants.CONFIG_SETTINGS
     dusty.constants.CONFIG_SETTINGS = {k: '' for k in [constants.CONFIG_BUNDLES_KEY, constants.CONFIG_REPO_OVERRIDES_KEY, constants.CONFIG_SPECS_REPO_KEY, 'docker_user']}
     self.expected_config = {constants.CONFIG_BUNDLES_KEY: [],
                             constants.CONFIG_ENV_KEY: {},
                             constants.CONFIG_REPO_OVERRIDES_KEY: {get_specs_repo(): self.temp_specs_path},
                             constants.CONFIG_SPECS_REPO_KEY: 'github.com/org/dusty-specs',
                             constants.CONFIG_SETUP_KEY: False,
                             constants.CONFIG_VM_MEM_SIZE: '2048'}
Пример #11
0
    def setUp(self):
        self.temp_config_path = tempfile.mkstemp()[1]
        self.temp_specs_path = tempfile.mkdtemp()
        self.temp_repos_path = tempfile.mkdtemp()

        constants.CONFIG_PATH = self.temp_config_path
        write_default_config()
        save_config_value(constants.CONFIG_SPECS_REPO_KEY, 'github.com/org/dusty-specs')
        override_repo(get_specs_repo().remote_path, self.temp_specs_path)
        basic_specs_fixture()

        self.client_output = []
        self.capture_handler = TestCaptureHandler(self.client_output)
        logging.getLogger(constants.SOCKET_LOGGER_NAME).addHandler(self.capture_handler)
Пример #12
0
    def setUp(self):
        self.temp_config_path = tempfile.mkstemp()[1]
        self.temp_specs_path = tempfile.mkdtemp()
        self.temp_repos_path = tempfile.mkdtemp()

        constants.CONFIG_PATH = self.temp_config_path
        write_default_config()
        save_config_value(constants.CONFIG_SPECS_REPO_KEY, 'github.com/org/dusty-specs')
        override_repo(get_specs_repo().remote_path, self.temp_specs_path)
        basic_specs_fixture()

        self.client_output = []
        self.capture_handler = TestCaptureHandler(self.client_output)
        logging.getLogger(constants.SOCKET_LOGGER_NAME).addHandler(self.capture_handler)
        reset_memoize_cache()
Пример #13
0
 def setUp(self):
     if not os.getenv('DUSTY_ALLOW_INTEGRATION_TESTS'):
         raise RuntimeError('You must set the env var DUSTY_ALLOW_INTEGRATION_TESTS to run integration tests. '
                            'This may affect your local config, do not run integration tests on your actual '
                            "machine unless you know what you're doing!")
     self.previous_config = get_config()
     self._clear_stdout()
     self.overridden_specs_path = tempfile.mkdtemp()
     write_default_config()
     save_config_value(constants.CONFIG_SETUP_KEY, True)
     save_config_value(constants.CONFIG_SPECS_REPO_KEY, 'github.com/gamechanger/example-dusty-specs')
     save_config_value(constants.CONFIG_MAC_USERNAME_KEY, self.current_user)
     override_repo(get_specs_repo().remote_path, self.overridden_specs_path)
     self._set_up_fake_local_repo()
     self._clear_stdout()
Пример #14
0
    def setUp(self):
        if not os.getenv('DUSTY_ALLOW_INTEGRATION_TESTS'):
            raise RuntimeError('You must set the env var DUSTY_ALLOW_INTEGRATION_TESTS to run integration tests. '
                               'This may affect your local config, do not run integration tests on your actual '
                               "machine unless you know what you're doing!")
        self.handler = DustyClientTestingSocketHandler()
        client_logger.addHandler(self.handler)
        self.previous_config = get_config()
        self._clear_stdout()
        self.overridden_specs_path = tempfile.mkdtemp()
        write_default_config()
        save_config_value(constants.CONFIG_SETUP_KEY, True)
        save_config_value(constants.CONFIG_SPECS_REPO_KEY, 'github.com/gamechanger/dusty-example-specs')

        self.tests_user = os.getenv('DUSTY_INTEGRATION_TESTS_USER', self.current_user)
        save_config_value(constants.CONFIG_MAC_USERNAME_KEY, self.tests_user)

        override_repo(get_specs_repo().remote_path, self.overridden_specs_path)
        self.fake_local_repo_location = '/tmp/fake-repo'
        self._set_up_fake_local_repo('/tmp/fake-repo')
        self._clear_stdout()
        self.exec_docker_processes = []
        reset_memoize_cache()
Пример #15
0
 def test_override_then_manage_all(self, fake_manage_repo):
     override_repo('github.com/app/a', self.temp_specs_path)
     override_repo('github.com/app/b', self.temp_specs_path)
     manage_all_repos()
     fake_manage_repo.assert_has_calls([call('github.com/app/a'), call('github.com/app/b'),
                                        call(get_specs_repo().remote_path)], any_order=True)