def __init__(self):

        self.problems = (Problem(id=1,
                                 RIC=RIC(4, 4, 3),
                                 grade=Grade('red', 'mid'),
                                 colour='red',
                                 sector='arch l',
                                 styles=('toe hook', 'pop'),
                                 set_by='Thara',
                                 set_date=datetime.date(2021, 1, 2),
                                 strip_date=None),
                         Problem(id=2,
                                 RIC=RIC(5, 2, 3),
                                 grade=Grade('black', 'mid'),
                                 colour='orange',
                                 sector='arch l',
                                 styles=('run', 'press'),
                                 set_by='Aaron',
                                 set_date=datetime.date(2021, 2, 2),
                                 strip_date=None),
                         Problem(id=3,
                                 RIC=RIC(1, 1, 1),
                                 grade=Grade('green', 'easy'),
                                 colour='green',
                                 sector='tower r',
                                 styles=('s', ),
                                 set_by='s',
                                 set_date=datetime.date(2021, 2, 16),
                                 strip_date=None))
        self._next_id = 4
    def test_update_new_problem(self):
        problem4 = Problem(id=4,
                           RIC=RIC(1, 1, 1),
                           grade=Grade('green', 'easy'),
                           colour='green',
                           sector='tower r',
                           styles=('s', ),
                           set_by='s',
                           set_date=datetime.date(2021, 2, 16),
                           strip_date=None)
        problem5 = Problem(id=4,
                           RIC=RIC(1, 2, 1),
                           grade=Grade('green', 'mid'),
                           colour='green',
                           sector='tower r',
                           styles=('s', ),
                           set_by='s',
                           set_date=datetime.date(2021, 2, 16),
                           strip_date=None)
        self.editor.add_new_problem(problem4)
        self.editor.add_new_problem(problem5)
        problems = self.editor.problems
        problem = self.editor.get_problem_by_id(4)

        self.assertEqual(len(problems), 4)
        self.assertEqual(problem, problem5)
    def test_undo_then_backup(self):
        problem4 = Problem(id=4, RIC=RIC(1, 1, 1), grade=Grade('green', 'easy'), colour='green', sector='tower r', styles=('s',), set_by='s', set_date=datetime.date(2021, 2, 16), strip_date=None)
        problem5 = Problem(id=4, RIC=RIC(1, 1, 1), grade=Grade('green', 'easy'), colour='orange', sector='tower r', styles=('s',), set_by='s', set_date=datetime.date(2021, 2, 16), strip_date=None)
        self.editor.add_new_problem(problem4)
        self.history.backup()
        self.history.undo()
        self.editor.add_new_problem(problem5)
        self.history.backup()
        problem  = self.editor.get_problem_by_id(4)

        self.assertEqual(len(self.editor.problems), 4)
        self.assertEqual(self.editor.next_id, 5)
        self.assertEqual(problem.colour, "orange")
Example #4
0
 def setUp(self):
     self.problem = Problem(2, RIC(1, 2, 3), Grade('purple',
                                                   'mid'), 'purple',
                            'cave l', ['pop', 'layback', 'power'], 'Thara',
                            date.today(), 'on')
     self.builder = ProblemCellDataBuilder(GradeDict(), ColourDict(),
                                           SectorDict())
Example #5
0
class MockFileIO():

    data = tuple([
        Problem(id=12,
                RIC=RIC(1, 1, 1),
                grade=Grade('purple', 'mid'),
                colour='purple',
                sector='mid',
                styles=('pop', ),
                set_by='d',
                set_date=datetime.date(2021, 2, 25),
                strip_date=datetime.date(2021, 2, 26)),
        Problem(id=11,
                RIC=RIC(1, 1, 1),
                grade=Grade('purple', 'mid'),
                colour='red',
                sector='mid',
                styles=('dyno', 'pop'),
                set_by='d',
                set_date=datetime.date(2021, 2, 25),
                strip_date=datetime.date(2021, 2, 26)),
        Problem(id=10,
                RIC=RIC(1, 1, 1),
                grade=Grade('purple', 'mid'),
                colour='purple',
                sector='mid',
                styles=('glide', ),
                set_by='d',
                set_date=datetime.date(2021, 2, 25),
                strip_date=datetime.date(2021, 2, 26)),
        Problem(id=9,
                RIC=RIC(1, 1, 1),
                grade=Grade('purple', 'mid'),
                colour='red',
                sector='front',
                styles=('dyno', ),
                set_by='d',
                set_date=datetime.date(2021, 2, 25),
                strip_date=datetime.date(2021, 2, 26))
    ])

    def get_all_problems(self):
        return self.data

    def filter_problems_by(self, predicate) -> tuple[Problem, ...]:
        return tuple([p for p in self.data if predicate(p)])
