MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_device

Function test_device

chirpstack/src/api/device.rs:1313–1854  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1311
1312 #[tokio::test]
1313 async fn test_device() {
1314 let _guard = test::prepare().await;
1315
1316 // setup admin user
1317 let u = user::User {
1318 is_admin: true,
1319 is_active: true,
1320 email: "admin@admin".into(),
1321 email_verified: true,
1322 ..Default::default()
1323 };
1324 let u = user::create(u).await.unwrap();
1325
1326 // create tenant
1327 let t = tenant::create(tenant::Tenant {
1328 name: "test-tenant".into(),
1329 can_have_gateways: true,
1330 max_gateway_count: 10,
1331 ..Default::default()
1332 })
1333 .await
1334 .unwrap();
1335
1336 // create application
1337 let app = application::create(application::Application {
1338 name: "test-app".into(),
1339 tenant_id: t.id,
1340 ..Default::default()
1341 })
1342 .await
1343 .unwrap();
1344
1345 // create device-profile
1346 let dp = device_profile::create(device_profile::DeviceProfile {
1347 name: "test-dp".into(),
1348 tenant_id: Some(t.id),
1349 ..Default::default()
1350 })
1351 .await
1352 .unwrap();
1353
1354 // setup the api
1355 let service = Device::new(RequestValidator::new());
1356
1357 // create
1358 let create_req = get_request(
1359 &u.id,
1360 api::CreateDeviceRequest {
1361 device: Some(api::Device {
1362 application_id: app.id.to_string(),
1363 device_profile_id: dp.id.to_string(),
1364 name: "test-device".into(),
1365 dev_eui: "0102030405060708".into(),
1366 ..Default::default()
1367 }),
1368 },
1369 );
1370 let _ = service.create(create_req).await.unwrap();

Callers

nothing calls this directly

Calls 15

prepareFunction · 0.85
set_dev_noncesFunction · 0.85
unwrapMethod · 0.80
to_stringMethod · 0.80
create_keysMethod · 0.80
get_keysMethod · 0.80
update_keysMethod · 0.80
insertMethod · 0.80
flush_dev_noncesMethod · 0.80
delete_keysMethod · 0.80
activateMethod · 0.80
get_activationMethod · 0.80

Tested by

no test coverage detected