コード例 #1
0
    def test_bossrequest_channel_not_found(self):
        """
        Test initialization of requests with a channel that does not exist

        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel2/?key=mkey'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "user": self.user,
            "method": request.method,
            "service": "meta",
            "version": version,
            "collection_name": "col1",
            "experiment_name": "exp1",
            "channel_name": "channel2",
            "key": "mkey",
            "value": None
        }

        try:
            BossRequest(drfrequest,request_args)
        except BossError as err:
            assert err.args[0] == 404
コード例 #2
0
    def test_bossrequest_init_coordinateframe(self):
        """
        Test initialization of requests from the meta data service with a valid collection and experiment and dataset
        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel1/?key=mkey'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_channel = 'channel1'
        expected_coord = 'cf1'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "user": self.user,
            "method": request.method,
            "service": "meta",
            "version": version,
            "collection_name": expected_col,
            "experiment_name": expected_exp,
            "channel_name": expected_channel,
            "key": "mkey",
        }
        ret = BossRequest(drfrequest, request_args)

        # Data model objects
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)
        self.assertEqual(ret.get_channel(), expected_channel)

        # Check coordinate frame
        self.assertEqual(ret.get_coordinate_frame(), expected_coord)
コード例 #3
0
    def test_experiment_init(self):
        """
        Test initialization of requests from the meta data service with valid collection and experiment
        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/?key=mkey&value=TestValue'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_bosskey = 'col1&exp1'
        expected_key = 'mkey'
        expected_value = 'TestValue'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        ret = BossRequest(drfrequest)

        # Datamodel object
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)

        # Boss key
        boss_key = ret.get_boss_key()
        self.assertEqual(boss_key, expected_bosskey)

        # Key and value
        key = ret.get_key()
        self.assertEqual(key, expected_key)
        value = ret.get_value()
        self.assertEqual(value, expected_value)
コード例 #4
0
ファイル: test_urls.py プロジェクト: theiscoresearch/boss
    def test_meta_urls_resolves_to_BossMeta_views(self):
        """
        Test to make sure the meta URL for get, post, delete and update with all
        datamodel params resolves to the meta view

        Returns: None
        """
        match = resolve('/' + version + '/meta/col1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)

        match = resolve('/' + version + '/meta/col1/exp1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)

        match = resolve('/' + version + '/meta/col1/exp1/ch1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)
コード例 #5
0
ファイル: test_urls.py プロジェクト: jhuapl-boss/boss
    def test_meta_urls_resolves_to_BossMeta_views(self):
        """
        Test to make sure the meta URL for get, post, delete and update with all
        datamodel params resolves to the meta view

        Returns: None
        """
        match = resolve('/' + version + '/meta/col1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)

        match = resolve('/' + version + '/meta/col1/exp1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)

        match = resolve('/' + version + '/meta/col1/exp1/ch1/')
        self.assertEqual(match.func.__name__, BossMeta.as_view().__name__)
コード例 #6
0
    def test_bossrequest_channel_layer_not_found(self):
        """
        Test initialization of requests with a channel that does not exist

        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel2/?key=mkey'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        try:
            BossRequest(drfrequest)
        except BossError as err:
            assert err.args[0] == 404
コード例 #7
0
    def test_bossrequest_experiment_not_found(self):
        """
        Test initialization of requests with a experiment that does not exist

        """
        # create the request
        url = '/' + version + '/meta/col1/exp2/?key=mkey'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        try:
            BossRequest(drfrequest)
        except BossError as err:
            assert err.status_code == 404
