コード例 #1
0
ファイル: test_config.py プロジェクト: pritishmishra/xmake
    def test_add_import_repo(self):
        nx_repos = ['http://nexus1', 'http://nexus2']
        docker_repos = ['http://docker1', 'http://docker2']

        cfg = BuildConfig()

        # non productive / non release build
        cfg._import_repos = {}
        cfg.add_import_repo(nx_repos[0])
        cfg.add_import_repo(nx_repos[1])
        cfg.add_import_repo(docker_repos[0], DOCKERREPO)
        cfg.add_import_repo(docker_repos[1], DOCKERREPO)
        assert cfg._import_repos[COMMONREPO] == nx_repos
        assert cfg._import_repos[DOCKERREPO] == docker_repos

        # productive build
        cfg._import_repos = {}
        cfg._productive = True
        cfg.add_import_repo(nx_repos[0])
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(nx_repos[1])
        cfg.add_import_repo(docker_repos[0], DOCKERREPO)
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(docker_repos[1], DOCKERREPO)

        assert cfg._import_repos[COMMONREPO] == [nx_repos[0]]
        assert cfg._import_repos[DOCKERREPO] == [docker_repos[0]]

        # xmake-ldi release build
        cfg._import_repos = {}
        cfg._productive = False
        cfg._release = 'release'
        cfg.add_import_repo(nx_repos[0])
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(nx_repos[1])
        cfg.add_import_repo(docker_repos[0], DOCKERREPO)
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(docker_repos[1], DOCKERREPO)
        assert cfg._import_repos[COMMONREPO] == [nx_repos[0]]
        assert cfg._import_repos[DOCKERREPO] == [docker_repos[0]]

        # xmake-dev release build
        cfg._import_repos = {}
        cfg._productive = True
        cfg._release = None
        cfg._version_suffix = None
        cfg.add_import_repo(nx_repos[0])
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(nx_repos[1])
        cfg.add_import_repo(docker_repos[0], DOCKERREPO)
        with self.assertRaisesRegexp(XmakeException, 'only one repository url is authorized'):
            cfg.add_import_repo(docker_repos[1], DOCKERREPO)
        assert cfg._import_repos[COMMONREPO] == [nx_repos[0]]
        assert cfg._import_repos[DOCKERREPO] == [docker_repos[0]]
コード例 #2
0
ファイル: maven.py プロジェクト: pritishmishra/xmake
    def test_check_version_compliance(self):

        matrix = ({"release":"indirect-shipment", "version": "0.6.3.25", "assert": True, "returnedValue": "0.6.3.25"},
                    {"release":"direct-shipment", "version": "1.0.3", "assert": True, "returnedValue": "1.0.3"},
                    {"release":"direct-shipment", "version": "v1.0.3", "assert": False, "returnedValue": "v1.0.3"},
                    {"release":"direct-shipment", "version": "0.6.3", "assert": False, "returnedValue": "0.6.3"},
                    {"release":"direct-shipment", "version": "1.2", "assert": False, "returnedValue": "1.2"},
                    {"release":"direct-shipment", "version": "1.2.3-sap", "assert": False, "returnedValue": "1.2.3-sap"},
                    {"release":"direct-shipment", "version": "1.2.3.sap", "assert": False, "returnedValue": "1.2.3.sap"},
                    {"release":"direct-shipment", "version": "1.2.3-sap-01", "assert": False, "returnedValue": "1.2.3-sap-01"},
                    {"release":"direct-shipment", "version": "1.2.3.sap-01", "assert": False, "returnedValue": "1.2.3.sap-01"},
                    {"release":"direct-shipment", "version": "300.2.1", "assert": True, "returnedValue": "300.2.1"},
                    {"release":"indirect-shipment", "version": "v1.0.3", "assert": False, "returnedValue": "v1.0.3"},
                    {"release":"indirect-shipment", "version": "1.2", "assert": True, "returnedValue": "1.2.0"},
                    {"release":"indirect-shipment", "version": "1.2.3-sap", "assert": True, "returnedValue": "1.2.3-sap"},
                    {"release":"indirect-shipment", "version": "1.2.3.sap", "assert": True, "returnedValue": "1.2.3.sap"},
                    {"release":"indirect-shipment", "version": "1.2.3-sap-01", "assert": True, "returnedValue": "1.2.3-sap-01"},
                    {"release":"indirect-shipment", "version": "1.2.3.sap-01", "assert": True, "returnedValue": "1.2.3.sap-01"},
                    {"release":"indirect-shipment", "version": "0.6.3", "assert": True, "returnedValue": "0.6.3"},
                    {"release":"indirect-shipment", "version": "0.6.3.25", "assert": True, "returnedValue": "0.6.3.25"},
                    {"release":"indirect-shipment", "version": "0.6.3-25", "assert": True, "returnedValue": "0.6.3"},
                  {"release":"indirect-shipment", "version": "9.5", "assert": True, "returnedValue": "9.5.0"},
                  {"release":"indirect-shipment", "version": "9.5-02", "assert": True, "returnedValue": "9.5.0"},
                  {"release":"indirect-shipment", "version": "23.502", "assert": True, "returnedValue": "23.502.0"},
                  {"release":"indirect-shipment", "version": "9.5-sap-02", "assert": True, "returnedValue": "9.5.0-sap-02"},
                  {"release":"indirect-shipment", "version": "1-sap.02", "assert": True, "returnedValue": "1.0.0-sap.02"},
                  {"release":"indirect-shipment", "version": "1.sap.02", "assert": True, "returnedValue": "1.0.0-sap.02"},
                  {"release":"indirect-shipment", "version": "1.1-sap.02", "assert": True, "returnedValue": "1.1.0-sap.02"},
                  {"release":"indirect-shipment", "version": "1.1.sap.02", "assert": True, "returnedValue": "1.1.0-sap.02"},

                  {"release":"indirect-shipment", "version": "1-sap", "assert": True, "returnedValue": "1.0.0-sap"},
                  {"release":"indirect-shipment", "version": "1.sap", "assert": True, "returnedValue": "1.0.0-sap"},
                  {"release":"indirect-shipment", "version": "1.1-sap", "assert": True, "returnedValue": "1.1.0-sap"},
                  {"release":"indirect-shipment", "version": "1.1.sap", "assert": True, "returnedValue": "1.1.0-sap"},
                  {"release":"indirect-shipment", "version": "0.1.110-sap", "assert": True, "returnedValue": "0.1.110-sap"},
                  {"release":"indirect-shipment", "version": "0.1.110.sap", "assert": True, "returnedValue": "0.1.110.sap"},

                  {"release":"indirect-shipment", "version": "1.2", "assert": True, "returnedValue": "1.2.0"},
                  {"release":"indirect-shipment", "version": "1.2.0.2", "assert": True, "returnedValue": "1.2.0.2"},
                  {"release":"indirect-shipment", "version": "2.18.2.v201304210537-sap-02", "assert": True, "returnedValue": "2.18.2.v201304210537-sap-02"},
                  {"release":"indirect-shipment", "version": "2.18.2.201304210537-sap-02", "assert": True, "returnedValue": "2.18.2.201304210537-sap-02"},
                  {"release":"indirect-shipment", "version": "2.18.2-201304210537-sap-02", "assert": True, "returnedValue": "2.18.2-201304210537-sap-02"},
                  {"release":"indirect-shipment", "version": "1.02", "assert": True, "returnedValue": "1.02.0"},
                  {"release":"indirect-shipment", "version": "300.2.1", "assert": True, "returnedValue": "300.2.1"},
                  {"release":"indirect-shipment", "version": "300.02", "assert": True, "returnedValue": "300.02.0"}

                )


        cfg =  BuildConfig()
        cfg._genroot_dir = r"C:\Users\i079877\TEMP"
        m= maven.build(cfg)

        for elem in matrix :
            cfg.set_base_version(elem["version"])
            cfg._release = elem["release"]
            status = m._check_project_version_compliance()
            self.assertEqual(status[0], elem["assert"], "expected {} but got {} for input {}/{}".format(elem["assert"], status[0] , elem["release"], elem["version"]))
            self.assertEqual(cfg.base_version(), elem["returnedValue"],"expected {} but got {} for input {}/{}".format(elem["returnedValue"], cfg.base_version(), elem["release"], elem["version"]))
