Exemplo n.º 1
0
    def setup_method(self, method):
        self.type = CompositeType('category', [
            sa.Column('scale', NumericRangeType),
            sa.Column('name', sa.String)
        ])

        TestCase.setup_method(self, method)
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        text_items = [
            self.Article(name=u'Article 1'),
            self.Article(name=u'Article 2'),
            self.Article(name=u'Article 3'),
            self.Article(name=u'Article 4'),
            self.BlogPost(name=u'BlogPost 1'),
            self.BlogPost(name=u'BlogPost 2'),
            self.BlogPost(name=u'BlogPost 3'),
            self.BlogPost(name=u'BlogPost 4')
        ]
        self.session.add_all(text_items)
        self.session.flush()
        category = self.Category(name=u'Category #1')
        category.articles = text_items[0:2]
        category.blog_posts = text_items[4:7]
        category2 = self.Category(name=u'Category #2')
        category2.articles = text_items[2:4]
        category2.blog_posts = text_items[-1:]
        self.session.add(category)
        self.session.add(category2)
        text_items[0].attachments = [
            self.Attachment(id=22, name=u'Attachment 1'),
            self.Attachment(id=34, name=u'Attachment 2')
        ]
        text_items[0].author = self.User(name=u'John Matrix')
        text_items[1].author = self.User(name=u'John Doe')

        self.session.commit()
Exemplo n.º 3
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.users = [self.User(), self.User()]
        self.articles = [
            self.Article(),
            self.Article(),
            self.Article(),
            self.Article()
        ]
        self.posts = [
            self.BlogPost(),
            self.BlogPost(),
            self.BlogPost(),
        ]

        self.session.add_all(self.users)
        self.session.add_all(self.articles)
        self.session.add_all(self.posts)
        self.session.commit()

        self.chain = QueryChain([
            self.session.query(self.User).order_by('id'),
            self.session.query(self.Article).order_by('id'),
            self.session.query(self.BlogPost).order_by('id')
        ])
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        text_items = [
            self.Article(name=u'Article 1'),
            self.Article(name=u'Article 2'),
            self.Article(name=u'Article 3'),
            self.Article(name=u'Article 4'),
            self.BlogPost(name=u'BlogPost 1'),
            self.BlogPost(name=u'BlogPost 2'),
            self.BlogPost(name=u'BlogPost 3'),
            self.BlogPost(name=u'BlogPost 4')
        ]
        self.session.add_all(text_items)
        self.session.flush()
        category = self.Category(name=u'Category #1')
        category.articles = text_items[0:2]
        category.blog_posts = text_items[4:7]
        category2 = self.Category(name=u'Category #2')
        category2.articles = text_items[2:4]
        category2.blog_posts = text_items[-1:]
        self.session.add(category)
        self.session.add(category2)
        text_items[0].attachments = [
            self.Attachment(id=22, name=u'Attachment 1'),
            self.Attachment(id=34, name=u'Attachment 2')
        ]
        text_items[0].author = self.User(name=u'John Matrix')
        text_items[1].author = self.User(name=u'John Doe')

        self.session.commit()
Exemplo n.º 5
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.users = [
            self.User(),
            self.User()
        ]
        self.articles = [
            self.Article(),
            self.Article(),
            self.Article(),
            self.Article()
        ]
        self.posts = [
            self.BlogPost(),
            self.BlogPost(),
            self.BlogPost(),
        ]

        self.session.add_all(self.users)
        self.session.add_all(self.articles)
        self.session.add_all(self.posts)
        self.session.commit()

        self.chain = QueryChain(
            [
                self.session.query(self.User).order_by('id'),
                self.session.query(self.Article).order_by('id'),
                self.session.query(self.BlogPost).order_by('id')
            ]
        )
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.path = os.path.join(os.path.dirname(__file__), 'uploads',
                              'images')
     self.rel_path = os.path.join('uploads', 'images')
     self.storage = FileSystemStorage(os.path.dirname(__file__))
     self.file = 'some_file.txt'
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.TextMultiItem(name=u'index', content=u'lorem ipsum'))
     self.session.add(
         self.TextMultiItem(name=u'ipsum', content=u'admin content'))
     self.session.commit()
Exemplo n.º 8
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(self.Article(name=u'index', content=u'some content'))
     self.session.add(self.Article(name=u'admin', content=u'admin content'))
     self.session.add(
         self.Article(name=u'home', content=u'this is the home page'))
     self.session.commit()
