Example #1
0
    def test_compound_selectors(self):
        self.assertEqual(
            ua.or_(
                ua.tag('foo'),
                ua.tag('bar')
            ),
            {'or': [
                {'tag': 'foo'},
                {'tag': 'bar'}
            ]}
        )

        self.assertEqual(
            ua.and_(
                ua.tag('foo'),
                ua.tag('bar')
            ),
            {
                'and': [
                    {'tag': 'foo'},
                    {'tag': 'bar'}
                ]
            }
        )

        self.assertEqual(
            ua.not_(
                ua.tag('foo')
            ),
            {
                'not': {
                    'tag': 'foo'
                }
            }
        )
Example #2
0
 def make_tags(self, val):
     if isinstance(val, list):
         return ua.and_(*[self.make_tags(v) for v in val])
     elif isinstance(val, dict):
         if 'or' in val:
             return ua.or_(*[self.make_tags(v) for v in val['or']])
         elif 'and' in val:
             return ua.and_(*[self.make_tags(v) for v in val['and']])
     else:
         return ua.tag(val)
Example #3
0
 def make_tags(self, val):
     if isinstance(val, list):
         return ua.and_(*[self.make_tags(v) for v in val])
     elif isinstance(val, dict):
         if 'or' in val:
             return ua.or_(*[self.make_tags(v) for v in val['or']])
         elif 'and' in val:
             return ua.and_(*[self.make_tags(v) for v in val['and']])
     else:
         return ua.tag(val)
Example #4
0
    def pushNotification(self, resp, no_update_list):
        '''push notification'''
        resp.response.out.write("<br/>Start Pushing Notification <br/>")
        airship = ua.Airship('LTjlWamyTzyBHhVmzMLu_A','OB3h24o3RYOan5-JQWdVGQ')
        push = airship.create_push()
        push.device_types = ua.device_types('ios','android')
#        if len(no_update_list) == 0:
#            push.audience = ua.tag('260')
#            push.notification = ua.notification(alert="FAWN TESTING")
        for data in no_update_list:
            message = """%s is offline with FAWN for 2 hours.""" %(data[2])
            resp.response.out.write(message)
            push.audience = ua.tag(data[0])
            push.notification = ua.notification(alert = message)
            push.send()
    def test_compound_selectors(self):
        self.assertEqual(ua.or_(ua.tag("foo"), ua.tag("bar")), {"or": [{"tag": "foo"}, {"tag": "bar"}]})

        self.assertEqual(ua.and_(ua.tag("foo"), ua.tag("bar")), {"and": [{"tag": "foo"}, {"tag": "bar"}]})

        self.assertEqual(ua.not_(ua.tag("foo")), {"not": {"tag": "foo"}})