Skip to content

Commit

Permalink
Add unit test for constant value expression
Browse files Browse the repository at this point in the history
  • Loading branch information
xzdandy committed Sep 11, 2023
1 parent a196a44 commit 41cacf7
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/unit_tests/expression/test_constant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding=utf-8
# Copyright 2018-2023 EvaDB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

import pandas as pd

from evadb.expression.constant_value_expression import ConstantValueExpression
from evadb.models.storage.batch import Batch


class ConstantExpressionsTest(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def test_constant_without_input_relationship(self):
const_expr = ConstantValueExpression(1)
self.assertEqual([1], const_expr.evaluate(None).frames[0].tolist())

def test_constant_with_input_relationship(self):
const_expr = ConstantValueExpression(1)
input_size = 10
self.assertEqual(
[1] * input_size,
const_expr.evaluate(Batch(pd.DataFrame([0] * input_size)))
.frames[0]
.tolist(),
)

0 comments on commit 41cacf7

Please sign in to comment.