Exemplo n.º 9
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(Article(name=u'index', content=u'some content'))
     self.session.add(Article(name=u'admin', content=u'admin content'))
     self.session.add(
         Article(name=u'home', content=u'this is the home page')
     )
     self.session.commit()
Exemplo n.º 10
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.article = self.Article()
     self.article.name = u'Some article'
     self.article.content = u'Some content'
     self.article.tags.append(self.Tag(name=u'Some tag'))
     self.session.add(self.article)
     self.session.commit()
Exemplo n.º 11
0
    def setup_method(self, method):
        self.type = CompositeType('money_type', [
            sa.Column('currency', CurrencyType),
            sa.Column('amount', sa.Integer)
        ])

        TestCase.setup_method(self, method)
        i18n.get_locale = lambda: i18n.babel.Locale('en')
Exemplo n.º 12
0
 def setUp(self):
     TestCase.setUp(self)
     self.logger = Logger(output_dir = test_logdir)
     self.protocol = MockProtocol('aim', 'digsby03')
     self.account = MockAccount('aim', 'digsby03')
     self.self_buddy = MockBuddy('digsby03', self.protocol)
     self.buddy = MockBuddy('digsby01', self.protocol)
     self.convo = MockConversation(buddy = self.buddy, ischat=False, protocol=self.protocol)
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.WeightedTextItem(name=u'Gort',
                               content=u'Klaatu barada nikto'))
     self.session.add(
         self.WeightedTextItem(name=u'Klaatu', content=u'barada nikto'))
     self.session.commit()
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.article = self.Article()
     self.article.name = u'Some article'
     self.article.content = u'Some content'
     self.article.tags.append(self.Tag(name=u'Some tag'))
     self.session.add(self.article)
     self.session.commit()
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.WeightedTextItem(name=u'Gort', content=u'Klaatu barada nikto')
     )
     self.session.add(
         self.WeightedTextItem(name=u'Klaatu', content=u'barada nikto')
     )
     self.session.commit()
Exemplo n.º 16
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     user = self.User(name='Someone',
                      email='*****@*****.**',
                      age=15,
                      fav_numbers=[1, 2, 3])
     self.session.add(user)
     self.session.commit()
     self.user = user
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.TextMultiItem(name=u'index', content=u'lorem ipsum')
     )
     self.session.add(
         self.TextMultiItem(name=u'ipsum', content=u'admin content')
     )
     self.session.commit()
Exemplo n.º 18
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        flexmock(S3BotoStorage) \
            .should_receive('_get_or_create_bucket') \
            .with_args('some_bucket') \
            .and_return(MockBucket())

        self.storage = S3BotoStorage('some_bucket')
        self.file = S3BotoStorageFile(self.storage, 'some_file')
Exemplo n.º 19
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        flexmock(S3BotoStorage) \
            .should_receive('_get_or_create_bucket') \
            .with_args('some_bucket') \
            .and_return(MockBucket())

        self.storage = S3BotoStorage('some_bucket')
        self.file = S3BotoStorageFile(self.storage, 'some_file')
Exemplo n.º 20
0
 def setUp(self):
     TestCase.setUp(self)
     self.logger = Logger(output_dir=test_logdir)
     self.protocol = MockProtocol('aim', 'digsby03')
     self.account = MockAccount('aim', 'digsby03')
     self.self_buddy = MockBuddy('digsby03', self.protocol)
     self.buddy = MockBuddy('digsby01', self.protocol)
     self.convo = MockConversation(buddy=self.buddy,
                                   ischat=False,
                                   protocol=self.protocol)
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.path = os.path.join(
         os.path.dirname(__file__),
         'uploads',
         'images'
     )
     self.rel_path = os.path.join('uploads', 'images')
     self.storage = FileSystemStorage(os.path.dirname(__file__))
     self.file = 'some_file.txt'
Exemplo n.º 22
0
    def setup_method(self, method):
        self.type = CompositeType(
            'category',
            [
                sa.Column('scale', NumericRangeType),
                sa.Column('name', sa.String)
            ]
        )

        TestCase.setup_method(self, method)
