示例#1
0
class JavaClientTests(unittest.TestCase):
    def setUp(self):
        self.client = self.__get_client__()
        self.client.initialize()
        self.service_name = os.path.join(os.getcwd(), "../thrift/services/", "wizecommerce.services.example.thrift")


    def __get_client__(self):
        self.config = Config()
        compiler = None
        for item in self.config.get_thrift_option("compilers"):
            compiler = ThriftCompiler(item)
            compiler.postfix = ""
            break

        return JavaClient([], compiler)

    @httprettified
    def test_check_version_pretty(self):
        self.config.set_local(False)
        expected = False
        expected_url = 'http://nexus.corp.nextag.com:8081/content/repositories/releases/com/wizecommerce/data/tag-client/0.0.13/tag-client-0.0.13.jar'
        HTTPretty.register_uri(HTTPretty.GET, expected_url, body="Hello")
        check_value = self.client.check_version(groupId='com.wizecommerce.data', artifactId='tag-client',
                                                version='0.0.13')
        self.failUnlessEqual(check_value, expected)
        check_value = self.client.check_version(groupId='com.wizecommerce.data', artifactId='tag-client',
                                                version='X.Y.ZZ')
        expected = True
        self.failUnlessEqual(check_value, expected)


    @httprettified
    def test_check_shaded_version_pretty(self):
        self.config.set_local(False)
        expected = False
        expected_url = 'http://crepo.corp.nextag.com/repo/components/com/wizecommerce/data/tag-client-shaded/0.0.13/tag-client-shaded-0.0.13.jar'
        HTTPretty.register_uri(HTTPretty.GET, expected_url, body="Hello")
        check_value_shaded = self.client.check_shaded_version(groupId='com.wizecommerce.data', artifactId='tag-client',
                                                              version='0.0.13')
        print check_value_shaded
        print expected

        assert check_value_shaded == expected
        self.failUnlessEqual(check_value_shaded, expected)

        check_value_shaded = self.client.check_shaded_version(groupId='com.wizecommerce.data', artifactId='tag-client',
                                                              version='X.Y.ZZ')
        expected = True
        assert check_value_shaded == expected

    def tearDown(self):
        self.config.reset_configuration()
示例#2
0
class BaseClientTests(unittest2.TestCase):
    def setUp(self):
        self.dict = {}
        self.client = self.__get_client__()
        # self.client.initialize()
        self.service_name = os.path.join(
            os.getcwd(), "../thrift/services/",
            "wizecommerce.services.example.thrift")

    def __get_client__(self):
        self.config = Config()
        self.config.reset_configuration()
        compiler = None
        for item in self.config.get_thrift_option("compilers"):
            compiler = ThriftCompiler(item)
        return Client([], compiler)

    def test_not_implemented_methods(self):
        client = self.__get_client__()
        self.assertRaises(NotImplementedError, client.__build_dependency__,
                          "DummyFile")
        self.assertRaises(NotImplementedError, client.__build_client__,
                          "service")
        self.assertRaises(NotImplementedError, client.check_version,
                          **self.dict)
        self.assertRaises(NotImplementedError,
                          client.__deploy_production_artifact__, self.dict,
                          "boo")
        self.assertRaises(NotImplementedError,
                          client.__deploy_local_artifact__, self.dict, "boo")
        self.assertRaises(NotImplementedError, client.finalize)
        self.assertRaises(NotImplementedError, client.initialize)

    def test_deploy_object(self):
        client = self.__get_client__()
        self.config.set_local(True)
        self.assertRaisesRegexp(NotImplementedError,
                                ".*Deploy Local Artifact.*",
                                client.deploy_object, self.dict, "dummy")
        client = self.__get_client__()
        self.config.set_local(False)
        self.assertRaisesRegexp(NotImplementedError,
                                ".*Deploy Production Artifact.*",
                                client.deploy_object, self.dict, "dummy")

    def test_sandbox(self):
        client = self.__get_client__()
        client.set_sandbox("DummySandbox")
        self.assertEquals("DummySandbox", client.get_sandbox())
示例#3
0
class BaseClientTests(unittest2.TestCase):
    def setUp(self):
        self.dict = {}
        self.client = self.__get_client__()
        # self.client.initialize()
        self.service_name = os.path.join(os.getcwd(), "../thrift/services/", "wizecommerce.services.example.thrift")

    def __get_client__(self):
        self.config = Config()
        self.config.reset_configuration()
        compiler = None
        for item in self.config.get_thrift_option("compilers"):
            compiler = ThriftCompiler(item)
        return Client([], compiler)

    def test_not_implemented_methods(self):
        client = self.__get_client__()
        self.assertRaises(NotImplementedError, client.__build_dependency__, "DummyFile")
        self.assertRaises(NotImplementedError, client.__build_client__, "service")
        self.assertRaises(NotImplementedError, client.check_version, **self.dict)
        self.assertRaises(NotImplementedError, client.__deploy_production_artifact__, self.dict, "boo")
        self.assertRaises(NotImplementedError, client.__deploy_local_artifact__, self.dict, "boo")
        self.assertRaises(NotImplementedError, client.finalize)
        self.assertRaises(NotImplementedError, client.initialize)

    def test_deploy_object(self):
        client = self.__get_client__()
        self.config.set_local(True)
        self.assertRaisesRegexp(
            NotImplementedError, ".*Deploy Local Artifact.*", client.deploy_object, self.dict, "dummy"
        )
        client = self.__get_client__()
        self.config.set_local(False)
        self.assertRaisesRegexp(
            NotImplementedError, ".*Deploy Production Artifact.*", client.deploy_object, self.dict, "dummy"
        )

    def test_sandbox(self):
        client = self.__get_client__()
        client.set_sandbox("DummySandbox")
        self.assertEquals("DummySandbox", client.get_sandbox())
