Exemple #1
0
 def test_override_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
         })
Exemple #2
0
 def test_list_repos_with_one_override(self):
     override_repo('github.com/app/a', self.temp_specs_path)
     list_repos()
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/a', self.temp_specs_path],
                                ['github.com/app/b', False]],
                               offset=1)
Exemple #3
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()
Exemple #4
0
 def test_list_repos_with_one_override(self):
     override_repo('github.com/app/a', self.temp_specs_path)
     list_repos()
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/a', self.temp_specs_path]])
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/b', False]],
                               offset=2)
Exemple #5
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})
Exemple #6
0
 def test_override_repo_colon(self):
     bad_path = os.path.join(self.temp_specs_path, 'colon:path')
     os.makedirs(bad_path)
     with self.assertRaises(RuntimeError):
         override_repo('github.com/app/a', bad_path)
     list_repos()
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/a', False],
                                ['github.com/app/b', False]],
                               offset=1)
Exemple #7
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)
Exemple #8
0
 def test_override_repo_colon(self):
     bad_path = os.path.join(self.temp_specs_path, 'colon:path')
     os.makedirs(bad_path)
     with self.assertRaises(RuntimeError):
         override_repo('github.com/app/a', bad_path)
     list_repos()
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/a', False]])
     self._assert_listed_repos(self.last_client_output,
                               [['github.com/app/b', False]],
                               offset=2)
Exemple #9
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)
Exemple #10
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()
Exemple #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)
        reset_memoize_cache()
Exemple #12
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()
Exemple #13
0
 def test_local_path(self):
     repo = Repo('github.com/app/a')
     self.assertEqual(repo.local_path, '/etc/dusty/repos/github.com/app/a')
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(repo.local_path, self.temp_dir)
Exemple #14
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)
Exemple #15
0
 def test_local_repo_path_with_override(self):
     override_repo("github.com/app/a", self.temp_dir)
     self.assertEqual(Repo("github.com/app/a").local_path, self.temp_dir)
Exemple #16
0
 def test_override_path(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(Repo('github.com/app/a').override_path, self.temp_dir)
     override_repo('/tmp/repo-c', self.temp_dir)
     self.assertEqual(Repo('/tmp/repo-c').override_path, self.temp_dir)
Exemple #17
0
 def test_repo_is_overridden_true(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertTrue(Repo('github.com/app/a').is_overridden)
Exemple #18
0
 def test_local_path(self):
     repo = Repo('github.com/app/a')
     self.assertEqual(repo.local_path, '/etc/dusty/repos/github.com/app/a')
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(repo.local_path, self.temp_dir)
Exemple #19
0
 def test_override_path(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(Repo('github.com/app/a').override_path, self.temp_dir)
     override_repo('/tmp/repo-c', self.temp_dir)
     self.assertEqual(Repo('/tmp/repo-c').override_path, self.temp_dir)
Exemple #20
0
 def test_local_repo_path_with_override(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(Repo('github.com/app/a').local_path, self.temp_dir)
Exemple #21
0
 def test_repo_is_overridden_true(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertTrue(Repo('github.com/app/a').is_overridden)