Esempio n. 1
0
    def test_update_dict(self):
        '''updates the new dictionary with ids, abbreviation, description
        and forms, but will not overwrite any descriptions'''

        new_data = {
            'Deparment A': {
                'usa_id': '1',
                'acronym': 'A'
            },
            'Deparment B': {
                'usa_id': '2',
                'acronym': 'B',
                'description': 'next des.'
            }
        }

        old_data = {'name': 'Deparment A', 'description': "old desc."}
        old_data_expected = {
            'name': 'Deparment A',
            'description': "old desc.",
            'usa_id': '1',
            'abbreviation': 'A'
        }
        old_data, new_data = usa_layer.update_dict(old_data, new_data)
        self.assertEqual(old_data_expected, old_data)

        old_data = {'name': 'Deparment B'}
        old_data_expected = {
            'name': 'Deparment B',
            'description': "next des.",
            'usa_id': '2',
            'abbreviation': 'B'
        }
        old_data, new_data = usa_layer.update_dict(old_data, new_data)
        self.assertEqual(old_data_expected, old_data)
Esempio n. 2
0
 def test_update_dict_descriptions(self):
     """ Check that description are not overwritten """
     old_data = {'description': 'des'}
     new_data = {'description': 'new description', 'usa_id': '1'}
     self.assertEqual(
         usa_layer.update_dict(old_data=old_data, new_data=new_data), {
             'description': 'des',
             'usa_id': '1'
         })
Esempio n. 3
0
    def test_update_dict(self):
        '''updates the new dictionary with ids, abbreviation, description
        and forms, but will not overwrite any descriptions'''

        new_data = {'Deparment A':{'usa_id':'1','acronym':'A'},
            'Deparment B':{'usa_id':'2','acronym':'B',
            'description':'next des.'}}

        old_data = {'name':'Deparment A','description':"old desc."}
        old_data_expected = {'name':'Deparment A','description':"old desc.",
            'usa_id':'1','abbreviation':'A'}
        old_data,new_data = usa_layer.update_dict(old_data,new_data)
        self.assertEqual(old_data_expected,old_data)

        old_data = {'name':'Deparment B'}
        old_data_expected = {'name':'Deparment B','description':"next des.",
            'usa_id':'2','abbreviation':'B'}
        old_data,new_data = usa_layer.update_dict(old_data,new_data)
        self.assertEqual(old_data_expected,old_data)
Esempio n. 4
0
    def test_update_dict(self):

        new_data = {'usa_id': '1'}
        old_data = {}
        expected_data = {'usa_id': '1'}

        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data)

        new_data.update({'description': 'des'})
        expected_data.update({'description': 'des'})
        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data)

        new_data.update({'abbreviation': 'A'})
        expected_data.update({'abbreviation': 'A'})
        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data)
    def test_update_dict(self):

        new_data = {'usa_id': '1'}
        old_data = {}
        expected_data = {'usa_id': '1'}

        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data
        )

        new_data.update({'description': 'des'})
        expected_data.update({'description': 'des'})
        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data
        )

        new_data.update({'abbreviation': 'A'})
        expected_data.update({'abbreviation': 'A'})
        self.assertEqual(
            usa_layer.update_dict(old_data=old_data, new_data=new_data),
            expected_data
        )