示例#4
0
def main():
    parser = argparse.ArgumentParser(description='Client Generation Script')
    parser.add_argument('--local', action="store_true", dest="local", default=False, help="Enables Local Mode")
    parser.add_argument('--profile', action="store_true", dest="profile", default=False, help="Profiles App")
    parser.add_argument("--docOnly", action="store_true", dest="doc_only", default=False)
    parser.add_argument('--ruby', action="store_true", dest="ruby", default=False,
                        help="Enables RubyMode, default is Ruby + Java (Local Mode Only)")
    parser.add_argument('--java', action="store_true", dest="java", default=False,
                        help="Enables JavaMode, default is Ruby + Java  (Local Mode Only) ")
    parser.add_argument('--thrift-file', action="store", dest="thrift_file", type=str,
                        help="Override list of services, and use the one specified (Local Mode Only)\nThis overrides vcs intelligence")
    parser.add_argument('--config', action="store", dest="config", type=str,
                        help="Override default config file and specify your own yaml config")
    parser.add_argument('--compilers', action="store_true", dest="compilers", default=False,
                        help="will list all supported compilers. (Not fully supported)")
    parser.add_argument('--set-compiler', action="store", dest="compiler", type=str,
                        help="accepts a valid compiler name defined in the yaml config.")



    args = parser.parse_args()
    if args.config is None:
        config = Config()
    else:
        config = Config(args.config)

    config.set_local(args.local)

    if args.thrift_file is not None:
        config.set_service_override(os.path.basename(args.thrift_file))

    if args.thrift_file is not None:
        config.set_local(True)

    if args.compilers:
        display_compilers()

    if args.compiler is not None:
        set_compiler(args.compiler)

    publish_client = PublishClient()

    ## these options can only be used in conjunction with local mode
    if config.is_local():
        if args.ruby and args.java:
            print "WARNING: you really should use rubyOverride or JavaOverride, " \
                  "if you pass both it can will fall back on default behavior.  (ie. omit both of them)"
        elif args.ruby:
            config.set_languages({"ruby": True})
        elif args.java:
            config.set_languages({"java": True})

    if args.doc_only:
        config.set_languages({})
        config.is_doc_enabled = True

    if args.profile:
        import cProfile

        cProfile.run('profileProject()')
    else:
        # Create Repo Structure
        publish_client.create_structure()
        # Loop through all of our services check for updates
        publish_client.process_thrift_services()
示例#5
0
class JavaClientTests(unittest.TestCase):
    def setUp(self):
        self.client = self.__get_client__()
        self.client.initialize()
        self.service_name = os.path.join(
            os.getcwd(), "../thrift/services/",
            "wizecommerce.services.example.thrift")

    def __get_client__(self):
        self.config = Config()
        compiler = None
        for item in self.config.get_thrift_option("compilers"):
            compiler = ThriftCompiler(item)
            compiler.postfix = ""
            break

        return JavaClient([], compiler)

    @httprettified
    def test_check_version_pretty(self):
        self.config.set_local(False)
        expected = False
        expected_url = 'http://nexus.corp.nextag.com:8081/content/repositories/releases/com/wizecommerce/data/tag-client/0.0.13/tag-client-0.0.13.jar'
        HTTPretty.register_uri(HTTPretty.GET, expected_url, body="Hello")
        check_value = self.client.check_version(
            groupId='com.wizecommerce.data',
            artifactId='tag-client',
            version='0.0.13')
        self.failUnlessEqual(check_value, expected)
        check_value = self.client.check_version(
            groupId='com.wizecommerce.data',
            artifactId='tag-client',
            version='X.Y.ZZ')
        expected = True
        self.failUnlessEqual(check_value, expected)

    @httprettified
    def test_check_shaded_version_pretty(self):
        self.config.set_local(False)
        expected = False
        expected_url = 'http://crepo.corp.nextag.com/repo/components/com/wizecommerce/data/tag-client-shaded/0.0.13/tag-client-shaded-0.0.13.jar'
        HTTPretty.register_uri(HTTPretty.GET, expected_url, body="Hello")
        check_value_shaded = self.client.check_shaded_version(
            groupId='com.wizecommerce.data',
            artifactId='tag-client',
            version='0.0.13')
        print check_value_shaded
        print expected

        assert check_value_shaded == expected
        self.failUnlessEqual(check_value_shaded, expected)

        check_value_shaded = self.client.check_shaded_version(
            groupId='com.wizecommerce.data',
            artifactId='tag-client',
            version='X.Y.ZZ')
        expected = True
        assert check_value_shaded == expected

    def tearDown(self):
        self.config.reset_configuration()