test: fix all compile warnings in subscriber matching tests
- Prefix unused variables with underscore in subscriber_matching_test.exs - Fix unused integration_id parameters in gaiia_fixtures.ex - Remove duplicate site_fixture/1 from access_control_test.exs - Use public site_fixture/2 from OrganizationsFixtures instead - Remove unused Sites alias from access_control_test.exs All 19 subscriber matching tests passing with no warnings.
This commit is contained in:
parent
67e15d1dc5
commit
4e6a038fb5
3 changed files with 31 additions and 43 deletions
|
|
@ -21,7 +21,7 @@ defmodule Towerops.GaiiaFixtures do
|
|||
integration
|
||||
end
|
||||
|
||||
def gaiia_account_fixture(organization_id, integration_id, attrs \\ %{}) do
|
||||
def gaiia_account_fixture(organization_id, _integration_id, attrs \\ %{}) do
|
||||
# Generate unique gaiia_id if not provided
|
||||
gaiia_id = Map.get(attrs, :gaiia_id, "gaiia_account_#{System.unique_integer()}")
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ defmodule Towerops.GaiiaFixtures do
|
|||
item
|
||||
end
|
||||
|
||||
def gaiia_network_site_fixture(organization_id, integration_id, attrs \\ %{}) do
|
||||
def gaiia_network_site_fixture(organization_id, _integration_id, attrs \\ %{}) do
|
||||
# Generate unique gaiia_id if not provided
|
||||
gaiia_id = Map.get(attrs, :gaiia_id, "gaiia_site_#{System.unique_integer()}")
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
describe "refresh_device_links/1" do
|
||||
test "creates links for wireless MAC matches (highest confidence)", ctx do
|
||||
# Create wireless client with known MAC
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55",
|
||||
ip_address: "192.168.1.100"
|
||||
|
|
@ -109,14 +109,14 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|
||||
test "creates links for wireless IP matches", ctx do
|
||||
# Create wireless client with IP but different MAC
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "AA:BB:CC:DD:EE:FF",
|
||||
ip_address: "192.168.1.100"
|
||||
})
|
||||
|
||||
# Create inventory item with matching IP
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "11:22:33:44:55:66",
|
||||
ip_address: "192.168.1.100"
|
||||
|
|
@ -135,14 +135,14 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|
||||
test "creates links for ARP IP matches (medium confidence)", ctx do
|
||||
# Create ARP entry with IP
|
||||
arp =
|
||||
_arp =
|
||||
arp_entry_fixture(ctx.device.id, %{
|
||||
ip_address: "192.168.1.100",
|
||||
mac_address: "AA:BB:CC:DD:EE:FF"
|
||||
})
|
||||
|
||||
# Create inventory item with matching IP
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "11:22:33:44:55:66",
|
||||
ip_address: "192.168.1.100"
|
||||
|
|
@ -160,14 +160,14 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|
||||
test "creates links for ARP MAC matches (medium confidence)", ctx do
|
||||
# Create ARP entry with MAC
|
||||
arp =
|
||||
_arp =
|
||||
arp_entry_fixture(ctx.device.id, %{
|
||||
ip_address: "192.168.1.100",
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
# Create inventory item with matching MAC
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "00:11:22:33:44:55",
|
||||
ip_address: "192.168.1.200"
|
||||
|
|
@ -192,7 +192,7 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
})
|
||||
|
||||
# Create inventory item at that network site (using gaiia_id, not database id)
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
assigned_network_site_gaiia_id: network_site.gaiia_id
|
||||
})
|
||||
|
|
@ -209,19 +209,19 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|
||||
test "prioritizes higher confidence matches", ctx do
|
||||
# Create both wireless MAC and ARP IP for same account
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55",
|
||||
ip_address: "192.168.1.100"
|
||||
})
|
||||
|
||||
arp =
|
||||
_arp =
|
||||
arp_entry_fixture(ctx.device.id, %{
|
||||
ip_address: "192.168.1.100",
|
||||
mac_address: "AA:BB:CC:DD:EE:FF"
|
||||
})
|
||||
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "00:11:22:33:44:55",
|
||||
ip_address: "192.168.1.100"
|
||||
|
|
@ -252,12 +252,12 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|> Repo.insert()
|
||||
|
||||
# Now create wireless client with better match
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
|
@ -283,23 +283,23 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
})
|
||||
|
||||
# Create wireless clients for both
|
||||
wc1 =
|
||||
_wc1 =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
wc2 =
|
||||
_wc2 =
|
||||
wireless_client_fixture(device2.id, ctx.org.id, %{
|
||||
mac_address: "AA:BB:CC:DD:EE:FF"
|
||||
})
|
||||
|
||||
# Create inventory items for both
|
||||
item1 =
|
||||
_item1 =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
item2 =
|
||||
_item2 =
|
||||
gaiia_inventory_item_fixture(account2.id, %{
|
||||
mac_address: "AA:BB:CC:DD:EE:FF"
|
||||
})
|
||||
|
|
@ -322,13 +322,13 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
account2 = gaiia_account_fixture(org2.id, integration2.id)
|
||||
|
||||
# Create wireless client in org1
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
# Create inventory item in org2 with same MAC
|
||||
item2 =
|
||||
_item2 =
|
||||
gaiia_inventory_item_fixture(account2.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
|
@ -345,12 +345,12 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
describe "refresh_links_for_device/1" do
|
||||
test "refreshes links for single device", ctx do
|
||||
# Create wireless client
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(ctx.account.id, %{
|
||||
mac_address: "00:11:22:33:44:55"
|
||||
})
|
||||
|
|
@ -380,7 +380,7 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
|> Enum.chunk_every(2)
|
||||
|> Enum.map_join(":", &Enum.join/1)
|
||||
|
||||
wc =
|
||||
_wc =
|
||||
wireless_client_fixture(ctx.device.id, ctx.org.id, %{
|
||||
mac_address: mac
|
||||
})
|
||||
|
|
@ -390,7 +390,7 @@ defmodule Towerops.Gaiia.SubscriberMatchingTest do
|
|||
gaiia_id: "account_#{i}"
|
||||
})
|
||||
|
||||
item =
|
||||
_item =
|
||||
gaiia_inventory_item_fixture(account.id, %{
|
||||
mac_address: mac
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ defmodule ToweropsWeb.Live.Helpers.AccessControlTest do
|
|||
import Towerops.OrganizationsFixtures
|
||||
|
||||
alias Towerops.Alerts
|
||||
alias Towerops.Sites
|
||||
alias ToweropsWeb.Live.Helpers.AccessControl
|
||||
|
||||
describe "verify_device_access/2" do
|
||||
|
|
@ -17,8 +16,8 @@ defmodule ToweropsWeb.Live.Helpers.AccessControlTest do
|
|||
org1 = organization_fixture(user1.id)
|
||||
org2 = organization_fixture(user2.id)
|
||||
|
||||
site1 = site_fixture(organization_id: org1.id)
|
||||
site2 = site_fixture(organization_id: org2.id)
|
||||
site1 = site_fixture(org1.id)
|
||||
site2 = site_fixture(org2.id)
|
||||
|
||||
device1 = device_fixture(%{site: site1, organization: org1})
|
||||
device2 = device_fixture(%{site: site2, organization: org2})
|
||||
|
|
@ -62,8 +61,8 @@ defmodule ToweropsWeb.Live.Helpers.AccessControlTest do
|
|||
org1 = organization_fixture(user1.id)
|
||||
org2 = organization_fixture(user2.id)
|
||||
|
||||
site1 = site_fixture(organization_id: org1.id)
|
||||
site2 = site_fixture(organization_id: org2.id)
|
||||
site1 = site_fixture(org1.id)
|
||||
site2 = site_fixture(org2.id)
|
||||
|
||||
%{
|
||||
org1: org1,
|
||||
|
|
@ -102,8 +101,8 @@ defmodule ToweropsWeb.Live.Helpers.AccessControlTest do
|
|||
org1 = organization_fixture(user1.id)
|
||||
org2 = organization_fixture(user2.id)
|
||||
|
||||
site1 = site_fixture(organization_id: org1.id)
|
||||
site2 = site_fixture(organization_id: org2.id)
|
||||
site1 = site_fixture(org1.id)
|
||||
site2 = site_fixture(org2.id)
|
||||
|
||||
device1 = device_fixture(%{site: site1, organization: org1})
|
||||
device2 = device_fixture(%{site: site2, organization: org2})
|
||||
|
|
@ -149,17 +148,6 @@ defmodule ToweropsWeb.Live.Helpers.AccessControlTest do
|
|||
end
|
||||
|
||||
# Helper functions to create test data
|
||||
defp site_fixture(attrs) do
|
||||
{:ok, site} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
name: "Test Site #{System.unique_integer([:positive])}"
|
||||
})
|
||||
|> Sites.create_site()
|
||||
|
||||
site
|
||||
end
|
||||
|
||||
defp alert_fixture(attrs) do
|
||||
{:ok, alert} =
|
||||
attrs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue