Exemple #1
0
    def test_raises_type_error_if_raw_humanized_id_is_invalid(self):
        # Given
        test_object = Foo()
        data = {'entityId': '12R-..2foo'}

        # When
        with pytest.raises(NonDehumanizableId):
            test_object.modify(data)
Exemple #2
0
    def test_for_sql_float_value_with_12dot9_sets_attribute_to_12dot9(self):
        # Given
        test_object = Foo()
        data = {'float_attribute': 12.9}

        # When
        test_object.modify(data)

        # Then
        assert test_object.float_attribute == 12.9
Exemple #3
0
    def test_for_sql_integer_value_with_12dot9_sets_attribute_to_12dot9(self):
        # Given
        test_object = Foo()
        data = {'integer_attribute': 12}

        # When
        test_object.modify(data)

        # Then
        assert test_object.integer_attribute == 12
Exemple #4
0
    def test_for_valid_sql_uuid_value(self):
        # Given
        test_object = Foo()
        uuid_attribute = str(uuid.uuid4())
        data = {'uuid_attribute': uuid_attribute}

        # When
        test_object.modify(data)

        # Then
        assert test_object.uuid_attribute == uuid_attribute
Exemple #5
0
    def test_for_valid_sql_humanize_id_value_with_key_finishing_by_Id(self):
        # Given
        test_object = Foo()
        humanized_entity_id = "AE"
        data = {'entityId': humanized_entity_id}

        # When
        test_object.modify(data)

        # Then
        assert test_object.entityId == dehumanize(humanized_entity_id)
Exemple #6
0
    def test_for_valid_sql_uuid_value_with_key_finishing_by_Id(self):
        # Given
        test_object = Foo()
        uuid_id = str(uuid.uuid4())
        data = {'uuidId': uuid_id}

        # When
        test_object.modify(data)

        # Then
        assert test_object.uuidId == uuid_id
Exemple #7
0
    def test_for_sql_integer_value_with_string_raises_decimal_cast_error(self):
        # Given
        test_object = Foo()
        data = {'integer_attribute': 'yolo'}

        # When
        with pytest.raises(DecimalCastError) as errors:
            test_object.modify(data)

        # Then
        assert errors.value.errors['integer_attribute'] == [
            "Invalid value for integer_attribute (integer): 'yolo'"
        ]
Exemple #8
0
    def test_raises_type_error_if_raw_uuid_is_invalid(self):
        # Given
        test_object = Foo()
        data = {'uuidId': 'foo'}

        # When
        with pytest.raises(UuidCastError) as errors:
            test_object.modify(data)

        # Then
        assert errors.value.errors['uuidId'] == [
            "Invalid value for uuidId (uuid): 'foo'"
        ]
Exemple #9
0
    def test_for_sql_datetime_value_in_wrong_format_returns_400_and_affected_key_in_error(
            self):
        # Given
        test_object = Foo()
        data = {'date_attribute': {'date_attribute': None}}

        # When
        with pytest.raises(DateTimeCastError) as errors:
            test_object.modify(data)

        # Then
        assert errors.value.errors['date_attribute'] == [
            "Invalid value for date_attribute (datetime): {'date_attribute': None}"
        ]
Exemple #10
0
    def test_for_valid_sql_humanize_id_synonym_value_with_key_finishing_by_Id(
            self):
        # Given
        test_object = Foo()
        humanized_bar_id = "AE"
        dehumanized_bar_id = dehumanize(humanized_bar_id)
        data = {'barId': humanized_bar_id}

        # When
        test_object.modify(data)

        # Then
        assert test_object.bar_id == dehumanized_bar_id
        assert test_object.barId == dehumanized_bar_id