Exemplo n.º 23
0
    def create_models(self):
        TestCase.create_models(self)

        class User(self.Model):
            __tablename__ = "user"
            __versioned__ = {"base_classes": (self.Model,)}

            id = sa.Column(sa.Integer, autoincrement=True, primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.User = User
Exemplo n.º 24
0
    def create_models(self):
        TestCase.create_models(self)

        class User(self.Model):
            __tablename__ = 'user'
            __versioned__ = {'base_classes': (self.Model, )}

            id = sa.Column(sa.Integer, autoincrement=True, primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.User = User
Exemplo n.º 25
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     user = self.User(
         name='Someone',
         email='*****@*****.**',
         age=15,
         fav_numbers=[1, 2, 3]
     )
     self.session.add(user)
     self.session.commit()
     self.user = user
Exemplo n.º 26
0
    def setup_method(self, method):
        self.type = CompositeType(
            'category',
            [
                sa.Column('scale', NumericRangeType),
                sa.Column('name', sa.String)
            ]
        )

        TestCase.setup_method(self, method)
        i18n.get_locale = lambda: babel.Locale('en')
Exemplo n.º 27
0
    def setup_method(self, method):
        self.type = CompositeType(
            'money_type',
            [
                sa.Column('currency', CurrencyType),
                sa.Column('amount', sa.Integer)
            ]
        )

        TestCase.setup_method(self, method)
        i18n.get_locale = lambda: babel.Locale('en')
Exemplo n.º 28
0
    def create_models(self):
        TestCase.create_models(self)

        class NotIdModel(self.Model):
            __tablename__ = 'not_id'
            __versioned__ = {'base_classes': (self.Model, )}

            pk = sa.Column(sa.Integer, autoincrement=True, primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.NotIdModel = NotIdModel
Exemplo n.º 29
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.items = [
         self.TextItem(name=u'index', content=u'some content'),
         self.TextItem(name=u'admin', content=u'admin content'),
         self.TextItem(
             name=u'home',
             content=u'this is the home page of [email protected]'),
         self.TextItem(name=u'not a some content', content=u'not a name')
     ]
     self.session.add_all(self.items)
     self.session.commit()
    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/new',
            view_func=CreateFormView.as_view('edit',
                model_class=self.User,
                form_class=MockForm
            )
        )
        self.app.add_url_rule('/users/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.users = [
         self.User(first_name=u'John', last_name=u'Matrix'),
         self.User(first_name=u'John', last_name=u'The Ripper')
     ]
     articles = [
         self.Article(id=1, name=u'Article 1', author=self.users[0]),
         self.Article(id=2, name=u'Article 2', author=self.users[1]),
         self.Article(id=3, name=u'Article 3')
     ]
     self.session.add_all(articles)
     self.session.commit()
Exemplo n.º 32
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.users = [
         self.User(id=333, name=u'John'),
         self.User(id=334, name=u'Matt')
     ]
     articles = [
         self.Article(id=1, name=u'Article 1', author=self.users[0]),
         self.Article(id=2, name=u'Article 2', author=self.users[1]),
         self.Article(id=3, name=u'Article 3')
     ]
     self.session.add_all(articles)
     self.session.commit()
Exemplo n.º 33
0
 def setup_method(self, method):
     search_manager.options['regconfig'] = 'pg_catalog.simple'
     TestCase.setup_method(self, method)
     self.items = [
         self.TextItem(name=u'index', content=u'some content'),
         self.TextItem(name=u'admin', content=u'admin content'),
         self.TextItem(
             name=u'home',
             content=u'this is the home page of [email protected]'),
         self.TextItem(name=u'not a some content', content=u'not a name')
     ]
     self.session.add_all(self.items)
     self.session.commit()
    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/<int:id>',
            view_func=UpdateView.as_view('update',
            model_class=self.User,
            validator=lambda a: a),
        )
        self.app.add_url_rule('/users/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
        user = self.User(name=u'John Matrix')
        self.db.session.add(user)
        self.db.session.commit()
    def create_models(self):
        TestCase.create_models(self)

        class TextMultiItem(self.Base):
            __tablename__ = 'textmultiitem'

            id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)

            name = sa.Column(sa.Unicode(255))
            content = sa.Column(sa.UnicodeText)
            name_vector = sa.Column(TSVectorType('name'))
            content_vector = sa.Column(TSVectorType('content'))

        self.TextMultiItem = TextMultiItem
Exemplo n.º 36
0
    def setup_method(self, method):
        @sa.event.listens_for(sa.orm.Session, 'before_flush')
        def before_flush(session, ctx, instances):
            for obj in session.dirty:
                obj.name = u'Updated article'

        self.before_flush = before_flush

        TestCase.setup_method(self, method)
        self.article = self.Article()
        self.article.name = u'Some article'
        self.article.content = u'Some content'
        self.session.add(self.article)
        self.session.commit()
    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/<int:id>/edit',
            view_func=UpdateFormView.as_view('edit',
            model_class=self.User,
            form_class=MockForm),
        )
        self.app.add_url_rule('/user/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
        user = self.User(name=u'John Matrix')
        self.db.session.add(user)
        self.db.session.commit()
    def create_models(self):
        TestCase.create_models(self)

        class TextMultiItem(self.Base):
            __tablename__ = 'textmultiitem'

            id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)

            name = sa.Column(sa.Unicode(255))
            content = sa.Column(sa.UnicodeText)
            name_vector = sa.Column(TSVectorType('name'))
            content_vector = sa.Column(TSVectorType('content'))

        self.TextMultiItem = TextMultiItem
