class CanFetchTicketPositionsInBacklogWithJSONTest(AgiloTestCase):
    def setUp(self):
        self.super()
        self.view = SprintListView(self.env)

    def call(self, name_of_last_visited_sprint=None):
        req = self.teh.mock_request(
            session={'agilo-1-scope': name_of_last_visited_sprint})
        return self.view.list_sprints(req)

    def test_can_get_list_of_sprints_from_view(self):
        self.teh.create_sprint('running 1')

        self.teh.create_sprint('to start 1',
                               start=in_days(10),
                               end=in_days(20))
        self.teh.create_sprint('to start 2',
                               start=in_days(10),
                               end=in_days(20))

        self.teh.create_sprint('closed 1',
                               start=before_days(10),
                               end=before_days(5))
        self.teh.create_sprint('closed 2',
                               start=before_days(10),
                               end=before_days(5))
        self.teh.create_sprint('closed 3',
                               start=before_days(10),
                               end=before_days(5))

        running, to_start, closed = self.call()
        self.assert_equals(1, len(running[Key.OPTIONS]))
        self.assert_equals(2, len(to_start[Key.OPTIONS]))
        self.assert_equals(3, len(closed[Key.OPTIONS]))

    def test_will_mark_last_viewed_sprint_from_session(self):
        self.teh.create_sprint('running 1')
        self.teh.create_sprint('running 2')

        running, to_start, closed = self.call('running 1')
        self.assert_equals(2, len(running[Key.OPTIONS]))
        self.assert_equals(0, len(to_start[Key.OPTIONS]))
        self.assert_equals(0, len(closed[Key.OPTIONS]))

        first, second = running[Key.OPTIONS]
        self.assert_equals('running 1', first[0])
        self.assert_true(first[1])
        self.assert_equals('running 2', second[0])
        self.assert_false(second[1])
class CanFetchTicketPositionsInBacklogWithJSONTest(AgiloTestCase):
    
    def setUp(self):
        self.super()
        self.view = SprintListView(self.env)
    
    def call(self, name_of_last_visited_sprint=None):
        req = self.teh.mock_request(session={'agilo-1-scope': name_of_last_visited_sprint})
        return self.view.list_sprints(req)
    
    def test_can_get_list_of_sprints_from_view(self):
        self.teh.create_sprint('running 1')

        self.teh.create_sprint('to start 1', start=in_days(10), end=in_days(20))
        self.teh.create_sprint('to start 2', start=in_days(10), end=in_days(20))
        
        self.teh.create_sprint('closed 1', start=before_days(10), end=before_days(5))
        self.teh.create_sprint('closed 2', start=before_days(10), end=before_days(5))
        self.teh.create_sprint('closed 3', start=before_days(10), end=before_days(5))
        
        running, to_start, closed = self.call()
        self.assert_equals(1, len(running[Key.OPTIONS]))
        self.assert_equals(2, len(to_start[Key.OPTIONS]))
        self.assert_equals(3, len(closed[Key.OPTIONS]))
    
    def test_will_mark_last_viewed_sprint_from_session(self):
        self.teh.create_sprint('running 1')
        self.teh.create_sprint('running 2')
        
        running, to_start, closed = self.call('running 1')
        self.assert_equals(2, len(running[Key.OPTIONS]))
        self.assert_equals(0, len(to_start[Key.OPTIONS]))
        self.assert_equals(0, len(closed[Key.OPTIONS]))
        
        first, second = running[Key.OPTIONS]
        self.assert_equals('running 1', first[0])
        self.assert_true(first[1])
        self.assert_equals('running 2', second[0])
        self.assert_false(second[1])
 def setUp(self):
     self.super()
     self.view = SprintListView(self.env)
 def setUp(self):
     self.super()
     self.view = SprintListView(self.env)