Esempio n. 1
0
 def test_camel_to_snake(self):
     self.assertEqual('', BusinessEntityUtils.camel_to_snake(''))
     self.assertEqual('customer',
                      BusinessEntityUtils.camel_to_snake('Customer'))
     self.assertEqual('customer_url',
                      BusinessEntityUtils.camel_to_snake('CustomerURL'))
     self.assertEqual('customer_address',
                      BusinessEntityUtils.camel_to_snake('CustomerAddress'))
Esempio n. 2
0
 def test_snake_to_camel(self):
     self.assertEqual('', BusinessEntityUtils.snake_to_camel(''))
     self.assertEqual('Customer',
                      BusinessEntityUtils.snake_to_camel('customer'))
     self.assertEqual('Customer',
                      BusinessEntityUtils.snake_to_camel('customer_'))
     self.assertEqual(
         'CustomerAddress',
         BusinessEntityUtils.snake_to_camel('customer_address'))
Esempio n. 3
0
    def update_or_create(self, entity_name: str, key: str, version: str,
                         user: User,
                         data: str) -> (AbstractBusinessEntity, bool):
        business_entity_class = BusinessEntityUtils.get_entity_class(
            entity_name)
        business_entity, created = business_entity_class.objects.update_or_create(
            key=key,
            version=version,
            defaults={
                'key': key,
                'version': version,
                'publisher': user,
                'data': data
            })

        self._message_publisher.send_entity_update_message(business_entity)

        return created
Esempio n. 4
0
 def delete_by_key(self, entity_name: str, key: str) -> int:
     business_entity_class = BusinessEntityUtils.get_entity_class(
         entity_name)
     return self.delete_by_queryset(
         business_entity_class.objects.filter(key=key))
Esempio n. 5
0
 def find_all(self, entity_name: str) -> QuerySet:
     business_entity_class = BusinessEntityUtils.get_entity_class(
         entity_name)
     return business_entity_class.objects.all()