Exemplo n.º 39
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.app = Flask(__name__)
        self.app.secret_key = 'secret'
        self.app.debug = True
        self.setup_views()
        login_manager = LoginManager()
        login_manager.init_app(self.app)
        self.client = self.app.test_client()
        self.context = self.app.test_request_context()
        self.context.push()

        @login_manager.user_loader
        def load_user(id):
            return self.session.query(self.User).get(id)
Exemplo n.º 40
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.app = Flask(__name__)
        self.app.secret_key = 'secret'
        self.app.debug = True
        self.setup_views()
        login_manager = LoginManager()
        login_manager.init_app(self.app)
        self.client = self.app.test_client()
        self.context = self.app.test_request_context()
        self.context.push()

        @login_manager.user_loader
        def load_user(id):
            return self.session.query(self.User).get(id)
Exemplo n.º 41
0
def load(location, requested_paths, excluded_paths, xul_tester, reldir=''):
    """
    Locates all tests by walking the filesystem starting at |location|.
    Uses xul_tester to evaluate any test conditions in the test header.
    Failure type and comment for a test case can come from
    - an external manifest entry for the test case,
    - an external manifest entry for a containing directory,
    - most commonly: the header of the test case itself.
    """
    manifestFile = os.path.join(location, 'jstests.list')
    externalManifestEntries = _parse_external_manifest(manifestFile, '')

    for root, basename in _find_all_js_files(location, location):
        # Get the full path and relative location of the file.
        filename = os.path.join(root, basename)
        if not _is_test_file(root, basename, filename, requested_paths,
                             excluded_paths):
            continue

        # Skip empty files.
        fullpath = os.path.join(location, filename)
        statbuf = os.stat(fullpath)

        testcase = TestCase(os.path.join(reldir, filename))
        _apply_external_manifests(filename, testcase, externalManifestEntries,
                                  xul_tester)
        _parse_test_header(fullpath, testcase, xul_tester)
        yield testcase
Exemplo n.º 42
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.equipment = [
            self.Equipment(
                id=2, name=u'E 1',
            ),
            self.Equipment(
                id=4, name=u'E 2',
            ),
            self.Equipment(
                id=6, name=u'E 3',
            ),
            self.Equipment(
                id=8, name=u'E 4',
            ),
        ]
        self.buildings = [
            self.Building(id=12, name=u'B 1', equipment=self.equipment[0]),
            self.Building(id=15, name=u'B 2', equipment=self.equipment[1]),
            self.Building(id=19, name=u'B 3'),
        ]
        self.business_premises = [
            self.BusinessPremise(
                id=22,
                name=u'BP 1',
                building=self.buildings[0]
            ),
            self.BusinessPremise(
                id=33,
                name=u'BP 2',
                building=self.buildings[0],
                equipment=self.equipment[2]
            ),
            self.BusinessPremise(
                id=44,
                name=u'BP 3',
                building=self.buildings[2],
                equipment=self.equipment[1]
            ),
        ]

        self.session.add_all(self.buildings)
        self.session.add_all(self.business_premises)
        self.session.add_all(self.equipment)
        self.session.commit()
