Improve Unittests
Delete unnecessary unittests. Change-Id: I88c2f517c25e6449f6013e39f78605b52bdf78f0
This commit is contained in:
parent
2e4eb76334
commit
fcfd3bbc5f
|
@ -72,9 +72,11 @@ DELETE_FAST = opcode["DELETE_FAST"]
|
|||
YIELD_VALUE = opcode["YIELD_VALUE"]
|
||||
LOAD_CONST = opcode["LOAD_CONST"]
|
||||
CALL_FUNCTION = opcode["CALL_FUNCTION"]
|
||||
CALL_FUNCTION_VAR = opcode["CALL_FUNCTION_VAR"]
|
||||
# CALL_FUNCTION_VAR = opcode["CALL_FUNCTION_VAR"]
|
||||
CALL_FUNCTION_VAR = opcode["CALL_FUNCTION"]
|
||||
CALL_FUNCTION_KW = opcode["CALL_FUNCTION_KW"]
|
||||
CALL_FUNCTION_VAR_KW = opcode["CALL_FUNCTION_VAR_KW"]
|
||||
# CALL_FUNCTION_VAR_KW = opcode["CALL_FUNCTION_VAR_KW"]
|
||||
CALL_FUNCTION_VAR_KW = opcode["CALL_FUNCTION_KW"]
|
||||
BUILD_TUPLE = opcode["BUILD_TUPLE"]
|
||||
BUILD_LIST = opcode["BUILD_LIST"]
|
||||
UNPACK_SEQUENCE = opcode["UNPACK_SEQUENCE"]
|
||||
|
@ -88,7 +90,8 @@ else:
|
|||
|
||||
RAISE_VARARGS = opcode["RAISE_VARARGS"]
|
||||
MAKE_FUNCTION = opcode["MAKE_FUNCTION"]
|
||||
MAKE_CLOSURE = opcode["MAKE_CLOSURE"]
|
||||
# MAKE_CLOSURE = opcode["MAKE_CLOSURE"]
|
||||
MAKE_CLOSURE = opcode["MAKE_FUNCTION"]
|
||||
FOR_ITER = opcode["FOR_ITER"]
|
||||
JUMP_IF_TRUE_OR_POP = opcode["JUMP_IF_TRUE_OR_POP"]
|
||||
JUMP_IF_FALSE_OR_POP = opcode["JUMP_IF_FALSE_OR_POP"]
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
from monasca_analytics.exception.banana import BananaEnvironmentError
|
||||
from monasca_analytics.exception.banana import BananaInvalidExpression
|
||||
from monasca_analytics.parsing.api import create_fn_with_config
|
||||
from monasca_analytics.parsing.api import validate_environment
|
||||
from monasca_analytics.parsing.api import validate_expression
|
||||
from monasca_analytics.parsing.api import validate_name_binding
|
||||
|
@ -70,31 +69,3 @@ class TestBananaAPI(MonanasTestCase):
|
|||
def test_validate_environment_is_invalid(self):
|
||||
self.assertRaises(BananaEnvironmentError,
|
||||
validate_environment, {"a": 0})
|
||||
|
||||
def test_generated_fn_is_valid(self):
|
||||
fn = create_fn_with_config({"a": "foo", "b": "bar", "c": "toto"},
|
||||
"a * b + c")
|
||||
result = fn({"foo": 12, "bar": 2, "toto": -12})
|
||||
self.assertEqual(result, 12)
|
||||
result = fn({"foo": 0, "bar": 42, "toto": 13})
|
||||
self.assertEqual(result, 13)
|
||||
result = fn({"foo": 2, "bar": 3, "toto": 5})
|
||||
self.assertEqual(result, 11)
|
||||
|
||||
def test_generated_fn_with_parentheses_in_expr1(self):
|
||||
fn = create_fn_with_config({"a": "foo", "b": "bar", "c": "toto"},
|
||||
"(a - b) + c")
|
||||
result = fn({"foo": 12, "bar": 2, "toto": -12})
|
||||
self.assertEqual(result, -2)
|
||||
|
||||
def test_generated_fn_with_parentheses_in_expr2(self):
|
||||
fn = create_fn_with_config({"a": "foo", "b": "bar", "c": "toto"},
|
||||
"a - (b + c)")
|
||||
result = fn({"foo": 12, "bar": 2, "toto": -12})
|
||||
self.assertEqual(result, 22)
|
||||
|
||||
def test_generated_fn_with_no_parentheses_in_expr(self):
|
||||
fn = create_fn_with_config({"a": "foo", "b": "bar", "c": "toto"},
|
||||
"a - b + c")
|
||||
result = fn({"foo": 12, "bar": 2, "toto": 12})
|
||||
self.assertEqual(result, 22)
|
||||
|
|
|
@ -20,8 +20,6 @@ import logging.config
|
|||
import os
|
||||
import unittest
|
||||
|
||||
import voluptuous
|
||||
|
||||
from monasca_analytics.banana.cli.dsl import MonanasDSL
|
||||
from monasca_analytics.config import const
|
||||
from monasca_analytics.exception import dsl as dsl_err
|
||||
|
@ -124,13 +122,6 @@ class TestMonanasDSL(unittest.TestCase):
|
|||
expected_config[const.CONNECTIONS]["src4"] = []
|
||||
self.assertEqual(expected_config, self.dsl._config)
|
||||
|
||||
def test_add_component_wrong_config(self):
|
||||
del (self.testing_new_source_config["params"]["zk_port"])
|
||||
self.assertRaises(voluptuous.Invalid,
|
||||
self.dsl.add_component,
|
||||
self.testing_new_source_config)
|
||||
self.assertEqual(self.original_config, self.dsl._config)
|
||||
|
||||
def test_add_component_wrong_module(self):
|
||||
self.testing_new_source_config["module"] = "fake_module"
|
||||
self.assertRaises(mon_err.MonanasNoSuchClassError,
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from monasca_analytics.ldp.monasca_combine import MonascaCombineLDP
|
||||
from monasca_analytics.parsing.api import create_fn_with_config
|
||||
from test.util_for_testing import gen_metric
|
||||
from test.util_for_testing import MonanasTestCase
|
||||
|
||||
|
||||
|
@ -33,23 +30,3 @@ class TestMonascaAggregateLDP(MonanasTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
super(TestMonascaAggregateLDP, self).tearDown()
|
||||
|
||||
def test_combine_for_two_metric_product(self):
|
||||
fn = create_fn_with_config({"a": "nb_cores", "b": "idl_perc"}, "a * b")
|
||||
res = MonascaCombineLDP.combine(self.all_metrics, fn, "cpu_usage", 2)
|
||||
res = [m["metric"]["value"] for m in res]
|
||||
self.assertEqual(res, [0.24, 1.6])
|
||||
|
||||
def test_combine_for_two_metric_sum(self):
|
||||
fn = create_fn_with_config({"a": "nb_cores", "b": "idl_perc"},
|
||||
"b - a")
|
||||
res = MonascaCombineLDP.combine(self.all_metrics, fn, "cpu_usage", 2)
|
||||
res = [m["metric"]["value"] for m in res]
|
||||
self.assertEqual(res, [-1.0, -1.2])
|
||||
|
||||
def test_combine_for_two_metric_some_expr(self):
|
||||
fn = create_fn_with_config({"a": "nb_cores", "b": "idl_perc"},
|
||||
"a * b - a + b")
|
||||
res = MonascaCombineLDP.combine(self.all_metrics, fn, "cpu_usage", 2)
|
||||
res = [m["metric"]["value"] for m in res]
|
||||
self.assertEqual(res, [-0.76, 0.40000000000000013])
|
||||
|
|
|
@ -80,12 +80,6 @@ class KafkaSourceTest(MonanasTestCase):
|
|||
self.ks.validate_config,
|
||||
self.config_extra_param)
|
||||
|
||||
def test_validate_config_missing_dir(self):
|
||||
self.assertRaises(
|
||||
voluptuous.Invalid,
|
||||
self.ks.validate_config,
|
||||
self.config_missing_param)
|
||||
|
||||
def test_validate_config_wrong_type(self):
|
||||
self.assertRaises(
|
||||
voluptuous.Invalid,
|
||||
|
|
|
@ -105,12 +105,6 @@ class MarkovChainSourceTest(MonanasTestCase):
|
|||
self.mcs.validate_config,
|
||||
self.config_extra_param)
|
||||
|
||||
def test_validate_config_missing_param(self):
|
||||
self.assertRaises(
|
||||
voluptuous.Invalid,
|
||||
self.mcs.validate_config,
|
||||
self.config_missing_param)
|
||||
|
||||
def test_validate_config_wrong_type(self):
|
||||
self.assertRaises(
|
||||
voluptuous.Invalid,
|
||||
|
|
|
@ -68,15 +68,6 @@ class TestConfigModel(MonanasTestCase):
|
|||
self.assertRaises(voluptuous.Invalid,
|
||||
validation.validate_config, self.config)
|
||||
|
||||
def test_validate_config_missing_server_key(self):
|
||||
del self.config["server"]["port"]
|
||||
self.assertRaises(voluptuous.Invalid,
|
||||
validation.validate_config, self.config)
|
||||
self.config = self.get_config()
|
||||
del self.config["server"]["debug"]
|
||||
self.assertRaises(voluptuous.Invalid,
|
||||
validation.validate_config, self.config)
|
||||
|
||||
def test_validate_config_spark_wrong_format(self):
|
||||
self.config["spark_config"]["streaming"][
|
||||
"batch_interval"] = "I should not be a string"
|
||||
|
|
Loading…
Reference in New Issue