def test_delete_invalid_subscription(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         #Invalid UUID - missing the last character
         self.assertRaises(InvalidUUID, nws.delete_subscription,
                           "652236c6-a85a-4845-8dc5-3e518bec044")
 def test_subscriptions_channel_id(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         subscriptions = nws.get_subscriptions_by_channel_id(
             "b779df7b-d6f6-4afb-8165-8dbe6232119f")
         self.assertEquals(len(subscriptions), 5)
Beispiel #3
0
 def test_channel_surrogate_id(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         channel = nws.get_channel_by_surrogate_id(
             "uw_student_courseavailable", "2012,autumn,cse,100,w")
         self._assert_channel(channel)
Beispiel #4
0
 def test_endpoint_endpoint_id(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         endpoint = nws.get_endpoint_by_endpoint_id(
             "780f2a49-2118-4969-9bef-bbd38c26970a")
         self._assert_endpoint_matches(endpoint)
Beispiel #5
0
    def test_create_message_with_json(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):

            json = {
                "Event": {
                    "EventID": "blah",
                    "Href": "",
                    "LastModified": "2012-12-23T09:00:00",
                    "Section": {
                        "Course": {
                            "CourseNumber": "100",
                            "CurriculumAbbreviation": "cse",
                            "Quarter": "winter",
                            "Year": 2012
                        },
                        "Href": "",
                        "SLN": "12345",
                        "SectionID": "aa"
                    },
                    "SpaceAvailable": 1
                }
            }

            message = Message()
            message.message_type = "uw_student_courseavailable"
            message.content = json

            nws = NWS()
            response_status = nws.create_new_message(message)
            self.assertEquals(response_status, 200)
Beispiel #6
0
 def _channel_channel_id_live(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.Live'):
         nws = NWS()
         channel = nws.get_channel_by_channel_id(
             "ce1d46fe-1cdf-4c5a-a316-20f6c99789b7")
         self.assertTrue(channel is not None)
 def _delete_subscription_live(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.Live'):
         nws = NWS()
         response_status = nws.delete_subscription(
             "6445864b-6d1c-47b7-a409-279ba4a4ccf4")
         self.assertEquals(response_status, 204)
 def test_subscriptions_subscriber_id(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         subscriptions = nws.get_subscriptions_by_subscriber_id(
             "javerage", "10")
         self.assertEquals(len(subscriptions), 5)
 def _subscription_channel_id_live(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.Live'):
         nws = NWS()
         subscriptions = nws.get_subscriptions_by_channel_id(
             "ce1d46fe-1cdf-4c5a-a316-20f6c99789b8")
         self.assertTrue(len(subscriptions) > 0)
Beispiel #10
0
    def test_create_message_with_model_closed(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):

            course_available_event = CourseAvailableEvent()
            course_available_event.event_id = "blah"
            course_available_event.last_modified = "2012-12-23T09:00:00"
            course_available_event.space_available = 0
            course_available_event.quarter = "winter"
            course_available_event.year = 2012
            course_available_event.curriculum_abbr = "cse"
            course_available_event.course_number = "100"
            course_available_event.section_id = "aa"
            course_available_event.sln = "12345"
            course_available_event.notification_msg_0 = " NO"

            message = Message()
            message.message_type = "uw_student_courseavailable"
            message.content = course_available_event.json_data()
            self.assertEquals(message.content['Event']['Section']['SectionID'],
                              'AA')
            self.assertEquals(
                message.content['Event']['Section']['Course']
                ['CurriculumAbbreviation'], 'CSE')
            self.assertEquals(message.content['Event']['NotificationMsg0'],
                              ' NO')

            nws = NWS()
            response_status = nws.create_new_message(message)
            self.assertEquals(response_status, 200)
Beispiel #11
0
 def _delete_channel_live(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.Live'):
         nws = NWS()
         response_status = nws.delete_channel(
             "ce1d46fe-1cdf-4c5a-a316-20f6c99789b7")
         self.assertEquals(response_status, 204)
Beispiel #12
0
 def test_channel_channel_id(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         channel = nws.get_channel_by_channel_id(
             "b779df7b-d6f6-4afb-8165-8dbe6232119f")
         self._assert_channel(channel)
Beispiel #13
0
 def test_delete_subscription(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         response_status = nws.delete_subscription(
             "652236c6-a85a-4845-8dc5-3e518bec044c")
         self.assertEquals(response_status, 204)
Beispiel #14
0
 def test_person_by_uwregid(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         person = nws.get_person_by_uwregid(
             "9136CCB8F66711D5BE060004AC494FFE")
         self._assert_person_matches(person)
Beispiel #15
0
 def test_channel_sln_and_term(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         channels = nws.get_channels_by_sln_year_quarter(
             "uw_student_courseavailable", "12345", 2012, "autumn")
         self.assertEquals(len(channels), 1)
Beispiel #16
0
 def test_endpoint_by_subscriber_id_protocol(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         endpoint = nws.get_endpoint_by_subscriber_id_and_protocol(
             "javerage", "sms")
         self._assert_endpoint_matches(endpoint)
Beispiel #17
0
    def test_endpoint_search_by_subscriber_id(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            nws = NWS()
            endpoints = nws.get_endpoints_by_subscriber_id("javerage")
            self.assertEquals(len(endpoints), 2)

            endpoint = endpoints[0]
            self._assert_endpoint_matches(endpoint)
Beispiel #18
0
    def test_create_person(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            nws = NWS()
            person = nws.get_person_by_surrogate_id("*****@*****.**")
            person.person_id = None
            person.endpoints = None

            response_status = nws.create_new_person(person)
            self.assertEquals(201, response_status)
Beispiel #19
0
    def test_create_endpoint(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            nws = NWS()
            endpoint = nws.get_endpoint_by_endpoint_id(
                "780f2a49-2118-4969-9bef-bbd38c26970a")
            endpoint.endpoint_id = None
            endpoint.endpoint_uri = None

            response_status = nws.create_new_endpoint(endpoint)
            self.assertEquals(201, response_status)
Beispiel #20
0
    def test_create_channel(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            channel = Channel()
            channel.surrogate_id = "2012,autumn,uwit,100,a"
            channel.type = "uw_student_courseavailable"
            channel.name = "TEST CREATE CHANNEL"
            channel.description = "TEST CREATE CHANNEL \n"

            nws = NWS()
            response_status = nws.create_new_channel(channel)
            self.assertEquals(response_status, 201)
Beispiel #21
0
    def test_subscriber_id_validation(self):
        nws = NWS()
        nws._validate_subscriber_id('javerage')
        nws._validate_subscriber_id('*****@*****.**')

        self.assertRaises(InvalidNetID, nws._validate_subscriber_id, '00ok')
        self.assertRaises(InvalidNetID, nws._validate_subscriber_id,
                          'ok123456789')
        self.assertRaises(InvalidNetID, nws._validate_subscriber_id,
                          '*****@*****.**')
        self.assertRaises(InvalidNetID, nws._validate_subscriber_id,
                          'javerage@')
Beispiel #22
0
    def _create_channel_live(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.Live'):
            channel = Channel()
            channel.channel_id = "ce1d46fe-1cdf-4c5a-a316-20f6c99789b7"
            channel.surrogate_id = "2012,autumn,uwit,100,a"
            channel.type = "uw_student_courseavailable"
            channel.name = "TEST CREATE CHANNEL"
            channel.template_surrogate_id = "CourseAvailableNotificationTemplate"
            channel.description = "TEST CREATE CHANNEL \n"

            nws = NWS()
            response_status = nws.create_new_channel(channel)
            self.assertEquals(response_status, 201)
Beispiel #23
0
    def test_terms_with_active_channels(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File',
                           RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File'):
            nws = NWS()

            terms = nws.get_terms_with_active_channels(
                "uw_student_courseavailable")
            self.assertEquals(len(terms), 2)

            self.assertEquals(terms[0].year, 2013)
            self.assertEquals(terms[0].quarter, 'spring')
            self.assertEquals(terms[1].year, 2013)
            self.assertEquals(terms[1].quarter, 'summer')
Beispiel #24
0
    def test_update_empty_subscriberid_subscription(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            subscription = Subscription()
            subscription.endpoint = Endpoint()
            subscription.endpoint.endpoint_address = "*****@*****.**"
            subscription.endpoint.protocol = "Email"
            subscription.endpoint.user = ''
            subscription.endpoint.owner = "javerage"
            subscription.channel = Channel()
            subscription.channel.channel_id = "b779df7b-d6f6-4afb-8165-8dbe6232119f"

            nws = NWS()
            self.assertRaises(InvalidNetID, nws.update_subscription,
                              subscription)
Beispiel #25
0
    def _update_subscription_live(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.Live'):
            subscription = Subscription()
            subscription.subscription_id = "6445864b-6d1c-47b7-a409-279ba4a4ccf4"
            subscription.end_point = "*****@*****.**"
            subscription.protocol = "Email"
            subscription.subscriber_id = "javerage"
            subscription.channel_id = "ce1d46fe-1cdf-4c5a-a316-20f6c99789b8"
            subscription.owner_id = "javerage"
            #subscription.subscriber_type = "Individual"

            nws = NWS()
            response_status = nws.update_subscription(subscription)
            self.assertEquals(response_status, 204)
Beispiel #26
0
    def test_create_empty_channelid_subscription(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            subscription = Subscription()
            subscription.endpoint = Endpoint()
            subscription.endpoint.endpoint_address = "*****@*****.**"
            subscription.endpoint.protocol = "Email"
            subscription.endpoint.subscriber_id = "javerage"
            subscription.endpoint.owner_id = "javerage"
            subscription.endpoint.user = "******"
            subscription.channel = Channel()

            nws = NWS()
            self.assertRaises(InvalidUUID, nws.create_new_subscription,
                              subscription)
Beispiel #27
0
    def test_create_invalid_subscriberid_subscription(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            subscription = Subscription()
            subscription.subscription_id = "c4597f93-0f62-4feb-ac88-af5f0329001f"
            subscription.endpoint = Endpoint()
            subscription.endpoint.endpoint_address = "*****@*****.**"
            subscription.endpoint.protocol = "Email"
            subscription.endpoint.subscriber_id = "-@#$ksjdsfkli13290243290490"
            subscription.endpoint.owner_id = "javerage"
            subscription.channel = Channel()
            subscription.channel.channel_id = "b779df7b-d6f6-4afb-8165-8dbe6232119f"

            nws = NWS()
            self.assertRaises(InvalidNetID, nws.create_new_subscription,
                              subscription)
Beispiel #28
0
    def test_update_subscription(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.File'):
            subscription = Subscription()
            subscription.subscription_id = "c4597f93-0f62-4feb-ac88-af5f0329001f"
            subscription.endpoint = Endpoint()
            subscription.endpoint.endpoint_address = "*****@*****.**"
            subscription.endpoint.protocol = "Email"
            subscription.endpoint.user = "******"
            subscription.endpoint.owner = "*****@*****.**"
            subscription.channel = Channel()
            subscription.channel.channel_id = "b779df7b-d6f6-4afb-8165-8dbe6232119f"

            nws = NWS()
            response_status = nws.update_subscription(subscription)
            self.assertEquals(response_status, 204)
Beispiel #29
0
    def _create_message_live_with_model(self):
        with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                           'restclients.dao_implementation.nws.Live'):
            course_available_event = CourseAvailableEvent()
            course_available_event.event_id = "blah"
            course_available_event.last_modified = "2012-12-23T09:00:00"
            course_available_event.status = "open"
            course_available_event.space_available = 1
            course_available_event.quarter = "autumn"
            course_available_event.year = 2012
            course_available_event.curriculum_abbr = "ling"
            course_available_event.course_number = "200"
            course_available_event.section_id = "ac"
            course_available_event.sln = "16116"

            message = Message()
            message.message_type = "uw_student_courseavailable"
            message.content = course_available_event.json_data()

            nws = NWS()
            response_status = nws.create_new_message(message)
            self.assertEquals(response_status, 200)
Beispiel #30
0
 def test_person_by_surrogate_id_nonexistent(self):
     with self.settings(RESTCLIENTS_NWS_DAO_CLASS=
                        'restclients.dao_implementation.nws.File'):
         nws = NWS()
         self.assertRaises(DataFailureException,
                           nws.get_person_by_surrogate_id, "asdfgh")