Esempio n. 1
0
    def test_model_dev_cant_delete_others_model(self, model_dev_create_model):
        (model_dev, model_id, name, task,
         model_file_path) = model_dev_create_model
        model_dev2 = make_model_dev()

        # Model dev 2 can't download model file
        with pytest.raises(Exception):
            model_dev2.delete_model(model_id)
Esempio n. 2
0
    def test_model_dev_cant_download_others_model(self,
                                                  model_dev_create_model):
        (model_dev, model_id, name, task,
         model_file_path) = model_dev_create_model
        model_dev2 = make_model_dev()

        # Model dev 2 can't delete model file
        with pytest.raises(Exception):
            with tempfile.NamedTemporaryFile() as f:
                model_dev2.download_model_file(model_id, f.name)
Esempio n. 3
0
    def model_dev_create_model(self):
        model_dev = make_model_dev()
        (name, task, model_file_path, model_class,
         dependencies) = make_model_info()
        model = model_dev.create_model(name, task, model_file_path,
                                       model_class, dependencies)
        assert 'id' in model
        model_id = model['id']

        return (model_dev, model_id, name, task, model_file_path)
Esempio n. 4
0
    def test_model_dev_cant_view_others_model(self, model_dev_create_model):
        (model_dev, model_id, name, task,
         model_file_path) = model_dev_create_model
        model_dev2 = make_model_dev()

        # Model dev 2 can't view model
        with pytest.raises(Exception):
            model_dev2.get_model(model_id)

        # Model dev 2 doesn't see it in available models
        models = model_dev2.get_available_models()
        assert not any([x['id'] == model_id for x in models])
Esempio n. 5
0
    def test_app_dev_cant_manage_users(self):
        ban_email = f'{gen()}@rafiki'
        email = gen_email()
        password = gen()
        model_dev = make_model_dev(email=ban_email)
        app_dev = make_app_dev()

        # Can't create user
        with pytest.raises(Exception):
            app_dev.create_user(email, password, UserType.ADMIN)

        # Can't list users
        with pytest.raises(Exception):
            app_dev.get_users()

        # Can't ban user
        with pytest.raises(Exception):
            app_dev.ban_user(ban_email)
Esempio n. 6
0
    def test_admin_ban_users(self):
        admin = make_admin()
        model_dev_email = gen_email()
        app_dev_email = gen_email()
        password = gen()
        model_dev = make_model_dev(email=model_dev_email, password=password)
        app_dev = make_app_dev(email=app_dev_email, password=password)

        # Ban both users
        admin.ban_user(model_dev_email)
        admin.ban_user(app_dev_email)

        # Both users cannot login again
        with pytest.raises(Exception):
            model_dev.login(model_dev_email, password)

        with pytest.raises(Exception):
            app_dev.login(app_dev_email, password)
Esempio n. 7
0
    def test_app_dev_view_public_model(self):
        app_dev = make_app_dev()
        model_dev = make_model_dev()
        (name, task, model_file_path, model_class,
         dependencies) = make_model_info()

        # Model dev creates public model
        model = model_dev.create_model(name,
                                       task,
                                       model_file_path,
                                       model_class,
                                       dependencies,
                                       access_right=ModelAccessRight.PUBLIC)
        assert 'id' in model
        model_id = model['id']

        # App dev sees it in available models
        models = app_dev.get_available_models()
        assert any([x['id'] == model_id for x in models])

        # App dev sees it in available models after filtering by task
        models = app_dev.get_available_models(task=task)
        assert any([x['id'] == model_id for x in models])