コード例 #1
0
ファイル: test_combo.py プロジェクト: matt-bernhardt/trapp
def test_combo_lookupCombos_needsDict():
    c = Combo()
    c.connectDB()
    with pytest.raises(RuntimeError) as excinfo:
        needle1 = 1
        needle2 = 'Foo'
        c.data = c.lookupCombos(needle1, needle2)
    assert 'lookupID requires two integers' in str(excinfo.value)
コード例 #2
0
    def lookupCombos(self):
        # This iterates over the self.combos array and looks up whether each
        # is recorded already

        c = Combo()
        c.connectDB()

        for group in self.combos:

            self.log.message(str(group))

            group['combos'] = c.lookupCombos(
                group['player1'],
                group['player2']
            )

            # There should be four id values:
            # both, neither, one, and the other
            # Just looking at counts isn't enough, but it is a start.
            if(len(group['combos']) == 4):
                # No action needed
                self.log.message('All present')
            elif(len(group['combos']) == 0):
                # None exist - so we create them
                self.log.message('Create all')
                c.registerCombo(
                    group['player1'],
                    group['player2']
                )
            else:
                # Some other number exists. WTF?
                self.log.message('Some present')
                raise RuntimeError('Incorrect number of combinations found')

            self.log.message('')

        c.disconnectDB()

        return True
コード例 #3
0
ファイル: test_combo.py プロジェクト: matt-bernhardt/trapp
def test_combo_lookupCombos():
    c = Combo()
    c.connectDB()
    c.data = c.lookupCombos(1, 2)
    assert len(c.data) == 4
コード例 #4
0
ファイル: test_combo.py プロジェクト: matt-bernhardt/trapp
def test_combo_disconnect():
    c = Combo()
    c.connectDB()
    assert hasattr(c, 'db')
    c.disconnectDB()
    assert hasattr(c, 'db') is False