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
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 == []
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)
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
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)
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)
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
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]
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 == []
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
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
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)
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
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
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
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
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
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 ]
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
def test_insertWord(self): test = WSmatrix()
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 == []
def test_size(self): test = WSmatrix((15, 15)) assert test.maxrow == 15 assert test.maxcol == 15
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 == []