Esempio n. 1
0
    def test_get_space(self):

        logging.info("***** get generic space")

        space = SpaceFactory.get(type='space')

        space = SpaceFactory.get(type='space', context='c', weird='w')
        self.assertEqual(space.context, 'c')
        with self.assertRaises(AttributeError):
            self.assertEqual(space.weird, 'w')
Esempio n. 2
0
    def test_build_spark(self):

        logging.info("***** build Cisco Spark space from settings")

        self.context.apply(
            settings={  # from settings to member attributes
                'space': {
                    'type':
                    'spark',
                    'room':
                    'My preferred channel',
                    'participants':
                    ['*****@*****.**', '*****@*****.**'],
                    'team':
                    'Anchor team',
                    'token':
                    'hkNWEtMJNkODVGlZWU1NmYtyY',
                }
            })

        space = SpaceFactory.build(context=self.context)
        self.assertEqual(space.context.get('space.token'),
                         'hkNWEtMJNkODVGlZWU1NmYtyY')
        self.assertEqual(space.context.get('space.room'),
                         'My preferred channel')
        self.assertEqual(space.configured_title(), 'My preferred channel')
Esempio n. 3
0
    def test_get_unknown(self):

        logging.info("***** get invalid space")

        with self.assertRaises(ValueError):
            space = SpaceFactory.get(type='*unknown',
                                     ex_token='b',
                                     ex_ears='c')
Esempio n. 4
0
    def test_sense_void(self):

        logging.info("***** sense nothing on bad configuration")

        self.context.apply(settings={  # no recognizable space type
            'space': {
                'type': 'not_a_space_type',
                'room': 'My preferred channel',
                'participants':
                    ['*****@*****.**', '*****@*****.**'],
                'team': 'Anchor team',
                'token': 'hkNWEtMJNkODk3ZDZLOGQ0OVGlZWU1NmYtyY',
                'fuzzy_token': '$MY_FUZZY_SPARK_TOKEN',
            },

        })

        with self.assertRaises(ValueError):
            SpaceFactory.sense(self.context)
Esempio n. 5
0
    def test_sense_local(self):

        logging.info("***** sense local space")

        self.context.apply(
            settings={  # sense='local'
                'space': {
                    'type':
                    'local',
                    'title':
                    'My preferred channel',
                    'participants':
                    ['*****@*****.**', '*****@*****.**'],
                    'input': ['help', 'version'],
                }
            })

        self.assertEqual(SpaceFactory.sense(self.context), 'local')
Esempio n. 6
0
    def test_build_local(self):

        logging.info("***** build local space from settings")

        self.context.apply(
            settings={  # from settings to member attributes
                'space': {
                    'title':
                    'My preferred channel',
                    'participants':
                    ['*****@*****.**', '*****@*****.**'],
                    'input': ['help', 'version'],
                }
            })

        space = SpaceFactory.build(context=self.context)
        self.assertEqual(self.context.get('space.title'),
                         'My preferred channel')
        self.assertEqual(space.configured_title(), 'My preferred channel')
Esempio n. 7
0
    def test_sense_space(self):

        logging.info("***** sense generic space")

        self.context.apply(
            settings={  # sense='space'
                'space': {
                    'room':
                    'My preferred channel',
                    'participants':
                    ['*****@*****.**', '*****@*****.**'],
                    'team':
                    'Anchor team',
                    'token':
                    'hkNWEtMJNkODk3ZDZLOGQ0OVGlZWU1NmYtyY',
                    'fuzzy_token':
                    '$MY_FUZZY_SPARK_TOKEN',
                }
            })

        self.assertEqual(SpaceFactory.sense(self.context), 'space')
Esempio n. 8
0
    def test_build_space(self):

        logging.info("***** build generic space from settings")

        self.context.apply(
            settings={  # from settings to member attributes
                'space': {
                    'title':
                    'My preferred channel',
                    'participants':
                    ['*****@*****.**', '*****@*****.**'],
                    'team':
                    'Anchor team',
                    'token':
                    'hkNWEtMJNkODVGlZWU1NmYtyY',
                    'webhook':
                    "http://73a1e282.ngrok.io",
                }
            })

        space = SpaceFactory.build(context=self.context)
        self.assertEqual(self.context.get('space.title'),
                         'My preferred channel')
        self.assertEqual(space.configured_title(), 'My preferred channel')
Esempio n. 9
0
    def test_get_spark(self):

        logging.info("***** get Cisco Spark space")

        space = SpaceFactory.get(type='spark', context=self.context, token='b')
        self.assertEqual(space.context.get('space.token'), 'b')
Esempio n. 10
0
    def test_get_local(self):

        logging.info("***** get local space")

        space = SpaceFactory.get(type='local', input=['hello', 'world'])
        self.assertEqual(space.participants, [])