Example #1
0
 def test_repo_name_from_git(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     self.assertEqual("CumulusCI", config.repo_name)
Example #2
0
 def test_repo_url_from_git(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     self.assertIn("/CumulusCI", config.repo_url)
Example #3
0
    def test_process_github_dependency(self):
        global_config = BaseGlobalConfig()
        config = BaseProjectConfig(global_config)
        config.get_github_api = DummyGithub
        config.keychain = DummyKeychain()

        result = config.process_github_dependency({
            "github":
            "https://github.com/SFDO-Tooling/CumulusCI-Test.git",
            "unmanaged":
            True,
            "skip": ["unpackaged/pre/skip", "unpackaged/post/skip"],
        })
        self.assertEqual(
            result,
            [
                {
                    u"headers": {
                        u"Authorization": u"token password"
                    },
                    u"namespace_inject":
                    None,
                    u"namespace_strip":
                    None,
                    u"namespace_tokenize":
                    None,
                    u"subfolder":
                    u"CumulusCI-Test-master/unpackaged/pre/pre",
                    u"unmanaged":
                    True,
                    u"zip_url":
                    u"https://github.com/SFDO-Tooling/CumulusCI-Test/archive/master.zip",
                },
                {
                    u"version": "2",
                    u"namespace": "ccitestdep"
                },
                {
                    u"headers": {
                        u"Authorization": u"token password"
                    },
                    u"namespace_inject":
                    None,
                    u"namespace_strip":
                    None,
                    u"namespace_tokenize":
                    None,
                    u"subfolder":
                    u"CumulusCI-Test-master/src",
                    u"unmanaged":
                    True,
                    u"zip_url":
                    u"https://github.com/SFDO-Tooling/CumulusCI-Test/archive/master.zip",
                },
                {
                    u"headers": {
                        u"Authorization": u"token password"
                    },
                    u"namespace_inject":
                    "ccitest",
                    u"namespace_strip":
                    None,
                    u"namespace_tokenize":
                    None,
                    u"subfolder":
                    u"CumulusCI-Test-master/unpackaged/post/post",
                    u"unmanaged":
                    True,
                    u"zip_url":
                    u"https://github.com/SFDO-Tooling/CumulusCI-Test/archive/master.zip",
                },
            ],
        )
Example #4
0
 def test_repo_root_from_env(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"root": "."}
     self.assertEqual(".", config.repo_root)
Example #5
0
 def test_list_orgs(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config.keychain = mock.Mock()
     config.keychain.list_orgs.return_value = mock.sentinel.orgs
     self.assertIs(mock.sentinel.orgs, config.list_orgs())
Example #6
0
 def test_set_org(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config.keychain = mock.Mock()
     config.set_org("test", {})
     config.keychain.set_org.assert_called_once()
Example #7
0
 def test_include_source__unknown(self):
     global_config = BaseGlobalConfig()
     project_config = BaseProjectConfig(global_config)
     with self.assertRaises(Exception):
         project_config.include_source({"foo": "bar"})
Example #8
0
 def test_config_project_path_no_repo_root(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     with temporary_dir() as d:
         self.assertIsNone(config.config_project_path)
Example #9
0
 def test_get_namespace__not_found(self):
     global_config = BaseGlobalConfig()
     project_config = BaseProjectConfig(global_config)
     with self.assertRaises(NamespaceNotFoundError):
         project_config.get_namespace("test")
Example #10
0
 def test_include_source__github(self, source):
     source.return_value = expected_result = mock.Mock()
     global_config = BaseGlobalConfig()
     project_config = BaseProjectConfig(global_config)
     other_config = project_config.include_source({"github": "foo/bar"})
     assert other_config.source is expected_result
Example #11
0
    def test_process_github_dependency_latest(self):
        global_config = BaseGlobalConfig()
        config = BaseProjectConfig(global_config)
        config.keychain = DummyKeychain()
        github = self._make_github()
        github.repositories["CumulusCI-Test-Dep"]._releases = [
            DummyRelease("beta/1.1-Beta_1", "1.1 (Beta 1)"),
            DummyRelease("release/1.0", "1.0"),
        ]
        config.get_github_api = mock.Mock(return_value=github)

        result = config.process_github_dependency(
            {
                "github": "https://github.com/SFDO-Tooling/CumulusCI-Test.git",
                "unmanaged": True,
                "skip": ["unpackaged/pre/skip", "unpackaged/post/skip"],
            },
            "",
            include_beta=True,
        )
        self.assertEqual(
            result,
            [
                {
                    "name": "Deploy unpackaged/pre/pre",
                    "repo_owner": "SFDO-Tooling",
                    "repo_name": "CumulusCI-Test",
                    "ref": "commit_sha",
                    "subfolder": "unpackaged/pre/pre",
                    "unmanaged": True,
                    "namespace_inject": None,
                    "namespace_strip": None,
                    "namespace_tokenize": None,
                },
                {
                    "name": "Install CumulusCI-Test-Dep 1.1 (Beta 1)",
                    "version": "1.1 (Beta 1)",
                    "namespace": "ccitestdep",
                },
                {
                    "name": "Deploy CumulusCI-Test",
                    "repo_owner": "SFDO-Tooling",
                    "repo_name": "CumulusCI-Test",
                    "ref": "commit_sha",
                    "subfolder": "src",
                    "unmanaged": True,
                    "namespace_inject": None,
                    "namespace_strip": None,
                    "namespace_tokenize": None,
                },
                {
                    "name": "Deploy unpackaged/post/post",
                    "repo_owner": "SFDO-Tooling",
                    "repo_name": "CumulusCI-Test",
                    "ref": "commit_sha",
                    "subfolder": "unpackaged/post/post",
                    "unmanaged": True,
                    "namespace_inject": "ccitest",
                    "namespace_strip": None,
                    "namespace_tokenize": None,
                },
            ],
        )
Example #12
0
 def test_get_static_dependencies(self):
     dep = {"namespace": "npsp", "version": "3"}
     config = BaseProjectConfig(
         BaseGlobalConfig(), {"project": {"dependencies": [dep]}}
     )
     self.assertEqual([dep], config.get_static_dependencies())
Example #13
0
 def test_get_tag_for_version_beta(self):
     config = BaseProjectConfig(
         BaseGlobalConfig(), {"project": {"git": {"prefix_beta": "beta/"}}}
     )
     self.assertEqual("beta/1.0-Beta_1", config.get_tag_for_version("1.0 (Beta 1)"))
Example #14
0
 def test_get_tag_for_version(self):
     config = BaseProjectConfig(
         BaseGlobalConfig(), {"project": {"git": {"prefix_release": "release/"}}}
     )
     self.assertEqual("release/1.0", config.get_tag_for_version("1.0"))
Example #15
0
 def test_relpath(self):
     global_config = BaseGlobalConfig()
     project_config = BaseProjectConfig(global_config)
     assert project_config.relpath(os.path.abspath(".")) == "."
Example #16
0
 def test_get_github_api(self, get_github_api):
     config = BaseProjectConfig(BaseGlobalConfig())
     config.keychain = mock.Mock()
     config.get_github_api()
     get_github_api.assert_called_once()
Example #17
0
    def test_process_github_dependency(self):
        global_config = BaseGlobalConfig()
        config = BaseProjectConfig(global_config)
        config.get_github_api = DummyGithub
        config.keychain = DummyKeychain()

        result = config.process_github_dependency({
            'github': 'https://github.com/SalesforceFoundation/CumulusCI-Test',
            'unmanaged': True,
        })
        self.assertEqual(result, [
            {
                u'headers': {
                    u'Authorization': u'token password'
                },
                u'namespace_inject':
                None,
                u'namespace_strip':
                None,
                u'namespace_tokenize':
                None,
                u'subfolder':
                u'CumulusCI-Test-master/unpackaged/pre/pre',
                u'unmanaged':
                True,
                u'zip_url':
                u'https://github.com/SalesforceFoundation/CumulusCI-Test/archive/master.zip',
            },
            {
                u'version': '2',
                u'namespace': 'ccitestdep'
            },
            {
                u'headers': {
                    u'Authorization': u'token password'
                },
                u'namespace_inject':
                None,
                u'namespace_strip':
                None,
                u'namespace_tokenize':
                None,
                u'subfolder':
                u'CumulusCI-Test-master/src',
                u'unmanaged':
                True,
                u'zip_url':
                u'https://github.com/SalesforceFoundation/CumulusCI-Test/archive/master.zip',
            },
            {
                u'headers': {
                    u'Authorization': u'token password'
                },
                u'namespace_inject':
                'ccitest',
                u'namespace_strip':
                None,
                u'namespace_tokenize':
                None,
                u'subfolder':
                u'CumulusCI-Test-master/unpackaged/post/post',
                u'unmanaged':
                True,
                u'zip_url':
                u'https://github.com/SalesforceFoundation/CumulusCI-Test/archive/master.zip',
            },
        ])
Example #18
0
 def test_check_keychain(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     with self.assertRaises(KeychainNotFound):
         config._check_keychain()
 def test_config_global(self):
     global_config = BaseGlobalConfig()
     global_config.config_global = {}
     config = BaseProjectConfig(global_config)
     self.assertIs(global_config.config_global, config.config_global)
Example #20
0
 def test_get_org(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config.keychain = mock.Mock()
     config.keychain.get_org.return_value = mock.sentinel.org
     self.assertIs(mock.sentinel.org, config.get_org("test"))
Example #21
0
 def test_list_projects(self):
     with self.assertRaises(NotImplementedError):
         BaseGlobalConfig().list_projects()
Example #22
0
 def test_get_static_dependencies_no_dependencies(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     self.assertIsNone(config.get_static_dependencies())
Example #23
0
 def test_create_project(self):
     with self.assertRaises(NotImplementedError):
         BaseGlobalConfig().create_project("test", {})
Example #24
0
 def test_config_global(self):
     global_config = BaseGlobalConfig()
     global_config.config_global = {}
     config = BaseProjectConfig(global_config)
     self.assertIs(global_config.config_global, config.config_global)
Example #25
0
 def test_repo_branch_from_repo_info(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"branch": "master"}
     self.assertEqual("master", config.repo_branch)
Example #26
0
 def test_repo_name_from_repo_info(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"name": "CumulusCI"}
     self.assertEqual("CumulusCI", config.repo_name)
Example #27
0
 def test_repo_commit_from_repo_info(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"commit": "abcdef"}
     self.assertEqual("abcdef", config.repo_commit)
Example #28
0
 def test_repo_url_no_repo_root(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     with temporary_dir():
         self.assertIsNone(config.repo_url)
Example #29
0
 def test_use_sentry(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config.keychain = mock.Mock()
     self.assertTrue(config.use_sentry)
Example #30
0
 def test_repo_owner_from_repo_info(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"owner": "SFDO-Tooling"}
     self.assertEqual("SFDO-Tooling", config.repo_owner)
Example #31
0
 def test_repo_url_from_repo_info(self):
     config = BaseProjectConfig(BaseGlobalConfig())
     config._repo_info = {"url": "https://github.com/SFDO-Tooling/CumulusCI"}
     self.assertEqual("https://github.com/SFDO-Tooling/CumulusCI", config.repo_url)