Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mjawadtp committed Jan 6, 2025
1 parent 0fca723 commit 2d14a07
Showing 1 changed file with 3 additions and 54 deletions.
57 changes: 3 additions & 54 deletions cumulusci/tasks/bulkdata/tests/test_select_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,7 @@
PANDAS_AVAILABLE = False


# Test Cases for standard_generate_query
def test_standard_generate_query_with_default_record_declaration():
select_operator = SelectOperationExecutor(SelectStrategy.STANDARD)
sobject = "Account" # Assuming Account has a declaration in DEFAULT_DECLARATIONS
limit = 5
offset = 2
query, fields = select_operator.select_generate_query(
sobject=sobject, fields=[], user_filter="", limit=limit, offset=offset
)

assert "WHERE" in query # Ensure WHERE clause is included
assert f"LIMIT {limit}" in query
assert f"OFFSET {offset}" in query
assert fields == ["Id"]


def test_standard_generate_query_without_default_record_declaration():
def test_standard_generate_query_without_filter():
select_operator = SelectOperationExecutor(SelectStrategy.STANDARD)
sobject = "Contact" # Assuming no declaration for this object
limit = 3
Expand All @@ -49,7 +33,6 @@ def test_standard_generate_query_without_default_record_declaration():
sobject=sobject, fields=[], user_filter="", limit=limit, offset=offset
)

assert "WHERE" not in query # No WHERE clause should be present
assert f"LIMIT {limit}" in query
assert "OFFSET" not in query
assert fields == ["Id"]
Expand All @@ -72,23 +55,7 @@ def test_standard_generate_query_with_user_filter():
assert fields == ["Id"]


# Test Cases for random generate query
def test_random_generate_query_with_default_record_declaration():
select_operator = SelectOperationExecutor(SelectStrategy.RANDOM)
sobject = "Account" # Assuming Account has a declaration in DEFAULT_DECLARATIONS
limit = 5
offset = 2
query, fields = select_operator.select_generate_query(
sobject=sobject, fields=[], user_filter="", limit=limit, offset=offset
)

assert "WHERE" in query # Ensure WHERE clause is included
assert f"LIMIT {limit}" in query
assert f"OFFSET {offset}" in query
assert fields == ["Id"]


def test_random_generate_query_without_default_record_declaration():
def test_random_generate_query():
select_operator = SelectOperationExecutor(SelectStrategy.RANDOM)
sobject = "Contact" # Assuming no declaration for this object
limit = 3
Expand All @@ -97,7 +64,6 @@ def test_random_generate_query_without_default_record_declaration():
sobject=sobject, fields=[], user_filter="", limit=limit, offset=offset
)

assert "WHERE" not in query # No WHERE clause should be present
assert f"LIMIT {limit}" in query
assert "OFFSET" not in query
assert fields == ["Id"]
Expand Down Expand Up @@ -209,23 +175,7 @@ def test_random_post_process_with_no_records():
assert error_message == f"No records found for {sobject} in the target org."


# Test Cases for Similarity Generate Query
def test_similarity_generate_query_with_default_record_declaration():
select_operator = SelectOperationExecutor(SelectStrategy.SIMILARITY)
sobject = "Account" # Assuming Account has a declaration in DEFAULT_DECLARATIONS
limit = 5
offset = 2
query, fields = select_operator.select_generate_query(
sobject, ["Name"], [], limit, offset
)

assert "WHERE" in query # Ensure WHERE clause is included
assert fields == ["Id", "Name"]
assert f"LIMIT {limit}" in query
assert f"OFFSET {offset}" in query


def test_similarity_generate_query_without_default_record_declaration():
def test_similarity_generate_query_no_nesting():
select_operator = SelectOperationExecutor(SelectStrategy.SIMILARITY)
sobject = "Contact" # Assuming no declaration for this object
limit = 3
Expand All @@ -234,7 +184,6 @@ def test_similarity_generate_query_without_default_record_declaration():
sobject, ["Name"], [], limit, offset
)

assert "WHERE" not in query # No WHERE clause should be present
assert fields == ["Id", "Name"]
assert f"LIMIT {limit}" in query
assert "OFFSET" not in query
Expand Down

0 comments on commit 2d14a07

Please sign in to comment.