コード例 #8
0
    def test_bossrequest_init_channel(self):
        """
        Test initialization of requests from the meta data service with a valid collection and experiment and channel

        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel1/?key=mkey&value=TestValue'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_channel = 'channel1'
        expected_bosskey = 'col1&exp1&channel1'
        expected_key = 'mkey'
        expected_value = 'TestValue'

        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "user": self.user,
            "method": request.method,
            "service": "meta",
            "version": version,
            "collection_name": expected_col,
            "experiment_name": expected_exp,
            "channel_name": expected_channel,
            "key": "mkey",
            "value": "TestValue"
        }

        # Data model Objects
        ret = BossRequest(drfrequest, request_args)
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)
        self.assertEqual(ret.get_channel(), expected_channel)

        # Boss key
        boss_key = ret.get_boss_key()
        self.assertEqual(boss_key, expected_bosskey)

        # Key and value
        key = ret.get_key()
        self.assertEqual(key, expected_key)
        value = ret.get_value()
        self.assertEqual(value, expected_value)
コード例 #9
0
    def test_collection_special_char_dash(self):
        """
        Test initialization of requests from the meta data service with collection that has a dash in the name
        :return:
        """
        # create the request with collection name
        # log in user


        url = '/' + version + '/meta/col1-22/?key=mkey&value=TestValue'
        expected_col = 'col1-22'
        expected_bosskey = 'col1-22'
        expected_key = 'mkey'
        expected_value = 'TestValue'

        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version

        # Create the request dict
        request_args = {
            "user": self.user,
            "method": request.method,
            "service": "meta",
            "version": version,
            "collection_name": expected_col,
            "experiment_name": None,
            "channel_name": None,
            "key": "mkey",
            "value": "TestValue"
        }

        # Datamodel object
        ret = BossRequest(drfrequest, request_args)
        self.assertEqual(ret.get_collection(), expected_col)

        # Boss key
        boss_key = ret.get_boss_key()
        self.assertEqual(boss_key, expected_bosskey)

        # Key and value
        key = ret.get_key()
        self.assertEqual(key, expected_key)
        value = ret.get_value()
        self.assertEqual(value, expected_value)
コード例 #10
0
    def test_bossrequest_init_coordinateframe(self):
        """
        Test initialization of requests from the meta data service with a valid collection and experiment and dataset
        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel1/?key=mkey'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_channel = 'channel1'
        expected_coord = 'cf1'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version
        ret = BossRequest(drfrequest)

        # Data model objects
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)
        self.assertEqual(ret.get_channel_layer(), expected_channel)

        # Check coordinate frame
        self.assertEqual(ret.get_coordinate_frame(), expected_coord)
コード例 #11
0
    def test_bossrequest_list_all_keys(self):
        """
        Test initialization of requests from the meta data service with a valid collection and experiment and channel
        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel1/'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_channel = 'channel1'
        expected_coord = 'cf1'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version
        # Create the request dict
        request_args = {
            "user": self.user,
            "method": request.method,
            "service": "meta",
            "version": version,
            "collection_name": expected_col,
            "experiment_name": expected_exp,
            "channel_name": expected_channel,
            "key": None,
            "value": None
        }

        ret = BossRequest(drfrequest, request_args)

        # Data model objects
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)
        self.assertEqual(ret.get_channel(), expected_channel)

        # Key and value should be empty
        self.assertEqual(ret.get_key(), None)
        self.assertEqual(ret.get_value(), None)
コード例 #12
0
    def test_bossrequest_list_all_keys(self):
        """
        Test initialization of requests from the meta data service with a valid collection and experiment and channel
        """
        # create the request
        url = '/' + version + '/meta/col1/exp1/channel1/'
        expected_col = 'col1'
        expected_exp = 'exp1'
        expected_channel = 'channel1'
        expected_coord = 'cf1'
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = BossMeta().initialize_request(request)
        drfrequest.version = version
        ret = BossRequest(drfrequest)

        # Data model objects
        self.assertEqual(ret.get_collection(), expected_col)
        self.assertEqual(ret.get_experiment(), expected_exp)
        self.assertEqual(ret.get_channel_layer(), expected_channel)

        # Key and value should be empty
        self.assertEqual(ret.get_key(), None)
        self.assertEqual(ret.get_value(), None)