예제 #1
0
    def handle(self, updates_filename, *args, **options):
        argv = []
        check_consistency = False
        kwarg = {}
        logging.basicConfig(stream=sys.stderr, level=((5 - int(options['verbosity'])) * 10))
        updatures.UPD_LOG = logging.getLogger("updatures")
        updatures.UPD_LOG.setLevel((5 - (int(options['verbosity']))) * 10)

        logging_curr = updatures.UPD_LOG.getEffectiveLevel()
        updatures.UPD_LOG.error("LOGGING LEVEL TEST: %d" % logging_curr)

        kwarg['sort_output'] = options['sort']
        if options['fakeold']:
            kwarg['fakeold'] = options['fakeold']
        argv += [ updates_filename ]

        for k,v in MODELS_DESCR.iteritems():
            if not v.refs:
                continue
            for kr,r in v.refs.iteritems():
                if r.is_many:
                    updatures.UPD_LOG.error("model: %s, field %s is_many" % (k, kr) )


        updatures_app(argv, **kwarg)
예제 #2
0
    def test_updatures(self):
        updatures.UPD_LOG = logging.getLogger("updatures")
        updatures.UPD_LOG.setLevel(40)

        logging_curr = updatures.UPD_LOG.getEffectiveLevel()
        updatures.UPD_LOG.error("LOGGING LEVEL TEST: %d" % logging_curr)

        test_result = 0
        for test in TEST_LIST:
            output = StringIO.StringIO()
            data_dir = os.path.dirname(os.path.realpath(__file__)) + '/data/'
            # NOTE: sort must be False to be able to upload
            #       fixture to a real environment
            result = updatures_app([data_dir + test + '_new.json'],
                                   output=output,
                                   fakeold=data_dir + test + '_old.json',
                                   sort_output=True)

            exp = file(data_dir + test + '_exp.json', 'r').read()

            if result == 0:
                if output.getvalue() == exp:
                    print "TEST SUCCESS %s" % test
                else:
                    test_result = 1
                    fnameout = data_dir + test + '_out.json'
                    file(fnameout, 'w').write(output.getvalue())
                    print("TEST DIFFER %s, OUTPUT IS SAVED IN %s" %
                          (test, fnameout))
            else:
                exp = json.loads(exp)
                if [result] == exp:
                    print "TEST SUCCESS %s, failure was expected" % test
                else:
                    test_result = 1
                    print(
                        "TEST FAILS executing %s a failure %s was expected"
                        " but %s was returned" % (test, exp, [result]))

        self.assertEqual(test_result, 0)
예제 #3
0
파일: test.py 프로젝트: gem/oq-platform
    def test_updatures(self):
        updatures.UPD_LOG = logging.getLogger("updatures")
        updatures.UPD_LOG.setLevel(40)

        logging_curr = updatures.UPD_LOG.getEffectiveLevel()
        updatures.UPD_LOG.error("LOGGING LEVEL TEST: %d" % logging_curr)

        test_result = 0
        for test in TEST_LIST:
            output = StringIO.StringIO()
            data_dir = os.path.dirname(os.path.realpath(__file__)) + '/data/'
            # NOTE: sort must be False to be able to upload
            #       fixture to a real environment
            result = updatures_app([data_dir + test + '_new.json'],
                                   output=output, fakeold=data_dir + test +
                                   '_old.json', sort_output=True)

            exp = file(data_dir + test + '_exp.json', 'r').read()

            if result == 0:
                if output.getvalue() == exp:
                    print "TEST SUCCESS %s" % test
                else:
                    test_result = 1
                    fnameout = data_dir + test + '_out.json'
                    file(fnameout, 'w').write(output.getvalue())
                    print ("TEST DIFFER %s, OUTPUT IS SAVED IN %s"
                           % (test, fnameout))
            else:
                exp = json.loads(exp)
                if [result] == exp:
                    print "TEST SUCCESS %s, failure was expected" % test
                else:
                    test_result = 1
                    print ("TEST FAILS executing %s a failure %s was expected"
                           " but %s was returned" % (test, exp, [ result ]))

        self.assertEqual(test_result, 0)