Beispiel #1
0
    def _get_payload(self):
        self.payload = {}

        for field in self._meta.fields:
            field_class = field.__class__.__name__
            prepare_method = '_prepare_%s' % to_snake_case(field_class)
            parse_field_name = to_camel_case(field.column)

            # TODO: when a field is null, it should be removed from parse
            # ignoring "system" fields
            if field.name not in self.SYSTEM_FIELDS and hasattr(self, field.name) and getattr(self, field.name) is not None:
                if hasattr(self, prepare_method):
                    self.payload[parse_field_name] = getattr(self, prepare_method)(field)
                else:
                    self.payload[parse_field_name] = self._prepare_field(field)
Beispiel #2
0
 def test_string_is_converted_to_camel_case(self):
     """ parsesync :: Strings are properly converted to camelCase """
     self.assertEqual(to_camel_case("foo_bar"), "fooBar")
Beispiel #3
0
 def test_parse_system_fields_convert_to_django_system_fields(self):
     """ parsesync.models :: Parse system fields convert to Django system fields """
     self.assertEquals(ParseModel.CREATED_AT_PARSE_FIELD, to_camel_case(ParseModel.CREATED_AT_DJANGO_FIELD))
     self.assertEquals(ParseModel.UPDATED_AT_PARSE_FIELD, to_camel_case(ParseModel.UPDATED_AT_DJANGO_FIELD))
Beispiel #4
0
 def test_parse_system_fields_are_in_camel_case(self):
     """ parsesync.models :: Parse system fields are in camelCase """
     self.assertEquals(ParseModel.DJANGO_ID_PARSE_FIELD, to_camel_case(ParseModel.DJANGO_ID_PARSE_FIELD))
     self.assertEquals(ParseModel.CREATED_AT_PARSE_FIELD, to_camel_case(ParseModel.CREATED_AT_PARSE_FIELD))
     self.assertEquals(ParseModel.OBJECT_ID_PARSE_FIELD, to_camel_case(ParseModel.OBJECT_ID_PARSE_FIELD))
     self.assertEquals(ParseModel.UPDATED_AT_PARSE_FIELD, to_camel_case(ParseModel.UPDATED_AT_PARSE_FIELD))