Ensure UnitTest coverage at least 85% #16
Closed
opened 2025-04-23 12:26:12 +00:00 by stanislav.hejny
·
3 comments
No Branch/Tag Specified
develop
api_docs
feat/63-cleverswarm-unidirectional
feat/61-multi-user-support
feat-58-backpressure-reactive-streams
fix/bp-report
otel-demo
cleverbrag-integration-2
cleverbrag-integration
code-formatting
errors-as-json
config-documemntation
fix-version
feat/#1
fix_testing
feat/readme
feat#2
feat#64
No results found.
Labels
Clear labels
Blocked
Needs feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Sprint May 15th - 28th
Assignees
aleenaumair (Aleena Umair)
argocd
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
mngrif (Michael Griffith)
org.clevermicro (System User)
org.cleverswarm (System User)
org.inf-cd
salcedo (Brian Salcedo)
stanislav.hejny (Stanislav Hejny)
Clear assignees
Notifications
Due Date
No due date set.
Blocks
Depends on
You do not have permission to read 2 dependencies
#47 Implement unit test
clevermicro/amq-adapter-python
Reference: clevermicro/amq-adapter-python#16
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ref epic: CleverSwarm Onboarding #58
Ensure proper unit test coverage, currently test coverage is 42%
@stanislav.hejny @aleenaumair
This ticket is also lacking priority (which needs to be set to backlog) as well as a milestone. Make sure this is fixed before moving forward. I MoSCoWed it though generally that would wait until the ticket is complete.
Hi,
Just want to reference a previous conversation around this, for documenting it; we discussed how setting Priority: Backlog overrides the Priority:High/ Med/ Low. So, until 'Backlog' gets moved to 'Status' label, we will be assigning high/med/low priority and keeping state 'unverified/verified' to depict tickets that are not 'In Progress' yet, meaning that they are still part of the backlog.
Please let us know as soon as the Backlog label is moved to status queue, so that we can start adding that to the tickets. @freemo
In addition, the 'Type' label also needs editing, to differentiate type (task, epic and legendary) and category (bug, feature, config, documentation, support, discussion).
cc: @eugen.thaci
Currently, Stan and I are working on the unit test. The estimated points are 8, but it actually taking much longer than it. In theory, writing unit tests should be easy since all the features are implemented, and all you need to do is to write code to ensure the functionality of them. But in reality, bugs may be found and refactor may be required for easy testing.
In today's case, I'm writing unit tests for
amqp/adapter/pydantic_serializer.py. As suggested by Aleena, I downloaded cursor ai editor and started generating unit tests (currently with a free 7-day trial). Generating unit test is fast, review the generated code is also not hard, everything looks good to me. At this point, including download, it takes less than 5 minutes. For the rest of the day, I'm fixing the code so the unit test can pass.I run the unit test, it failed, I start fixing it. The first problem is related to how python finds classes. For the pydantic serializer, we need to know the class before we deserialize it. The code records the class name before the actual data so we know which class to use when deserializing. However, in python, a class name is not enough to locate a class, you also need a module path. This is relatively easy to fix since llm gives me the correct code to do that.
I rerun the test again, now the deserialization is failing, due to broken data. I added several print statements to see what data is being fed to the method, and noticed an issue with serialization. The serializer uses comma to separate key value pairs, which is generally fine until your value can also contain comma. For example, dict and list. When deserializing, the input string will be split by comma, this will break dick and list, causing an error. I fixed it by using JSON.
I rerun the test again, and got a new error. But now the error is triggered by the test code, saying a field should be an object, but after deserialization, it becomes a dict. In the serializer, I saw code that handles the nested model specifically, but it doesn't run. After some debugging, I found the issue caused by
obj.model_dump(). This pydantic method will export the model, but turning everything into dict. In this process, nested models will be also converted to dict, making the code failed to check if it's a nested model or not. By not using the converted value, we can pull the original value using the field name, and continue the process. However, in the deserializer, the input string doesn't give anything about the type, so we need to look up the type in the class. This is where the llm doesn't help: with python 3.9, you have an old way to do that; with python 3.10, you have a new way to do that. And with pydantic v1 and v2, there are also different APIs. LLM's output failed to keep up to date, and I spend a bunch of time to figure out how python's type system working, how pydantic helps on that, and the most time-consuming part, how to handle union type likeFoo | None.At the end of the day, everything is fixed and the coverage for that file is 89%, and the overall coverage rate is bumped by 3%. But this process takes me a whole day, largely due to my unfamiliarity with python and related library. I expect this should be improved as I keep working on the codebase and gain more and more experience with python, the codebase and related libraries.