Exemplo n.º 43
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.equipment = [
            self.Equipment(
                id=2, name=u'E 1',
            ),
            self.Equipment(
                id=4, name=u'E 2',
            ),
            self.Equipment(
                id=6, name=u'E 3',
            ),
            self.Equipment(
                id=8, name=u'E 4',
            ),
        ]
        self.buildings = [
            self.Building(id=12, name=u'B 1', equipment=self.equipment[0]),
            self.Building(id=15, name=u'B 2', equipment=self.equipment[1]),
            self.Building(id=19, name=u'B 3'),
        ]
        self.business_premises = [
            self.BusinessPremise(
                id=22,
                name=u'BP 1',
                building=self.buildings[0]
            ),
            self.BusinessPremise(
                id=33,
                name=u'BP 2',
                building=self.buildings[0],
                equipment=self.equipment[2]
            ),
            self.BusinessPremise(
                id=44,
                name=u'BP 3',
                building=self.buildings[2],
                equipment=self.equipment[1]
            ),
        ]

        self.session.add_all(self.buildings)
        self.session.add_all(self.business_premises)
        self.session.add_all(self.equipment)
        self.session.commit()
def mock_tnth_questionnairebanks():
    for name in (symptom_tracker_instruments):
        TestCase.add_questionnaire(name=name)

    # Symptom Tracker Baseline
    self_management = INTERVENTION.SELF_MANAGEMENT
    st_qb = QuestionnaireBank(
        name='symptom_tracker',
        classification='baseline',
        intervention_id=self_management.id,
        start='{"days": 0}',
        expired='{"months": 3}'
    )
    for rank, instrument in enumerate(symptom_tracker_instruments):
        q = Questionnaire.find_by_name(name=instrument)
        qbq = QuestionnaireBankQuestionnaire(questionnaire=q, rank=rank)
        st_qb.questionnaires.append(qbq)

    # Symptom Tracker Recurrence
    st_recur = Recur(
        start='{"months": 3}', cycle_length='{"months": 3}',
        termination='{"months": 27}')

    with SessionScope(db):
        db.session.add(st_qb)
        db.session.add(st_recur)
        db.session.commit()

    self_management = INTERVENTION.SELF_MANAGEMENT
    st_recur_qb = QuestionnaireBank(
        name='symptom_tracker_recurring',
        classification='recurring',
        intervention_id=self_management.id,
        start='{"days": 0}',
        expired='{"months": 3}',
        recurs=[st_recur]
    )
    for rank, instrument in enumerate(symptom_tracker_instruments):
        q = Questionnaire.find_by_name(name=instrument)
        qbq = QuestionnaireBankQuestionnaire(questionnaire=q, rank=rank)
        st_recur_qb.questionnaires.append(qbq)
    with SessionScope(db):
        db.session.add(st_recur_qb)
        db.session.commit()
Exemplo n.º 45
0
def mock_tnth_questionnairebanks():
    for name in (symptom_tracker_instruments):
        TestCase.add_questionnaire(name=name)

    # Symptom Tracker Baseline
    self_management = INTERVENTION.SELF_MANAGEMENT
    st_qb = QuestionnaireBank(
        name='symptom_tracker',
        classification='baseline',
        intervention_id=self_management.id,
        start='{"days": 0}',
        expired='{"months": 3}'
    )
    for rank, instrument in enumerate(symptom_tracker_instruments):
        q = Questionnaire.find_by_name(name=instrument)
        qbq = QuestionnaireBankQuestionnaire(questionnaire=q, rank=rank)
        st_qb.questionnaires.append(qbq)

    # Symptom Tracker Recurrence
    st_recur = Recur(
        start='{"months": 3}', cycle_length='{"months": 3}',
        termination='{"months": 27}')

    with SessionScope(db):
        db.session.add(st_qb)
        db.session.add(st_recur)
        db.session.commit()

    self_management = INTERVENTION.SELF_MANAGEMENT
    st_recur_qb = QuestionnaireBank(
        name='symptom_tracker_recurring',
        classification='recurring',
        intervention_id=self_management.id,
        start='{"days": 0}',
        expired='{"months": 3}',
        recurs=[st_recur]
    )
    for rank, instrument in enumerate(symptom_tracker_instruments):
        q = Questionnaire.find_by_name(name=instrument)
        qbq = QuestionnaireBankQuestionnaire(questionnaire=q, rank=rank)
        st_recur_qb.questionnaires.append(qbq)
    with SessionScope(db):
        db.session.add(st_recur_qb)
        db.session.commit()
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        articles = [
            self.Article(name=u'Article 1'),
            self.Article(name=u'Article 2'),
            self.Article(name=u'Article 3'),
            self.Article(name=u'Article 4'),
            self.Article(name=u'Article 5')
        ]
        self.session.add_all(articles)
        self.session.flush()

        category = self.Category(name=u'Category #1')
        category.articles = articles[0:2]
        category2 = self.Category(name=u'Category #2')
        category2.articles = articles[2:]
        self.session.add(category)
        self.session.add(category2)
        self.session.commit()
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        articles = [
            self.Article(name=u'Article 1'),
            self.Article(name=u'Article 2'),
            self.Article(name=u'Article 3'),
            self.Article(name=u'Article 4'),
            self.Article(name=u'Article 5')
        ]
        self.session.add_all(articles)
        self.session.flush()

        category = self.Category(name=u'Category #1')
        category.articles = articles[0:2]
        category2 = self.Category(name=u'Category #2')
        category2.articles = articles[2:]
        self.session.add(category)
        self.session.add(category2)
        self.session.commit()
