Exemplo n.º 1
0
 def test_no_boards(self):
     """
     Test: Call create_feed without boards.
     Expected result: Feed will be created without any boards.
     """
     #Create a feed with only one of the boards:
     feed = logic.create_feed(self.user, False, False, 15, [])
     self.assertEqual(len(feed.boards.all()), 0)
Exemplo n.º 2
0
 def test_unassigned_not_added(self):
     """
     Test: Test that the unsassigned flag in the feed is respected.
     Expected result: Only the assigned cards in bot boards will be in the feed.
     """
     #Create a feed with only assigned cards:
     feed = logic.create_feed(self.user, True, False, 15, TEST_BOARDS)
     cal = logic.create_calendar_from_feed(feed)
     
     #check that there are entries from both boards, but only assigned ones:
     self.assertEqual(len(cal.subcomponents), 2, "More cards then expected.")
     for comp in cal.subcomponents:
         self.assertFalse("na" in comp["SUMMARY"], "Not assigned card added to cal.")
Exemplo n.º 3
0
 def test_subset_of_boards(self):
     """
     Test: Create a calendar from a subset of the boards the user has.
     Expected result: Only the requested boards will be in calendar.
     """
     #Create a feed with only one of the boards:
     feed = logic.create_feed(self.user, False, False, 15, TEST_BOARDS[:1])
     cal = logic.create_calendar_from_feed(feed)
     
     #check that there are entries from test board 1 but not test board 2:
     self.assertEqual(len(cal.subcomponents), 2, "More cards then expected.")
     for comp in cal.subcomponents:
         self.assertTrue(comp["SUMMARY"].startswith("tb1"), "Wrong test board cards added.")
         self.assertFalse("nd" in comp["SUMMARY"], "No due date card was added.")
Exemplo n.º 4
0
 def test_with_boards_in_db(self):
     """
     Test: Call create_feed with boards that are already in db.
     Expected result: A feed with boards will be returned.
     """
     #Create a feed with only one of the boards:
     models.Board(board_id=TEST_BOARDS[1], name="some name").save()
     
     feed = logic.create_feed(self.user, False, False, 15, TEST_BOARDS[1:])
     
     self.assertEqual(len(feed.boards.all()), 1, "Wrong number of boards returned")
     self.assertFalse(feed.only_assigned)
     self.assertFalse(feed.is_all_day_event)
     self.assertEqual(feed.event_length, 15)
Exemplo n.º 5
0
    def test_no_user(self):
        """
        Test: User doesn't exist in session.
        Expected result: Error will be returned.
        """
        request = self.factory.get('/doesnt/matter')
        request.session = {}
        
        feed = logic.create_feed(self.user, True, True, 15, [])

        json_ret = json.loads(ajax.delete_feed(request, feed.id))
        
        self.assertFalse(json_ret["deleted"], "Feed was deleted")
        self.assertEqual(json_ret["error"], "You need to be authorized to call this.", "Error is wrong.")
        self.assertTrue(feed.is_valid, "Feed was marked as invalid.")
Exemplo n.º 6
0
    def test_delete_feed(self):
        """
        Test: User exists and feed exists.
        Expected result: No exceptions are raised
        """
        request = self.factory.get('/doesnt/matter')
        request.session = {"cur_user" : self.user.id}
        
        feed = logic.create_feed(self.user, True, True, 15, [])

        json_ret = json.loads(ajax.delete_feed(request, feed.id))
        feed = models.Feed.objects.get(id = feed.id)
        
        self.assertTrue(json_ret["deleted"], "Feed was not deleted")
        self.assertEqual(json_ret["feed_id"], feed.id, "Feed id is wrong.")
        self.assertFalse(feed.is_valid, "Feed was not marked as invalid.")
Exemplo n.º 7
0
 def test_exception(self):
     """
     Test: An exception is raised main code.
     Expected result: Error will be returned.
     """
     request = self.factory.get('/doesnt/matter')
     request.session = {"cur_user" : self.user.id}
     
     original_get_user_from_user_id = ajax._get_user_from_user_id
     ajax._get_user_from_user_id = raise_exception
     
     feed = logic.create_feed(self.user, True, True, 15, [])
     
     json_ret = json.loads(ajax.delete_feed(request, feed.id))
     ajax._get_user_from_user_id = original_get_user_from_user_id
     
     self.assertFalse(json_ret["deleted"], "Feed was deleted")
     self.assertTrue(EXCEPTION_STRING in json_ret["error"], "Error is wrong.")
     self.assertTrue(feed.is_valid, "Feed was deleted.")
Exemplo n.º 8
0
 def test_with_boards_not_in_db(self):
     """
     Test: Call create_feed with boards not in the db.
     Expected result: A feed with boards will be returned and board will be created in db.
     """
     try:
         models.Board.objects.get(board_id=TEST_BOARDS[0])
         self.fail("A board was already in the db.")
     except models.Board.DoesNotExist:
         pass
     
     feed = logic.create_feed(self.user, False, False, 15, TEST_BOARDS[:1])
     
     self.assertEqual(len(feed.boards.all()), 1, "Wrong number of boards returned")
     self.assertFalse(feed.only_assigned)
     self.assertFalse(feed.is_all_day_event)
     self.assertEqual(feed.event_length, 15)
     
     models.Board.objects.get(board_id=TEST_BOARDS[0])
Exemplo n.º 9
0
 def setUp(self):
     self.user = logic.get_or_create_user(USER_TOKEN, "some name", USER_ID, "*****@*****.**")
     self.feed = logic.create_feed(self.user, False, False, 15, TEST_BOARDS)