<commit_before>from django.test import TestCase
from django.conf import settings
from restclients.exceptions import DataFailureException
from restclients.trumba.calendar import Calendar
from restclients.trumba.exceptions import TrumbaException, CalendarNotExist, CalendarOwnByDiffAccount, NoDataReturned, UnknownError, UnexpectedError

class TrumbaTestCalendars(TestCase):

    def test_get_bot_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_BOT_DAO_CLASS='restclients.dao_implementation.trumba.FileBot'
            ):
            result = Calendar.get_bot_calendars()
            self.assertTrue(result is not None and len(result) == 4)

    def test_get_sea_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_SEA_DAO_CLASS='restclients.dao_implementation.trumba.FileSea'
            ):
            result = Calendar.get_sea_calendars()
            self.assertIsNotNone(result)
            self.assertTrue(len(result) == 10)

            trumba_cal = result[1]
            self.assertEqual(trumba_cal.calendarid, 1)
            self.assertEqual(trumba_cal.campus, 'sea')
            self.assertEqual(trumba_cal.name, 'Seattle calendar')
            self.assertTrue(trumba_cal.is_sea())
            self.assertFalse(trumba_cal.is_bot())
            self.assertFalse(trumba_cal.is_tac())
            
            trumba_cal = result[11321]
            self.assertEqual(trumba_cal.calendarid, 11321)
            self.assertEqual(trumba_cal.campus, 'sea')
            self.assertEqual(trumba_cal.name, 'Seattle child-sub-sub-calendar321')
            self.assertTrue(trumba_cal.is_sea())
            self.assertFalse(trumba_cal.is_bot())
            self.assertFalse(trumba_cal.is_tac())

            
    def test_get_tac_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_TAC_DAO_CLASS='restclients.dao_implementation.trumba.FileTac'
            ):
            self.assertIsNotNone(Calendar.get_tac_calendars())
            self.assertTrue(len(Calendar.get_tac_calendars()) == 1)
            

    def test_get_sea_permissions_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_SEA_DAO_CLASS='restclients.dao_implementation.trumba.FileSea'
            ):
            result = Calendar.get_sea_permissions(1)
            self.assertIsNotNone(result)
            self.assertTrue(len(result) == 3)
            perm = result[0]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, '<NAME>')
            self.assertEqual(perm.uwnetid, 'dummyp')
            self.assertEqual(perm.level, 'PUBLISH')
            self.assertFalse(perm.is_edit())
            self.assertFalse(perm.is_showon())
            self.assertTrue(perm.is_sea())
            self.assertFalse(perm.is_bot())
            self.assertFalse(perm.is_tac())

            perm = result[1]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, '<NAME>')
            self.assertEqual(perm.uwnetid, 'dummye')
            self.assertEqual(perm.level, 'EDIT')
            self.assertTrue(perm.is_edit())
            self.assertFalse(perm.is_showon())
            self.assertTrue(perm.is_sea())
            self.assertFalse(perm.is_bot())
            self.assertFalse(perm.is_tac())

            perm = result[2]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, '<NAME>')
            self.assertEqual(perm.uwnetid, 'dummys')
            self.assertEqual(perm.level, 'SHOWON')<commit_msg>Revise assertion as publish permission is treated as an editor permission.<commit_after>from django.test import TestCase
from django.conf import settings
from restclients.exceptions import DataFailureException
from restclients.trumba.calendar import Calendar
from restclients.trumba.exceptions import TrumbaException, CalendarNotExist, CalendarOwnByDiffAccount, NoDataReturned, UnknownError, UnexpectedError

class TrumbaTestCalendars(TestCase):

    def test_get_bot_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_BOT_DAO_CLASS='restclients.dao_implementation.trumba.FileBot'
            ):
            result = Calendar.get_bot_calendars()
            self.assertTrue(result is not None and len(result) == 4)

    def test_get_sea_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_SEA_DAO_CLASS='restclients.dao_implementation.trumba.FileSea'
            ):
            result = Calendar.get_sea_calendars()
            self.assertIsNotNone(result)
            self.assertTrue(len(result) == 10)

            trumba_cal = result[1]
            self.assertEqual(trumba_cal.calendarid, 1)
            self.assertEqual(trumba_cal.campus, 'sea')
            self.assertEqual(trumba_cal.name, 'Seattle calendar')
            self.assertTrue(trumba_cal.is_sea())
            self.assertFalse(trumba_cal.is_bot())
            self.assertFalse(trumba_cal.is_tac())
            
            trumba_cal = result[11321]
            self.assertEqual(trumba_cal.calendarid, 11321)
            self.assertEqual(trumba_cal.campus, 'sea')
            self.assertEqual(trumba_cal.name, 'Seattle child-sub-sub-calendar321')
            self.assertTrue(trumba_cal.is_sea())
            self.assertFalse(trumba_cal.is_bot())
            self.assertFalse(trumba_cal.is_tac())

            
    def test_get_tac_calendars_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_TAC_DAO_CLASS='restclients.dao_implementation.trumba.FileTac'
            ):
            self.assertIsNotNone(Calendar.get_tac_calendars())
            self.assertTrue(len(Calendar.get_tac_calendars()) == 1)
            

    def test_get_sea_permissions_normal_cases(self):
        with self.settings(
            RESTCLIENTS_TRUMBA_SEA_DAO_CLASS='restclients.dao_implementation.trumba.FileSea'
            ):
            result = Calendar.get_sea_permissions(1)
            self.assertIsNotNone(result)
            self.assertTrue(len(result) == 3)
            perm = result[0]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, 'Dummy publisher')
            self.assertEqual(perm.uwnetid, 'dummyp')
            self.assertEqual(perm.level, 'PUBLISH')
            self.assertTrue(perm.is_edit())
            self.assertFalse(perm.is_showon())
            self.assertTrue(perm.is_sea())
            self.assertFalse(perm.is_bot())
            self.assertFalse(perm.is_tac())

            perm = result[1]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, 'Dummy editor')
            self.assertEqual(perm.uwnetid, 'dummye')
            self.assertEqual(perm.level, 'EDIT')
            self.assertTrue(perm.is_edit())
            self.assertFalse(perm.is_showon())
            self.assertTrue(perm.is_sea())
            self.assertFalse(perm.is_bot())
            self.assertFalse(perm.is_tac())

            perm = result[2]
            self.assertEqual(perm.calendarid, 1)
            self.assertEqual(perm.campus, 'sea')
            self.assertEqual(perm.name, 'Dummy showon')
            self.assertEqual(perm.uwnetid, 'dummys')
            self.assertEqual(perm.level, 'SHOWON')
{'fraction_non_alphanumeric': 0.1003835471498479, 'fraction_numerical': 0.007141912445443725, 'mean_word_length': 2.4735875057418464, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6943196', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2287, 'n_words': 290}