def setUp(self): super(TagModelTest, self).setUp() tag_model._MODELS_WITH_TAGS = (_ModelWithTags,) self.tag1 = tag_model.Tag( name='TestTag1', hidden=False, protect=True, color='blue', description='Description 1.') self.tag2 = tag_model.Tag( name='TestTag2', hidden=False, protect=False, color='red', description='Description 2.') self.tag1.put() self.tag2.put() self.tag1_data = tag_model.TagData( tag_key=self.tag1.key, more_info='tag1_data info.') self.tag2_data = tag_model.TagData( tag_key=self.tag2.key, more_info='tag2_data info.') self.entity1 = _ModelWithTags( tags=[self.tag1_data, self.tag2_data]).put().get() self.entity2 = _ModelWithTags( tags=[self.tag1_data, self.tag2_data]).put().get() self.entity3 = _ModelWithTags( tags=[self.tag1_data, self.tag2_data]).put().get()
def setUp(self): super(TagModelPy23MigrationTest, self).setUp() self.tag = tag_model.Tag( name='TestTag1', hidden=False, protect=True, color='blue', description='Description 1.')
def testTagDate(self): tag_model_object = tag_model.Tag( name='TestTag1', hidden=False, protect=True, color='blue', description='Description 1.') tag = tag_model.TagData(tag=tag_model_object, more_info='test_data') self.assertEqual('test_data', tag.more_info) self.assertEqual(tag_model_object, tag.tag)
def setUp(self): super(DeviceModelTest, self).setUp() config_model.Config.set( 'device_identifier_mode', config_model.DeviceIdentifierMode.SERIAL_NUMBER) self.shelf = shelf_model.Shelf.enroll( user_email=loanertest.USER_EMAIL, location='MTV', capacity=10, friendly_name='MTV office') self.tag1_key = tag_model.Tag( name='TestTag1', hidden=False, protect=True, color='blue', description='Description 1.').put() self.tag2_key = tag_model.Tag( name='TestTag2', hidden=False, protect=False, color='red', description='Description 2.').put() self.tag1_data = tag_model.TagData( tag=self.tag1_key.get(), more_info='tag1_data info.') self.tag2_data = tag_model.TagData( tag=self.tag2_key.get(), more_info='tag2_data info.') device_model.Device( serial_number='12321', enrolled=True, device_model='HP Chromebook 13 G1', current_ou='/', shelf=self.shelf.key, chrome_device_id='unique_id_1', damaged=False).put() device_model.Device( serial_number='67890', enrolled=True, device_model='Google Pixelbook', current_ou='/', shelf=self.shelf.key, chrome_device_id='unique_id_2', damaged=False, tags=[self.tag1_data]).put() device_model.Device( serial_number='VOID', enrolled=False, device_model='HP Chromebook 13 G1', current_ou='/', shelf=self.shelf.key, chrome_device_id='unique_id_8', damaged=False, tags=[self.tag1_data, self.tag2_data]).put() self.device1 = device_model.Device.get(serial_number='12321') self.device2 = device_model.Device.get(serial_number='67890') self.device3 = device_model.Device.get(serial_number='Void') datastore_user = user_model.User.get_user(loanertest.USER_EMAIL) datastore_user.update(superadmin=True)
def testPrePutHook(self, query_mock): self.tag = tag_model.Tag( name='TestTag3', hidden=False, protect=False, color='red', description='Description 2.') query_mock.return_value.get.return_value = False self.tag.name = 'test123' self.tag._pre_put_hook() query_mock.return_value.get.assert_called_once_with(keys_only=True)
def testPreDeleteHook(self, info_mock, key_mock): self.tag = tag_model.Tag( name='TestTag3', hidden=False, protect=False, color='red', description='Description 2.') key_mock.urlsafe.return_value = 'test' key_mock.get.return_value.name = 'test_name' self.tag._pre_delete_hook(key_mock) info_mock.assert_called_once_with( 'Destroying the tag with urlsafe key %r and name %r.', 'test', 'test_name') key_mock.urlsafe.assert_called_once_with()
def setUp(self): super(ApiUtilsTest, self).setUp() self.test_tag = tag_model.Tag(name='test', hidden=False, protect=False, color='red').put().get() self.test_shelf_model = shelf_model.Shelf( enabled=True, friendly_name='test_friendly_name', location='test_location', lat_long=ndb.GeoPt(10.10, 20.20), altitude=1.1, capacity=10, audit_interval_override=12, audit_notification_enabled=True, audit_requested=True, responsible_for_audit='test_group', last_audit_time=datetime.datetime(year=2018, month=1, day=1), last_audit_by='test_auditer').put().get() self.expected_shelf_message = shelf_messages.Shelf( shelf_request=shelf_messages.ShelfRequest( location='test_location', urlsafe_key=self.test_shelf_model.key.urlsafe()), enabled=True, friendly_name='test_friendly_name', location='test_location', identifier='test_friendly_name', latitude=10.10, longitude=20.20, altitude=1.1, capacity=10, audit_notification_enabled=True, audit_requested=True, audit_enabled=True, responsible_for_audit='test_group', last_audit_time=datetime.datetime(year=2018, month=1, day=1), last_audit_by='test_auditer')