Beispiel #1
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()
Beispiel #2
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()
Beispiel #3
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()
Beispiel #4
0
 def tearDown(self):
     for exec_docker_process in self.exec_docker_processes:
         try:
             os.kill(exec_docker_process.pid)
         except:
             pass
     shutil.rmtree(self.overridden_specs_path)
     if os.path.exists(constants.COMPOSE_DIR):
         shutil.rmtree(constants.COMPOSE_DIR)
     shutil.rmtree('/tmp/fake-repo')
     save_config(self.previous_config)
     self.handler.log_to_client_output = ''
     client_logger.removeHandler(self.handler)
     nfs_client.unmount_all_repos()
     reset_memoize_cache()
     nfs_server._write_exports_config(set())
Beispiel #5
0
 def tearDown(self):
     for exec_docker_process in self.exec_docker_processes:
         try:
             os.kill(exec_docker_process.pid)
         except:
             pass
     shutil.rmtree(self.overridden_specs_path)
     if os.path.exists(constants.COMPOSE_DIR):
         shutil.rmtree(constants.COMPOSE_DIR)
     shutil.rmtree("/tmp/fake-repo")
     save_config(self.previous_config)
     self.handler.log_to_client_output = ""
     client_logger.removeHandler(self.handler)
     nfs_client.unmount_all_repos()
     reset_memoize_cache()
     nfs_server._write_exports_config(set())
Beispiel #6
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()
Beispiel #7
0
 def test_unset(self):
     self.run_command('assets unset required_app_asset')
     self.run_command('assets unset required_lib_asset')
     reset_memoize_cache()
     self.assertFalse(asset_is_set('required_app_asset'))
     self.assertFalse(asset_is_set('required_lib_asset'))
Beispiel #8
0
 def tearDown(self):
     os.remove(self.temp_config_path)
     shutil.rmtree(self.temp_specs_path)
     shutil.rmtree(self.temp_repos_path)
     logging.getLogger(constants.SOCKET_LOGGER_NAME).removeHandler(self.capture_handler)
     reset_memoize_cache()
Beispiel #9
0
 def test_unset(self):
     self.run_command('assets unset required_app_asset')
     self.run_command('assets unset required_lib_asset')
     reset_memoize_cache()
     self.assertFalse(asset_is_set('required_app_asset'))
     self.assertFalse(asset_is_set('required_lib_asset'))
Beispiel #10
0
 def test_cache_bust(self):
     self.memoized_fn()
     reset_memoize_cache()
     self.memoized_fn()
     self.assertEqual(self.counter, 2)
Beispiel #11
0
 def tearDown(self):
     os.remove(self.temp_config_path)
     shutil.rmtree(self.temp_specs_path)
     shutil.rmtree(self.temp_repos_path)
     logging.getLogger(constants.SOCKET_LOGGER_NAME).removeHandler(self.capture_handler)
     reset_memoize_cache()