Example #6
0
    def _make_new_problem(self, row: int, col: int):
        # return a new problem with new auto increment id

        _id = self._editor.next_id
        _grade = Setting.get(GradeSetting).get_grade(row)
        _hold = str(_grade).split(' ')[0]
        _sector = self._dependency.get(SectorEditor).get_sector(col)

        return Problem(_id, RIC(1, 1, 1), _grade, _hold, _sector, (), '',
                       date.today(), 'on')
 def test_add_incorrect_problem(self):
     problem5 = Problem(id=5,
                        RIC=RIC(1, 1, 1),
                        grade=Grade('green', 'easy'),
                        colour='green',
                        sector='tower r',
                        styles=('s', ),
                        set_by='s',
                        set_date=datetime.date(2021, 2, 16),
                        strip_date=None)
     with self.assertRaises(ValueError):
         self.editor.add_new_problem(problem5)
 def test_add_same_problem(self):
     # can't update the problems from previous set
     problem1 = Problem(id=1,
                        RIC=RIC(1, 1, 1),
                        grade=Grade('green', 'easy'),
                        colour='green',
                        sector='tower r',
                        styles=('s', ),
                        set_by='s',
                        set_date=datetime.date(2021, 2, 16),
                        strip_date=None)
     with self.assertRaises(ValueError):
         self.editor.add_new_problem(problem1)
Example #9
0
    def _try_make_problem(self):

        _id = int(self.view.text_id.text())
        _r = int(self.view.dropdown_r.currentText())
        _i = int(self.view.dropdown_i.currentText())
        _c = int(self.view.dropdown_c.currentText())
        ric = RIC(_r, _i, _c)
        grade = Grade.from_str(self.view.text_grade.text())
        colour = self.view.dropdown_hold.currentText()
        sector = self.view.text_sector.text().lower()
        styles = self._get_styles_tuple()
        set_by = self.view.lineedit_set_by.text()
        set_date = date.fromisoformat(self.view.lineedit_set_date.text())
        strip_date = None

        return Problem(_id, ric, grade, colour, sector, styles, set_by,
                       set_date, strip_date)
    def test_delete_problem(self):
        problem4 = Problem(id=4,
                           RIC=RIC(1, 1, 1),
                           grade=Grade('green', 'easy'),
                           colour='green',
                           sector='tower r',
                           styles=('s', ),
                           set_by='s',
                           set_date=datetime.date(2021, 2, 16),
                           strip_date=None)
        self.editor.add_new_problem(problem4)
        self.editor.delete_problem(2)
        self.editor.delete_problem(4)
        result2 = self.editor.get_problem_by_id(2)
        result4 = self.editor.get_problem_by_id(4)

        self.assertEqual(type(result2), Problem)
        self.assertEqual(result4, None)
    def test_strip_problem(self):
        problem4 = Problem(id=4,
                           RIC=RIC(1, 1, 1),
                           grade=Grade('green', 'easy'),
                           colour='green',
                           sector='tower r',
                           styles=('s', ),
                           set_by='s',
                           set_date=datetime.date(2021, 2, 16),
                           strip_date=None)
        self.editor.add_new_problem(problem4)
        self.editor.strip_problem(2, datetime.date.today())
        with self.assertRaises(IndexError):
            self.editor.strip_problem(4, datetime.date.today())
        problems = self.editor.problems
        problem = self.editor.get_problem_by_id(2)

        self.assertEqual(len(problems), 3)
        self.assertEqual(problem, None)
Example #12
0
    def test_constructer(self):
        self.ric = RIC(1, 2, 3)

        self.assertEqual(self.ric.R, 1)
        self.assertEqual(self.ric.I, 2)
        self.assertEqual(self.ric.C, 3)
Example #13
0
 def test_try_set_value(self):
     self.ric = RIC(1, 2, 3)
     with self.assertRaises(AttributeError):
         self.ric.R = 2
Example #14
0
 def test_construct_with_out_of_range_value(self):
     with self.assertRaises(ValueError):
         self.ric = RIC(1, 2, 6)
Example #15
0
 def test_construct_with_string(self):
     with self.assertRaises(TypeError):
         self.ric = RIC('1', 2, 5)