Exemplo n.º 48
0
def load(location, requested_paths, excluded_paths, xul_tester, reldir=''):
    """
    Locates all tests by walking the filesystem starting at |location|.
    Uses xul_tester to evaluate any test conditions in the test header.
    Failure type and comment for a test case can come from
    - an external manifest entry for the test case,
    - an external manifest entry for a containing directory,
    - most commonly: the header of the test case itself.
    """
    # The list of tests that we are collecting.
    tests = []

    # Any file whose basename matches something in this set is ignored.
    EXCLUDED = set(
        ('browser.js', 'shell.js', 'jsref.js', 'template.js', 'user.js',
         'sta.js', 'test262-browser.js', 'test262-shell.js',
         'test402-browser.js', 'test402-shell.js', 'testBuiltInObject.js',
         'testIntl.js', 'js-test-driver-begin.js', 'js-test-driver-end.js'))

    manifestFile = os.path.join(location, 'jstests.list')
    externalManifestEntries = _parse_external_manifest(manifestFile, '')

    for root, basename in _find_all_js_files(location, location):
        # Skip js files in the root test directory.
        if not root:
            continue

        # Skip files that we know are not tests.
        if basename in EXCLUDED:
            continue

        # Get the full path and relative location of the file.
        filename = os.path.join(root, basename)
        fullpath = os.path.join(location, filename)

        # If any tests are requested by name, skip tests that do not match.
        if requested_paths \
           and not any(req in filename for req in requested_paths):
            continue

        # Skip excluded tests.
        if filename in excluded_paths:
            continue

        # Skip empty files.
        statbuf = os.stat(fullpath)
        if statbuf.st_size == 0:
            continue

        testcase = TestCase(os.path.join(reldir, filename))
        _apply_external_manifests(filename, testcase, externalManifestEntries,
                                  xul_tester)
        _parse_test_header(fullpath, testcase, xul_tester)
        tests.append(testcase)
    return tests
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        articles = [
            self.Article(id1=1, id2=2, name=u'Article 1'),
            self.Article(id1=2, id2=2, name=u'Article 2'),
            self.Article(id1=3, id2=3, name=u'Article 3'),
            self.Article(id1=4, id2=3, name=u'Article 4'),
            self.Article(id1=5, id2=3, name=u'Article 5')
        ]
        self.session.add_all(articles)
        self.session.flush()

        tags = [
            self.Tag(id1=1, id2=2, name=u'Tag 1'),
            self.Tag(id1=2, id2=3, name=u'Tag 2'),
            self.Tag(id1=3, id2=4, name=u'Tag 3')
        ]
        articles[0].tags = tags
        articles[3].tags = tags[1:]
        self.session.commit()
Exemplo n.º 50
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        articles = [
            self.Article(id1=1, id2=2, name=u'Article 1'),
            self.Article(id1=2, id2=2, name=u'Article 2'),
            self.Article(id1=3, id2=3, name=u'Article 3'),
            self.Article(id1=4, id2=3, name=u'Article 4'),
            self.Article(id1=5, id2=3, name=u'Article 5')
        ]
        self.session.add_all(articles)
        self.session.flush()

        tags = [
            self.Tag(id1=1, id2=2, name=u'Tag 1'),
            self.Tag(id1=2, id2=3, name=u'Tag 2'),
            self.Tag(id1=3, id2=4, name=u'Tag 3')
        ]
        articles[0].tags = tags
        articles[3].tags = tags[1:]
        self.session.commit()
