Esempio n. 1
0
    def test_build_registration_relations(self, mock_get_relation_names):
        # type: (MagicMock) -> None
        # Arrange
        mock_get_relation_names.return_value = ['relationname']

        classname = 'class'
        list_args = {
            'arg1': ['val1'],
            'relationname:objtype': ['urn:123'],
        }
        expected_result = {
            'relations': {
                'relationname': [
                    {
                        'objekttype': 'objtype',
                        'urn': 'urn:123',
                        'virkning': None
                    }
                ]
            },
            'states': {},
            'attributes': {}
        }

        # Act
        actual_result = br.build_registration(classname, list_args)

        # Assert
        self.assertEqual(expected_result, actual_result)
Esempio n. 2
0
    def test_build_registration_states(self,
                                       mock_get_state_names):
        # type: (MagicMock, MagicMock) -> None
        # Arrange
        mock_get_state_names.return_value = ['statename']

        classname = 'class'
        list_args = {
            'statename': ['val1', 'val2'],
            'whatever': ['whatever'],
        }

        expected_result = {
            'states': {
                'statename': [
                    {
                        'virkning': None,
                        'statename': 'val1'
                    },
                    {
                        'virkning': None,
                        'statename': 'val2'
                    }
                ]
            },
            'attributes': {},
            'relations': {}
        }

        # Act
        actual_result = br.build_registration(classname, list_args)

        # Assert
        self.assertEqual(expected_result, actual_result)
Esempio n. 3
0
    def test_build_registration_dokument(self, mock_dvet_get_fields,
                                         mock_ddet_get_fields, mock_get_dprn):
        # Arrange
        mock_dvet_get_fields.return_value = ['testvariantegenskab']
        mock_ddet_get_fields.return_value = ['testdelegenskab']
        mock_get_dprn.return_value = ['testdelrelnavn']

        list_args = {
            'varianttekst': ['testtekst'],
            'deltekst': ['testdeltekst'],
            'testvariantegenskab': ['val1', 'val2'],
            'testdelegenskab': ['val3', 'val4'],
            'testdelrelnavn:objtype': ['urn:1234'],
        }

        expected_result = {
            "variants": [
                {
                    "dele": [
                        {
                            "egenskaber": [
                                {
                                    "virkning": None,
                                    "testdelegenskab": "val3"
                                },
                                {
                                    "virkning": None,
                                    "testdelegenskab": "val4"
                                }
                            ],
                            "relationer": {
                                "testdelrelnavn": [
                                    {
                                        "virkning": None,
                                        "urn": "urn:1234",
                                        "objekttype": "objtype"
                                    }
                                ]
                            },
                            "deltekst": "testdeltekst"
                        }
                    ],
                    "egenskaber": [
                        {
                            "virkning": None,
                            "testvariantegenskab": "val1"
                        },
                        {
                            "virkning": None,
                            "testvariantegenskab": "val2"
                        }
                    ],
                    "varianttekst": "testtekst"
                }
            ],
            "states": {
                "fremdrift": []
            },
            "attributes": {},
            "relations": {}
        }

        # Act
        actual_result = br.build_registration('Dokument', list_args)

        # Assert
        self.assertEqual(expected_result, actual_result)