Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix tests

Swifty972cbfc3dee5
diff --git a/autogpt_platform/backend/backend/data/block.py b/autogpt_platform/backend/backend/data/block.py
index 1bf378dc5f..cd94c41325 100644
--- a/autogpt_platform/backend/backend/data/block.py
+++ b/autogpt_platform/backend/backend/data/block.py
@@ -834,9 +834,6 @@ def check_block_same(db_block: BlocksRegistry, local_block: Block) -> bool:
local_block_instance = local_block() # type: ignore
local_block_definition = local_block_instance.to_dict()
db_block_definition = db_block.definition
- logger.info(
- f"Checking if block {local_block_instance.name} is the same as the database block {db_block.name}"
- )
is_same = recursive_json_compare(db_block_definition, local_block_definition)
return is_same
@@ -879,7 +876,6 @@ async def upsert_blocks_change_bulk(blocks: Dict[str, Block]):
"""
db_blocks = await get_block_registry()
block_update = find_delta_blocks(db_blocks, blocks)
- logger.error(f"Upserting {len(block_update)} blocks of {len(blocks)} total blocks")
for block_id, block in block_update.items():
await BlocksRegistry.prisma().upsert(
where={"id": block_id},
diff --git a/autogpt_platform/backend/backend/data/block_test.py b/autogpt_platform/backend/backend/data/block_test.py
index aff481e285..89cbbad433 100644
--- a/autogpt_platform/backend/backend/data/block_test.py
+++ b/autogpt_platform/backend/backend/data/block_test.py
@@ -59,29 +59,29 @@ async def test_recursive_json_compare():
@pytest.mark.asyncio
async def test_check_block_same():
- local_block = PrintToConsoleBlock()
+ local_block_instance = PrintToConsoleBlock()
db_block = BlocksRegistry(
id="f3b1c1b2-4c4f-4f0d-8d2f-4c4f0d8d2f4c",
- name=local_block.__class__.__name__,
- definition=json.dumps(local_block.to_dict()), # type: ignore To much type magic going on here
+ name=local_block_instance.__class__.__name__,
+ definition=json.dumps(local_block_instance.to_dict()), # type: ignore To much type magic going on here
updatedAt=datetime.now(),
)
- assert check_block_same(db_block, local_block)
+ assert check_block_same(db_block, PrintToConsoleBlock) # type: ignore
@pytest.mark.asyncio
async def test_check_block_not_same():
- local_block = PrintToConsoleBlock()
- local_block_data = local_block.to_dict()
+ local_block_instance = PrintToConsoleBlock()
+ local_block_data = local_block_instance.to_dict()
local_block_data["description"] = "Hello, World!"
db_block = BlocksRegistry(
id="f3b1c1b2-4c4f-4f0d-8d2f-4c4f0d8d2f4c",
- name=local_block.__class__.__name__,
+ name=local_block_instance.__class__.__name__,
definition=json.dumps(local_block_data), # type: ignore To much type magic going on here
updatedAt=datetime.now(),
)
- assert not check_block_same(db_block, local_block)
+ assert not check_block_same(db_block, PrintToConsoleBlock) # type: ignore
@pytest.mark.asyncio
@@ -89,10 +89,10 @@ async def test_find_delta_blocks():
now = datetime.now()
store_value_block = StoreValueBlock()
local_blocks = {
- PrintToConsoleBlock().id: PrintToConsoleBlock(),
- ReverseListOrderBlock().id: ReverseListOrderBlock(),
- FileStoreBlock().id: FileStoreBlock(),
- store_value_block.id: store_value_block,
+ PrintToConsoleBlock().id: PrintToConsoleBlock,
+ ReverseListOrderBlock().id: ReverseListOrderBlock,
+ FileStoreBlock().id: FileStoreBlock,
+ store_value_block.id: StoreValueBlock,
}
db_blocks = {
PrintToConsoleBlock().id: BlocksRegistry(
@@ -117,7 +117,7 @@ async def test_find_delta_blocks():
delta_blocks = find_delta_blocks(db_blocks, local_blocks)
assert len(delta_blocks) == 1
assert store_value_block.id in delta_blocks.keys()
- assert delta_blocks[store_value_block.id] == store_value_block
+ assert delta_blocks[store_value_block.id] == StoreValueBlock
@pytest.mark.asyncio
@@ -127,10 +127,10 @@ async def test_find_delta_blocks_block_updated():
print_to_console_block_definition = PrintToConsoleBlock().to_dict()
print_to_console_block_definition["description"] = "Hello, World!"
local_blocks = {
- PrintToConsoleBlock().id: PrintToConsoleBlock(),
- ReverseListOrderBlock().id: ReverseListOrderBlock(),
- FileStoreBlock().id: FileStoreBlock(),
- store_value_block.id: store_value_block,
+ PrintToConsoleBlock().id: PrintToConsoleBlock,
+ ReverseListOrderBlock().id: ReverseListOrderBlock,
+ FileStoreBlock().id: FileStoreBlock,
+ store_value_block.id: StoreValueBlock,
}
db_blocks = {
PrintToConsoleBlock().id: BlocksRegistry(
@@ -155,7 +155,7 @@ async def test_find_delta_blocks_block_updated():
delta_blocks = find_delta_blocks(db_blocks, local_blocks)
assert len(delta_blocks) == 2
assert store_value_block.id in delta_blocks.keys()
- assert delta_blocks[store_value_block.id] == store_value_block
+ assert delta_blocks[store_value_block.id] == StoreValueBlock
assert PrintToConsoleBlock().id in delta_blocks.keys()
@@ -163,9 +163,9 @@ async def test_find_delta_blocks_block_updated():
async def test_find_delta_block_no_diff():
now = datetime.now()
local_blocks = {
- PrintToConsoleBlock().id: PrintToConsoleBlock(),
- ReverseListOrderBlock().id: ReverseListOrderBlock(),
- FileStoreBlock().id: FileStoreBlock(),
+ PrintToConsoleBlock().id: PrintToConsoleBlock,
+ ReverseListOrderBlock().id: ReverseListOrderBlock,
+ FileStoreBlock().id: FileStoreBlock,
}
db_blocks = {
PrintToConsoleBlock().id: BlocksRegistry(