Exemple #1
0
 def test_populate(self):
     words =['where','is','world','taking','us','spontaneously','this','one','will','do', 'just', 'fine', 'thankyou']
     directions = WSdirections()
     test = WSmatrix((11,11),directions.Right | directions.Left, words, wstext=self.wstext)
     matrix, accepted, rejected = test.populate()
     #assert rejected == ['spontaneously', 'is', 'us']
     assert len(accepted) == 10
Exemple #2
0
 def test_populate_matrix1(self):
     words = ['bitspace', 'extras']
     directions = WSdirections()
     test = WSmatrix((7, 9), directions.DiagDwnLeft, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     assert rejected == []
Exemple #3
0
 def test_longlist(self):
     words =['bitspace','extras','officious', 'as','it','may','seem','to','some','considering',
     'the','significance','wonderous','proposals','obstinate','peter','paul','mary','children','christmas',
     'trees','foundations','thrillseeking','frivolous']
     directions = WSdirections()
     test = WSmatrix((7,9),directions.Right|directions.Left|directions.Up|directions.Down,words)
     success, matrix, accepted, rejected = test.populate_matrix(test.matrix, words)
Exemple #4
0
 def test_canInsertWord(self):
     words =['this','one','will','do']
     directions = WSdirections()
     test = WSmatrix((11,11),directions.Right | directions.Left,words)
     for word in words:
         answer = test.canInsertWord(word, (0,0), directions.Right, test.matrix)
         assert answer == True
     assert test.canInsertWord('this is a very long word not to fit in grid', (0,0), directions.Right, test.matrix) == False
Exemple #5
0
 def test_cell_init(self):
     test = WSmatrix()
     maxx=30
     maxy=25
     matrix, available, minleftover = test.init_cells(maxx,maxy)
     assert len(matrix) == maxx
     assert len(matrix[0]) == maxy
     assert available == (maxx * maxy)
     assert minleftover == int(0.01 * available)
Exemple #6
0
 def test_cell_init(self):
     test = WSmatrix()
     maxx = 30
     maxy = 25
     matrix, available, minleftover = test.init_cells(maxx, maxy)
     assert len(matrix) == maxx
     assert len(matrix[0]) == maxy
     assert available == (maxx * maxy)
     assert minleftover == int(0.01 * available)
Exemple #7
0
 def setUpAll(self):
     words =['bitspaceX', 'this','one','will','do', 'just', 'fine', 'thankyou']
     directions = WSdirections()
     test = WSmatrix((5,9),directions.DiagDwnRight,words)
     success, matrix, accepted, rejected = test.populate_matrix(test.matrix, words)
     self.format = WSformats()
     self.format.matrix = matrix
     self.format.accepted = accepted
     self.format.rejected = rejected
     self.format.solution = test.wordsplaced
Exemple #8
0
    def test_directions(self):
        test = WSmatrix()
        directions = WSdirections()
        assert test.directions == [directions.Right]
        
        test.set_directions(directions.Right | directions.Left)
        assert test.directions == [directions.Right, directions.Left]

        test.set_directions(directions.Right | directions.Left | directions.Up | directions.Down)
        assert test.directions == [directions.Right, directions.Left, directions.Up, directions.Down]
Exemple #9
0
 def test_populate_matrix(self):
     words = [
         'bitspaceX', 'this', 'one', 'will', 'do', 'just', 'fine',
         'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((10, 10), directions.DiagDwnRight | directions.Right,
                     words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     assert rejected == []
Exemple #10
0
 def test_startGrid(self):
     directions = WSdirections()
     test = WSmatrix((10,10),directions.Right | directions.Left,self.words)
     matrix = test.startGrid(directions.Right, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Down, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Right,9)
     assert len(matrix) == 20
     matrix = test.startGrid(directions.DiagDwnRight,10)
     assert len(matrix) == 1
Exemple #11
0
 def test_canInsertWord(self):
     words = ['this', 'one', 'will', 'do']
     directions = WSdirections()
     test = WSmatrix((11, 11), directions.Right | directions.Left, words)
     for word in words:
         answer = test.canInsertWord(word, (0, 0), directions.Right,
                                     test.matrix)
         assert answer == True
     assert test.canInsertWord(
         'this is a very long word not to fit in grid', (0, 0),
         directions.Right, test.matrix) == False
Exemple #12
0
 def test_longlist(self):
     words = [
         'bitspace', 'extras', 'officious', 'as', 'it', 'may', 'seem', 'to',
         'some', 'considering', 'the', 'significance', 'wonderous',
         'proposals', 'obstinate', 'peter', 'paul', 'mary', 'children',
         'christmas', 'trees', 'foundations', 'thrillseeking', 'frivolous'
     ]
     directions = WSdirections()
     test = WSmatrix((7, 9), directions.Right | directions.Left
                     | directions.Up | directions.Down, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
Exemple #13
0
 def test_populate(self):
     words = [
         'where', 'is', 'world', 'taking', 'us', 'spontaneously', 'this',
         'one', 'will', 'do', 'just', 'fine', 'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((11, 11),
                     directions.Right | directions.Left,
                     words,
                     wstext=self.wstext)
     matrix, accepted, rejected = test.populate()
     #assert rejected == ['spontaneously', 'is', 'us']
     assert len(accepted) == 10
Exemple #14
0
 def setUpAll(self):
     words = [
         'bitspaceX', 'this', 'one', 'will', 'do', 'just', 'fine',
         'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((5, 9), directions.DiagDwnRight, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     self.format = WSformats()
     self.format.matrix = matrix
     self.format.accepted = accepted
     self.format.rejected = rejected
     self.format.solution = test.wordsplaced
Exemple #15
0
 def test_init(self):
     directions = WSdirections()
     test = WSmatrix((11, 11), directions.Right | directions.Left,
                     self.words)
     assert test.maxrow == 11
     assert test.maxcol == 11
     assert test.directions == [directions.Right, directions.Left]
     assert test.wordlist == self.words
     print directions
Exemple #16
0
    def test_insertWord(self):
        words = [
            'this', 'one', 'will', 'do', 'nicely', 'fine', 'thankyou',
            'seriouslybroken'
        ]
        directions = WSdirections()
        test = WSmatrix((5, 9), directions.Right | directions.Left, words)
        matrix = test.matrix
        assert test.canInsertWord(words[0], (0, 0), directions.Right,
                                  matrix) == True

        test.debug = False
        assert test.canInsertWord(words[1:][0], (0, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[1:][0], (1, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[2], (2, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[3], (3, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[4], (4, 0), directions.Right,
                                  matrix) == True
Exemple #17
0
 def test_startGrid(self):
     directions = WSdirections()
     test = WSmatrix((10, 10), directions.Right | directions.Left,
                     self.words)
     matrix = test.startGrid(directions.Right, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Down, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Right, 9)
     assert len(matrix) == 20
     matrix = test.startGrid(directions.DiagDwnRight, 10)
     assert len(matrix) == 1
Exemple #18
0
    def test_directions(self):
        test = WSmatrix()
        directions = WSdirections()
        assert test.directions == [directions.Right]

        test.set_directions(directions.Right | directions.Left)
        assert test.directions == [directions.Right, directions.Left]

        test.set_directions(directions.Right | directions.Left | directions.Up
                            | directions.Down)
        assert test.directions == [
            directions.Right, directions.Left, directions.Up, directions.Down
        ]
Exemple #19
0
 def test_insertWord(self):
     words =['this','one','will','do','nicely', 'fine', 'thankyou','seriouslybroken']
     directions = WSdirections()
     test = WSmatrix((5,9),directions.Right | directions.Left,words)
     matrix = test.matrix
     assert test.canInsertWord(words[0], (0,0), directions.Right,matrix) == True
     
     test.debug = False
     assert test.canInsertWord(words[1:][0], (0,0), directions.Right,matrix) == True
     assert test.canInsertWord(words[1:][0], (1,0), directions.Right,matrix) == True
     assert test.canInsertWord(words[2], (2,0), directions.Right,matrix) == True
     assert test.canInsertWord(words[3], (3,0), directions.Right,matrix) == True
     assert test.canInsertWord(words[4], (4,0), directions.Right,matrix) == True
Exemple #20
0
 def test_insertWord(self):
     test = WSmatrix()
Exemple #21
0
 def test_populate_matrix(self):
     words =['bitspaceX', 'this','one','will','do', 'just', 'fine', 'thankyou']
     directions = WSdirections()
     test = WSmatrix((10,10),directions.DiagDwnRight | directions.Right,words)
     success, matrix, accepted, rejected = test.populate_matrix(test.matrix, words)
     assert rejected == []
Exemple #22
0
 def test_size(self):
     test = WSmatrix((15, 15))
     assert test.maxrow == 15
     assert test.maxcol == 15
Exemple #23
0
 def test_populate_matrix1(self):
     words =['bitspace','extras']
     directions = WSdirections()
     test = WSmatrix((7,9),directions.DiagDwnLeft,words)
     success, matrix, accepted, rejected = test.populate_matrix(test.matrix, words)
     assert rejected == []