Exemplo n.º 51
0
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.TextItem(
             name=u'index',
             content=u'some content'
         )
     )
     self.session.add(
         self.TextItem(
             name=u'admin',
             content=u'admin content'
         )
     )
     self.session.add(
         self.TextItem(
             name=u'home',
             content=u'this is the home page of [email protected]'
         )
     )
     self.session.commit()
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     text_items = [
         self.Article(name=u'Article 1'),
         self.Article(name=u'Article 2'),
         self.Article(name=u'Article 3'),
         self.Article(name=u'Article 4'),
         self.BlogPost(name=u'BlogPost 1'),
         self.BlogPost(name=u'BlogPost 2'),
         self.BlogPost(name=u'BlogPost 3'),
         self.BlogPost(name=u'BlogPost 4')
     ]
     self.session.add_all(text_items)
     self.session.flush()
     category = self.Category(name=u'Category #1')
     category.articles = text_items[0:2]
     category.blog_posts = text_items[4:7]
     category2 = self.Category(name=u'Category #2')
     category2.articles = text_items[2:4]
     category2.blog_posts = text_items[-1:]
     self.session.add(category)
     self.session.add(category2)
     self.session.commit()
 def setup_method(self, method):
     search_manager.options['regconfig'] = 'pg_catalog.simple'
     TestCase.setup_method(self, method)
     self.items = [
         self.TextItem(
             name=u'index',
             content=u'some content'
         ),
         self.TextItem(
             name=u'admin',
             content=u'admin content'
         ),
         self.TextItem(
             name=u'home',
             content=u'this is the home page of [email protected]'
         ),
         self.TextItem(
             name=u'not a some content',
             content=u'not a name'
         )
     ]
     self.session.add_all(self.items)
     self.session.commit()
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.users = [
         self.User(first_name=u'John', last_name=u'Matrix'),
         self.User(first_name=u'John', last_name=u'The Ripper')
     ]
     articles = [
         self.Article(
             id=1,
             name=u'Article 1',
             author=self.users[0]
         ),
         self.Article(
             id=2,
             name=u'Article 2',
             author=self.users[1]
         ),
         self.Article(
             id=3,
             name=u'Article 3'
         )
     ]
     self.session.add_all(articles)
     self.session.commit()
 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.users = [
         self.User(id=333, name=u'John'),
         self.User(id=334, name=u'Matt')
     ]
     articles = [
         self.Article(
             id=1,
             name=u'Article 1',
             author=self.users[0]
         ),
         self.Article(
             id=2,
             name=u'Article 2',
             author=self.users[1]
         ),
         self.Article(
             id=3,
             name=u'Article 3'
         )
     ]
     self.session.add_all(articles)
     self.session.commit()
Exemplo n.º 56
0
def load(location, xul_tester, reldir=''):
    """
    Locates all tests by walking the filesystem starting at |location|.
    Uses xul_tester to evaluate any test conditions in the test header.
    """
    # The list of tests that we are collecting.
    tests = []

    # Any file who's basename matches something in this set is ignored.
    EXCLUDED = set(
        ('browser.js', 'shell.js', 'jsref.js', 'template.js', 'user.js',
         'js-test-driver-begin.js', 'js-test-driver-end.js'))

    for root, basename in _find_all_js_files(location, location):
        # Skip js files in the root test directory.
        if not root:
            continue

        # Skip files that we know are not tests.
        if basename in EXCLUDED:
            continue

        # Get the full path and relative location of the file.
        filename = os.path.join(root, basename)
        fullpath = os.path.join(location, filename)

        # Skip empty files.
        statbuf = os.stat(fullpath)
        if statbuf.st_size == 0:
            continue

        # Parse the test header and load the test.
        testcase = TestCase(os.path.join(reldir, filename),
                            enable=True,
                            expect=True,
                            random=False,
                            slow=False,
                            debugMode=False)
        _parse_test_header(fullpath, testcase, xul_tester)
        tests.append(testcase)
    return tests
Exemplo n.º 57
0
 def tearDown(self):
     TestCase.tearDown(self)
     wx.GetApp().testing = False
Exemplo n.º 58
0
 def setUp(self):
     TestCase.setUp(self)
     wx.GetApp().testing = True
 def create_tables(self):
     self.connection.execute('DROP SCHEMA IF EXISTS other')
     self.connection.execute('CREATE SCHEMA other')
     TestCase.create_tables(self)