Пример #1
0
    def test_create_base_item(self):
        idea = create_base_item(ItemType('idea', ''), 'idea-1', 'idea name')
#         print str('idea: ' + str(idea))
        assert isinstance(idea, Idea)
        stakeholder = create_base_item(ItemType('stakeholder', ''), 'stakeholder-1', 'stakeholder_name')
#         print str('stakeholder: ' + str(stakeholder))
        assert isinstance(stakeholder, Stakeholder)
Пример #2
0
 def create_or_update_item(self, request, item_type_name, item_id):
     '''
     Decides to create a new item or update an existing item.
     '''
     log.debug('create_or_update_item(' + str(request) + ', ' + item_type_name + ', ' + item_id+ ')')
     item_type = self.get_sodocu().get_config().get_item_type_by_name(item_type_name)
     item = self.sodocu.get_item_by_id(item_type, item_id)
     log.debug('item: ' + str(item))
     
     if item is None:
         item = create_base_item(item_type, item_id, request.form['name'])
         item.get_meta_data().set_created_by(self.get_user())
         item.get_meta_data().set_created_now()
         self.get_sodocu().add_item(item)
     
     self.update_item(request, item)
     item.get_meta_data().set_changed_by(self.get_user())
     item.get_meta_data().set_changed_now()
     self.get_sodocu().save_item(item)
     
     return redirect('/%s/' % item_type_name)
Пример #3
0
 def render_new_item_as_form(self, item_type_name):
     item_type = self.get_sodocu().get_config().get_item_type_by_name(item_type_name)
     new_id = item_type_name + '-' + str(get_max_id(self.sodocu.get_items_by_type(item_type)) + 1)
     temp_item = create_base_item(item_type, new_id, '')
     return self.render_one_item_as_form(temp_item)
Пример #4
0
    def test_get_adder_method(self):
        idea = create_base_item(ItemType('idea', ''), 'idea-1', 'idea name')
        adder_method = get_adder_method(idea.get_relations(), 'invented_from')
#         print adder_method
        assert 'add_invented_from' in str(adder_method)
Пример #5
0
    def test_get_setter_method(self):
        idea = create_base_item(ItemType('idea', ''), 'idea-1', 'idea name')
        setter_method = get_setter_method(idea.get_relations(), 'invented_by')
#         print setter_method
        assert 'set_invented_by' in str(setter_method)