Exemple #1
0
 def test_audit_invalid_device(self):
     request = shelf_messages.ShelfAuditRequest(
         shelf_request=shelf_messages.ShelfRequest(location='NYC'),
         device_identifiers=['Invalid'])
     with self.assertRaisesRegexp(
             endpoints.NotFoundException,
             shelf_api._DEVICE_DOES_NOT_EXIST_MSG % 'Invalid'):
         self.service.audit(request)
Exemple #2
0
    def testShelfAuditRequest(self):
        shelf_audit_req = shelf_messages.ShelfAuditRequest(
            shelf_request=None,
            device_identifiers=['FAKE-IDENTIFIER-1', 'FAKE-IDENTIFIER-2'])

        self.assertIsNone(shelf_audit_req.shelf_request)
        self.assertListEqual(shelf_audit_req.device_identifiers,
                             ['FAKE-IDENTIFIER-1', 'FAKE-IDENTIFIER-2'])
Exemple #3
0
 def test_audit_using_shelf_location(self, mock_logging, mock_xsrf_token):
   request = shelf_messages.ShelfAuditRequest(
       shelf_request=shelf_messages.ShelfRequest(location='NYC'),
       device_identifiers=self.device_identifiers)
   response = self.service.audit(request)
   self.assertEqual(mock_xsrf_token.call_count, 1)
   self.assertTrue(mock_logging.called)
   for identifier in self.device_identifiers:
     datastore_device = device_model.Device.get(serial_number=identifier)
     self.assertEqual(datastore_device.shelf.get().location, 'NYC')
   self.assertFalse(self.shelf.audit_requested)
   self.assertEqual(self.shelf.last_audit_by, loanertest.SUPER_ADMIN_EMAIL)
   self.assertIsInstance(response, message_types.VoidMessage)
Exemple #4
0
 def test_audit_remove_devices(self, mock_get_shelf,
                               mock_model_device_search):
     shelf = self.device2_key.get()
     shelf.shelf = self.shelf.key
     shelf.put()
     mock_model_device_search.return_value = (search.SearchResults(
         results=[
             search.ScoredDocument(doc_id=self.device2_key.urlsafe()),
             search.ScoredDocument(doc_id=self.device3_key.urlsafe()),
             search.ScoredDocument(doc_id=self.device4_key.urlsafe())
         ],
         number_found=3))
     mock_get_shelf.return_value = self.shelf
     request = shelf_messages.ShelfAuditRequest(
         shelf_request=shelf_messages.ShelfRequest(
             location=self.shelf.location),
         device_identifiers=[self.device3_key.get().serial_number])
     self.service.audit(request)
     self.assertEqual(self.device3_key.get().shelf, self.shelf.key)
     self.assertEqual(self.device2_key.get().shelf, None)
     self.assertEqual(self.device4_key.get().shelf, None)