compare = {
  device['id']: 1,
...
}

for key, item in compare.items():
  self.assertEqual(key, item)