Пример #1
0
def test_check_row():
    row = {'name': 'Bob', 'age': '5', 'eye colour': 'blue'}
    assert check_row(row, ('age', '==', 5))
    assert not check_row(row, ('eye colour', '==', 5))
    assert check_row(row, ('eye colour', '==', 'blue'))
    assert check_row(row, ('age', '>=', 4))
    assert check_row(row, ('age', '<=', 1000))
Пример #2
0
def test_check_row_logical():
    row = {'name': 'Bob', 'age': '5', 'eye colour': 'blue'}
    assert check_row(row, (('age', '==', 5), 'OR', ('eye colour', '==', 5)))
    assert check_row(row, (('6', '==', 5), 'OR', ('eye colour', '==', 'blue')))
    assert not check_row(row,
                         (('6', '==', 5), 'OR', ('eye colour', '==', 'red')))
    assert not check_row(row,
                         (('age', '==', 5), 'AND', ('eye colour', '==', 5)))
Пример #3
0
 def test_2_2_tokens(self):
     mat = sol.matrix()
     mat[0][0] = 'O'
     mat[0][1] = 'O'
     mat[1][1] = 'O'
     mat[1][2] = 'O'
     self.assertEqual(False, sol.check_row(mat, 'O'))
Пример #4
0
 def test_1_2__1_3_tokens(self):
     mat = sol.matrix()
     mat[0][0] = 'X'
     mat[0][1] = 'X'
     mat[1][0] = 'O'
     mat[1][1] = 'O'
     mat[1][2] = 'O'
     self.assertEqual(True, sol.check_row(mat, 'O'))
Пример #5
0
def test_check_row2():
    row = {
        'house': 'Harkonnen',
        'origin': 'Hakkon',
        'color': 'red',
        'enemy': 'Atreides'
    }
    assert not check_row(row, ('house', '==', 'Atreides'))
    assert check_row(row, ('house', '==', 'Harkonnen'))
    assert check_row(row, ('house', '>=', 'Atreides'))
    assert check_row(row, ('25', '==', '25'))
    assert check_row(row, (6, '>=', '5'))
    assert check_row(row, (99, '<=', 100))
    assert check_row(row, (101, '>=', 100))
    assert check_row(row, ('snow', '<=', 'snow'))
    assert check_row(row, ('shoe', '<=', 'show'))
    assert not check_row(row, ('shoe', '>=', 'show'))
    assert not check_row(row, ('', '==', 'a'))
    assert check_row(row, ('', '==', ''))
    assert check_row(row, ('', '', ''))
Пример #6
0
 def test_0_token(self):
     mat = sol.matrix()
     mat[0][0] = 'X'
     mat[2][2] = 'O'
     self.assertEqual(False, sol.check_row(mat, 'X'))