def patch(self):
     """
     Patch this customer in the associated node, updating his attributes with the modified ones.
     """
     tracker = resolve_mutation_tracker(self.mute)
     self.customer_api_manager.patch(_id=self.attributes['id'],
                                     body=tracker)
Exemplo n.º 2
0
    def test_set_like_customer_add(self):
        self.customers[0].base.likes[0].name = 'name1'
        self.customers[0].base.likes += [Like(customer=self.customers[0], id='01')]

        mute_res = {'base': {'likes': [
            {'name': 'name1',
             'category': 'category',
             'id': 'id',
             'createdTime': '1994-02-11 14:05'},
            {u'id': u'01'}
        ]
        }
        }
        mute = {'base.likes': [
            {'name': 'name1',
             'category': 'category',
             'id': 'id',
             'createdTime': '1994-02-11 14:05'},
            {u'id': u'01'}
        ]
        }

        assert self.customers[0].mute == mute, self.customers[0].mute
        res = resolve_mutation_tracker(self.customers[0].mute)
        assert res == mute_res, res
Exemplo n.º 3
0
    def test_set_job_customer_add(self):
        self.customers[0].base.jobs[0].isCurrent = False
        self.customers[0].base.jobs += [Job(customer=self.customers[0], id='01')]

        mute = {'base.jobs': [
            {u'companyIndustry': u'companyIndustry',
             u'companyName': u'companyName',
             u'startDate': u'1994-10-06',
             u'endDate': u'1994-10-06',
             u'jobTitle': u'jobTitle',
             u'isCurrent': False},
            {u'id': u'01'}
        ]
        }
        mute_res = {'base': {'jobs': [
            {u'companyIndustry': u'companyIndustry',
             u'companyName': u'companyName',
             u'startDate': u'1994-10-06',
             u'endDate': u'1994-10-06',
             u'jobTitle': u'jobTitle',
             u'isCurrent': False},
            {u'id': u'01'}
        ]
        }
        }
        assert self.customers[0].mute == mute, self.customers[0].mute
        res = resolve_mutation_tracker(self.customers[0].mute)
        assert res == mute_res, res
    def get_mutation_tracker(self):
        """
        Get the mutation tracker for this customer

        :rtype: dict
        :return: the mutation tracker of this customer
        """
        return resolve_mutation_tracker(self.mute)
Exemplo n.º 5
0
    def add_tag(self, customer_id, tag):
        """
        Add a new tag in the list of customer's tags

        :param customer_id: the id customer in which adding the tag
        :param tag: a string, int, representing the tag to add
        """
        customer = self.get_customer(id=customer_id)
        new_tags = customer.tags.manual
        new_tags += [tag]
        customer.tags.manual = new_tags
        self.update_customer(id=customer_id,
                             **resolve_mutation_tracker(customer.mute))
Exemplo n.º 6
0
    def remove_tag(self, customer_id, tag):
        """
        Remove (if exists) a tag in the list of customer's tag

        :param customer_id: the id customer in which adding the tag
        :param tag: a string, int, representing the tag to add
        """
        customer = self.get_customer(id=customer_id)
        new_tags = list(customer.tags.manual)
        try:
            new_tags.remove(tag)
            customer.tags.manual = new_tags
            self.update_customer(id=customer_id,
                                 **resolve_mutation_tracker(customer.mute))
        except ValueError as e:
            raise ValueError("Tag not in Customer's Tags")
Exemplo n.º 7
0
    def test_set_like_customer(self):
        self.customers[0].base.likes[0].name = 'name1'
        self.customers[0].base.likes[0].category = 'category1'

        like = self.customers[0].base.likes[0]

        mute = {'base.likes':
                             [{'name':'name1',
                               'category':'category1',
                               'id':'id',
                               'createdTime':'1994-02-11 14:05'}]}
        mute_res= {'base': {'likes':
                             [{'name':'name1',
                               'category':'category1',
                               'id':'id',
                               'createdTime':'1994-02-11 14:05'}]}}
        assert self.customers[0].mute == mute, self.customers[0].mute
        res = resolve_mutation_tracker(self.customers[0].mute)
        assert res == mute_res, res
    def test_new_prop(self):
        p = Properties(a=Properties(b=Properties(c=[Properties(e='f')])),
                       d='e')
        assert isinstance(p.a, Properties), type(p.a)
        assert isinstance(p.a.b, Properties), type(p.a.b)
        assert isinstance(p.a.b.c, list), type(p.a.b.c)
        assert isinstance(p.a.b.c[0], Properties), type(p.a.b.c[0])
        assert p.a.b.c[0].e == 'f', p.a.b.c[0].e
        assert p.d == 'e', p.d

        p.a.b = Properties(f='g')
        assert p.mute == {'a.b': {'c': [], 'f': 'g'}}, p.mute

        p.a.b = 'a'
        assert p.mute == {'a.b': 'a'}, p.mute

        p.a.b = [Properties(c='d')]
        assert p.mute == {'a.b': [{'c': 'd'}]}, p.mute

        p.a.b = 'a'
        assert p.mute == {'a.b': 'a'}, p.mute
        res = resolve_mutation_tracker(p.mute)
        assert res == {'a': {'b': 'a'}}, res
Exemplo n.º 9
0
    def test_set_job_customer(self):
        self.customers[0].base.jobs[0].jobTitle = "title"
        self.customers[0].base.jobs[0].endDate = u'1994-10-06'

        edu = self.customers[0].base.jobs[0]
        edu.isCurrent = False

        mute = {'base.jobs':
                             [{u'companyIndustry': u'companyIndustry',
                               u'companyName': u'companyName',
                               u'startDate': u'1994-10-06',
                               u'endDate': u'1994-10-06',
                               u'jobTitle': u'title',
                               u'isCurrent': False}]}
        mute_res = {'base': {'jobs':
                             [{u'companyIndustry': u'companyIndustry',
                               u'companyName': u'companyName',
                               u'startDate': u'1994-10-06',
                               u'endDate': u'1994-10-06',
                               u'jobTitle': u'title',
                               u'isCurrent': False}]}}
        assert self.customers[0].mute == mute, self.customers[0].mute
        res = resolve_mutation_tracker(self.customers[0].mute)
        assert res == mute_res, res