Beispiel #1
0
 def testListDeviceBlocklist(self):
     """Test ListDeviceBlocklist."""
     blocklist1 = datastore_test_util.CreateDeviceBlocklist(
         'alab1', 'auser')
     blocklist2 = datastore_test_util.CreateDeviceBlocklist(
         'alab2', 'auser')
     api_response = self.testapp.post_json(
         '/_ah/api/DeviceBlocklistApi.ListDeviceBlocklist', {})
     msg = protojson.decode_message(api_messages.DeviceBlocklistCollection,
                                    api_response.body)
     # Order by create_timestamp.
     self.AssertDeviceBlocklistEqualMessage(blocklist2,
                                            msg.device_blocklists[0])
     self.AssertDeviceBlocklistEqualMessage(blocklist1,
                                            msg.device_blocklists[1])
 def testDeviceBlocklist(self):
     blocklist = datastore_test_util.CreateDeviceBlocklist('alab', 'auser')
     res = blocklist.key.get()
     self.assertIsNotNone(res.create_timestamp)
     self.assertEqual('alab', res.lab_name)
     self.assertEqual('lab outage', res.note)
     self.assertEqual('auser', res.user)
 def testDeviceBlocklistToMessage(self):
     blocklist = datastore_test_util.CreateDeviceBlocklist('alab', 'auser')
     msg = datastore_entities.ToMessage(blocklist)
     self.assertIsNotNone(msg.key_id)
     self.assertIsNotNone(msg.create_timestamp)
     self.assertEqual('alab', msg.lab_name)
     self.assertEqual('lab outage', msg.note)
     self.assertEqual('auser', msg.user)
Beispiel #4
0
 def testGetDeviceBlocklist(self):
     """Test GetDeviceBlocklist."""
     blocklist = datastore_test_util.CreateDeviceBlocklist('alab', 'auser')
     api_request = {'key_id': blocklist.key.integer_id()}
     api_response = self.testapp.post_json(
         '/_ah/api/DeviceBlocklistApi.GetDeviceBlocklist', api_request)
     msg = protojson.decode_message(api_messages.DeviceBlocklistMessage,
                                    api_response.body)
     self.assertEqual('200 OK', api_response.status)
     self.AssertDeviceBlocklistEqualMessage(blocklist, msg)
 def testDeviceBlocklistArchiveToMessage(self):
     blocklist = datastore_test_util.CreateDeviceBlocklist('alab', 'auser')
     blocklist_archive = (
         datastore_entities.DeviceBlocklistArchive.FromDeviceBlocklist(
             blocklist, 'another_user'))
     blocklist_archive.put()
     msg = datastore_entities.ToMessage(blocklist_archive)
     self.assertEqual(msg.device_blocklist.create_timestamp,
                      msg.start_timestamp)
     self.assertIsNotNone(msg.end_timestamp)
     self.assertEqual('another_user', msg.archived_by)
     self.assertEqual('alab', msg.device_blocklist.lab_name)
     self.assertEqual('lab outage', msg.device_blocklist.note)
     self.assertEqual('auser', msg.device_blocklist.user)
 def testDeviceBlocklistArchive(self):
     blocklist = datastore_test_util.CreateDeviceBlocklist('alab', 'auser')
     blocklist_archive = (
         datastore_entities.DeviceBlocklistArchive.FromDeviceBlocklist(
             blocklist, 'another_user'))
     blocklist_archive.put()
     res = blocklist_archive.key.get()
     self.assertEqual(res.device_blocklist.create_timestamp,
                      res.start_timestamp)
     self.assertIsNotNone(res.end_timestamp)
     self.assertEqual('another_user', res.archived_by)
     self.assertEqual('alab', res.device_blocklist.lab_name)
     self.assertEqual('lab outage', res.device_blocklist.note)
     self.assertEqual('auser', res.device_blocklist.user)
 def testIsLabBlocked_notBlocked(self):
     """Test IsLabBlocked for not blocked lab."""
     datastore_test_util.CreateDeviceBlocklist(lab_name='alab',
                                               user='******')
     self.assertFalse(device_blocker.IsLabBlocked('another_lab'))
 def testIsLabBlocked(self):
     """Test IsLabBlocked."""
     datastore_test_util.CreateDeviceBlocklist(lab_name='alab',
                                               user='******')
     self.assertTrue(device_blocker.IsLabBlocked('alab'))