-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Cases for UE Generation Handler #11
Open
WaterMenon09
wants to merge
21
commits into
lf-connectivity:main
Choose a base branch
from
tanzim10:Test_UEGeneration_Handler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ce31359
Fixed requirements issue
tanzim10 73e1546
added handler to the mobility directory
WaterMenon09 c4d379a
added blank test file for handler
WaterMenon09 bb87c98
fixed import issue in handler
WaterMenon09 046535c
Deleted some dump files
tanzim10 a4b69ac
CCO file issue resolved
tanzim10 5cffe2e
Fixed CCO Notebook
tanzim10 5397fa5
Kept the changes in the notebook locally
tanzim10 c912b3b
Updated requirements issue from CI test
tanzim10 9fb5d73
Fixed scikit learn issue
tanzim10 f51a6b6
Merge pull request #1 from tanzim10/tanzim-patch-1
tanzim10 92bd8af
Merge branch 'lf-connectivity:main' into main
tanzim10 fafa83d
changed location for handler and added unit tests
WaterMenon09 240a7cb
fixed hanlder position
WaterMenon09 1484c90
fixed import locations
WaterMenon09 783ceef
used black on test & helper files
WaterMenon09 4239ca5
fixed name and removed redundant code in test
WaterMenon09 c2c91fb
added docstring
WaterMenon09 10b72e0
added HOW TO RUN comment
WaterMenon09 3b428ec
blacked
WaterMenon09 a6a4815
fixed typo
WaterMenon09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
radp/digital_twin/mobility/tests/test_UETracksGenerationHelper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import unittest | ||
from services.ue_tracks_generation.ue_tracks_generation_helper import UETracksGenerationHelper | ||
from radp.common import constants | ||
|
||
|
||
class TestUETracksGenerationHelper(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# Mock data for testing | ||
self.job_data = { | ||
constants.SIMULATION_ID: "1234", | ||
constants.UE_TRACKS_GENERATION: { | ||
constants.PARAMS: { | ||
constants.SIMULATION_TIME_INTERVAL: 5, | ||
constants.NUM_TICKS: 100, | ||
constants.NUM_BATCHES: 10, | ||
constants.UE_CLASS_DISTRIBUTION: { | ||
constants.STATIONARY: {constants.COUNT: 10, constants.VELOCITY: 0.0, constants.VELOCITY_VARIANCE: 0.0}, | ||
constants.PEDESTRIAN: {constants.COUNT: 20, constants.VELOCITY: 1.2, constants.VELOCITY_VARIANCE: 0.1}, | ||
constants.CYCLIST: {constants.COUNT: 15, constants.VELOCITY: 5.5, constants.VELOCITY_VARIANCE: 0.5}, | ||
constants.CAR: {constants.COUNT: 5, constants.VELOCITY: 20.0, constants.VELOCITY_VARIANCE: 1.0}, | ||
}, | ||
constants.LON_LAT_BOUNDARIES: { | ||
constants.MIN_LAT: -90.0, | ||
constants.MAX_LAT: 90.0, | ||
constants.MIN_LON: -180.0, | ||
constants.MAX_LON: 180.0, | ||
}, | ||
constants.GAUSS_MARKOV_PARAMS: { | ||
constants.ALPHA: 0.8, | ||
constants.VARIANCE: 0.1, | ||
constants.RNG_SEED: 42, | ||
constants.LON_X_DIMS: "100", | ||
constants.LON_Y_DIMS: "100", | ||
}, | ||
}, | ||
constants.OUTPUT_FILE_PREFIX: "sim_output_" | ||
} | ||
} | ||
|
||
def test_get_simulation_id(self): | ||
self.assertEqual(UETracksGenerationHelper.get_simulation_id(self.job_data), "1234") | ||
|
||
def test_get_ue_tracks_generation_parameters(self): | ||
params = UETracksGenerationHelper.get_ue_tracks_generation_parameters(self.job_data) | ||
self.assertEqual(params[constants.NUM_TICKS], 100) | ||
self.assertEqual(params[constants.NUM_BATCHES], 10) | ||
|
||
def test_get_output_file_prefix(self): | ||
self.assertEqual(UETracksGenerationHelper.get_output_file_prefix(self.job_data), "sim_output_") | ||
|
||
def test_get_ue_class_distribution_count(self): | ||
counts = UETracksGenerationHelper.get_ue_class_distribution_count(self.job_data[constants.UE_TRACKS_GENERATION][constants.PARAMS]) | ||
self.assertEqual(counts, (10, 20, 15, 5)) | ||
|
||
def test_get_ue_class_distribution_velocity(self): | ||
velocities = UETracksGenerationHelper.get_ue_class_distribution_velocity( | ||
self.job_data[constants.UE_TRACKS_GENERATION][constants.PARAMS], 5 | ||
) | ||
self.assertEqual(velocities, (0.0, 6.0, 27.5, 100.0)) | ||
|
||
def test_get_lat_lon_boundaries(self): | ||
boundaries = UETracksGenerationHelper.get_lat_lon_boundaries( | ||
self.job_data[constants.UE_TRACKS_GENERATION][constants.PARAMS] | ||
) | ||
self.assertEqual(boundaries, (-90.0, 90.0, -180.0, 180.0)) | ||
|
||
def test_get_gauss_markov_alpha(self): | ||
alpha = UETracksGenerationHelper.get_gauss_markov_alpha(self.job_data[constants.UE_TRACKS_GENERATION][constants.PARAMS]) | ||
self.assertEqual(alpha, 0.8) | ||
|
||
''' | ||
if __name__ == '__main__': | ||
unittest.main() | ||
''' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may delete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed the redundant comments, added the docstring and added the CLI code to run in the docstring under |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename file as
test_ue_tracks_generation_helper.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed the file