Пример #1
0
 def setUp(self):
     super(AttachedToTests, self).setUp()
     obj1 = Tag(tag=u'medicinal')
     obj2 = Tag(tag=u'maderable')
     obj3 = Tag(tag=u'frutal')
     fam = Family(family=u'Solanaceae')
     self.session.add_all([obj1, obj2, obj3, fam])
     self.session.commit()
Пример #2
0
 def test_str(self):
     """
     Test Tag.__str__ method
     """
     name = u'test'
     tag = Tag(tag=name)
     self.assert_(str(tag) == name)
Пример #3
0
 def test_when_user_edits_name_name_is_memorized(self):
     model = Tag()
     view = MockTagView()
     presenter = TagEditorPresenter(model, view)
     view.widget_set_value('tag_name_entry', u'1234')
     presenter.on_text_entry_changed('tag_name_entry')
     self.assertEquals(model.tag, u'1234')
Пример #4
0
 def test_widget_names_and_field_names(self):
     model = Tag()
     view = MockTagView()
     presenter = TagEditorPresenter(model, view)
     for widget, field in presenter.widget_to_field_map.items():
         self.assertTrue(hasattr(model, field), field)
         presenter.view.widget_get_value(widget)
Пример #5
0
 def test_when_user_edits_fields_ok_active(self):
     model = Tag()
     view = MockTagView()
     presenter = TagEditorPresenter(model, view)
     self.assertTrue(not view.sensitive)  # not changed
     presenter.on_text_entry_changed('tag_name_entry', u'1234')
     self.assertEquals(model.tag, u'1234')
     self.assertTrue(view.sensitive)  # changed
Пример #6
0
    def test_if_asked_presenter_initializes_view(self):
        session = db.Session()

        # prepare data in database
        obj = Tag(tag=u'1234')
        session.add(obj)
        view = MockTagView()
        TagEditorPresenter(obj, view, refresh_view=True)
        self.assertEquals(view.widget_get_value("tag_name_entry"), u'1234')
Пример #7
0
    def test_presenter_does_not_initialize_view(self):
        session = db.Session()

        # prepare data in database
        obj = Tag(tag=u'1234')
        session.add(obj)
        view = MockTagView()
        presenter = TagEditorPresenter(obj, view)
        self.assertFalse(view.widget_get_value("tag_name_entry"))
        presenter.refresh_view()
        self.assertEquals(view.widget_get_value("tag_name_entry"), u'1234')
Пример #8
0
    def test_when_user_inserts_existing_name_warning_ok_deactivated(self):
        session = db.Session()

        # prepare data in database
        obj = Tag(tag=u'1234')
        session.add(obj)
        session.commit()
        session.close()
        ## ok. thing is already there now.

        session = db.Session()
        view = MockTagView()
        obj = Tag()  # new scratch object
        session.add(obj)  # is in session
        presenter = TagEditorPresenter(obj, view)
        self.assertTrue(not view.sensitive)  # not changed
        presenter.on_unique_text_entry_changed('tag_name_entry', u'1234')
        self.assertEquals(obj.tag, u'1234')
        self.assertTrue(view.is_dirty())
        self.assertTrue(not view.sensitive)  # unacceptable change
        self.assertTrue(presenter.has_problems())
Пример #9
0
 def test_attached_tags_many(self):
     fam = self.session.query(Family).one()
     tags = self.session.query(Tag).all()
     for t in tags:
         tag_plugin.tag_objects(t, [fam])
     self.assertEquals(Tag.attached_to(fam), tags)
Пример #10
0
 def test_attached_tags_singleton(self):
     fam = self.session.query(Family).one()
     obj2 = self.session.query(Tag).filter(Tag.tag == u'maderable').one()
     tag_plugin.tag_objects(obj2, [fam])
     self.assertEquals(Tag.attached_to(fam), [obj2])
Пример #11
0
 def test_attached_tags_empty(self):
     fam = self.session.query(Family).one()
     self.assertEquals(Tag.attached_to(fam), [])
Пример #12
0
 def test_attached_tags_many(self):
     fam = self.session.query(Family).one()
     tags = self.session.query(Tag).all()
     for t in tags:
         tag_plugin.tag_objects(t, [fam])
     self.assertEquals(Tag.attached_to(fam), tags)
Пример #13
0
 def test_attached_tags_singleton(self):
     fam = self.session.query(Family).one()
     obj2 = self.session.query(Tag).filter(Tag.tag == u'maderable').one()
     tag_plugin.tag_objects(obj2, [fam])
     self.assertEquals(Tag.attached_to(fam), [obj2])
Пример #14
0
 def test_attached_tags_empty(self):
     fam = self.session.query(Family).one()
     self.assertEquals(Tag.attached_to(fam), [])