コード例 #3
0
ファイル: test_config.py プロジェクト: pritishmishra/xmake
    def test_import_repos(self):
        nx_repos = ['http://nexus1', 'http://nexus2', 'http://nexus3']
        docker_repos = ['http://docker1', 'http://docker2', 'http://docker3']
        npm_repos = ['http://npm1', 'http://npm2', 'http://npm3']


        # no repos
        cfg = BuildConfig()
        cfg._import_repos = {
            COMMONREPO: None,
            DOCKERREPO: None,
            NPMREPO: None
        }
        assert cfg.import_repos() == None
        assert cfg.import_repos(t=DOCKERREPO) == None
        assert cfg.import_repos(t=NPMREPO) == None

        # no repos productive build
        cfg._productive = True
        assert cfg.import_repos() == None
        assert cfg.import_repos(t=DOCKERREPO) == None
        assert cfg.import_repos(t=NPMREPO) == None

        # no repos
        cfg = BuildConfig()
        cfg._import_repos = {
            COMMONREPO: [],
            DOCKERREPO: [],
            NPMREPO: []
        }
        assert cfg.import_repos() == []
        assert cfg.import_repos(t=DOCKERREPO) == []
        assert cfg.import_repos(t=NPMREPO) == []

        # no repos productive build
        cfg._productive = True
        assert cfg.import_repos() == []
        assert cfg.import_repos(t=DOCKERREPO) == []
        assert cfg.import_repos(t=NPMREPO) == []

        cfg = BuildConfig()
        cfg._import_repos = {
            COMMONREPO: nx_repos,
            DOCKERREPO: docker_repos,
            NPMREPO: npm_repos
        }
        # non productive / non release build
        assert cfg.import_repos() == nx_repos
        assert cfg.import_repos(t=DOCKERREPO) == docker_repos
        assert cfg.import_repos(t=NPMREPO) == npm_repos

        # productive build
        cfg._productive = True
        assert cfg.import_repos() == [nx_repos[0]]
        assert cfg.import_repos(t=DOCKERREPO) == [docker_repos[0]]
        assert cfg.import_repos(t=NPMREPO) == [npm_repos[0]]

        # xmake-ldi release build
        cfg._productive = False
        cfg._release = 'release'
        assert cfg.import_repos() == [nx_repos[0]]
        assert cfg.import_repos(t=DOCKERREPO) == [docker_repos[0]]
        assert cfg.import_repos(t=NPMREPO) == [npm_repos[0]]

        # xmake-dev release build
        cfg._productive = True
        cfg._release = None
        cfg._version_suffix = None
        assert cfg.import_repos() == [nx_repos[0]]
        assert cfg.import_repos(t=DOCKERREPO) == [docker_repos[0]]
        assert cfg.import_repos(t=NPMREPO) == [npm_repos[0]]