예제 #1
0
    def test_getcreate_spec(self):
        """
        Ensures that getcreate works as expected.
        :return:
        """
        spec = api.getcreate_spec("http://myurl.com")
        assert spec is not None

        # Retrieve the spec from the DB.
        spec2 = api.db.session.query(Spec).filter_by(url="http://myurl.com").first()
        assert spec2.id == spec.id

        # getcreate again to ensure the same id is returned
        spec3 = api.getcreate_spec("http://myurl.com")
        assert spec3.id == spec.id
    def setUp(self):
        appcomposer.app.config['DEBUG'] = True
        appcomposer.app.config['TESTING'] = True
        appcomposer.app.config['CSRF_ENABLED'] = False
        appcomposer.app.config["SECRET_KEY"] = 'secret'
        self.flask_app = appcomposer.app.test_client()

        self.flask_app.__enter__()

        # In case the test failed before, start from a clean state.
        self._cleanup()

        self.flask_app.get("/")
        rv = self.login("testuser", "password")

        # Create the PARENT app
        url = "appcomposer/tests_data/relativeExample/i18n.xml"
        rv = self.flask_app.post("/composers/translate/selectlang", data={"appname": "UTApp", "appurl": url}, follow_redirects=True)
        self.firstApp = get_app_by_name("UTApp").unique_id

        rv = self.login("testuser2", "password")
        # Create the CHILDREN app
        url = "appcomposer/tests_data/relativeExample/i18n.xml"
        rv = self.flask_app.post("/composers/translate/selectlang", data={"appname": "UTApp2", "appurl": url}, follow_redirects=True)
        self.secondApp = get_app_by_name("UTApp2").unique_id

        self.other_spec = getcreate_spec("TESTURL")