예제 #1
0
    def test_login_team_set(self):
        """
        Login a user who already has their team set
        """
        with app.test_client() as testClient:
            ###Create a student and join a team and select route###
            self.loginuser(testClient, '*****@*****.**', 'password')
            checkUserTeam = getTeamFromStudentID(
                getStudentID('*****@*****.**')[0]['STUDENT_ID'])

            if len(checkUserTeam
                   ) == 0 or checkUserTeam[0]['TEAM_NAME'] != "TEST NEW NAME":
                self.selectTeam(testClient, "test tutor", "test tutor team 1")
                self.selectRoute(testClient, 1, "TEST NEW NAME")
        app.test_client().delete()
        with app.test_client() as testClient:
            ###Login to the user and ensure they are redirected to the correct question###
            self.register(testClient, "test user2", "*****@*****.**",
                          "password", "password", "test tutor")
            self.loginuser(testClient, '*****@*****.**', 'password')
            response = self.selectTeam(testClient, "test tutor",
                                       "TEST NEW NAME")
            self.assertEqual(response.status_code, 200)
            self.assert_template_used('mobile/Clue_Page.html')
            checkUserTeam = getTeamFromStudentID(
                getStudentID('*****@*****.**')[0]['STUDENT_ID'])
            self.assertEqual(checkUserTeam[0]['TEAM_ID'],
                             getTeamID('TEST NEW NAME')[0]['TEAM_ID'])
예제 #2
0
파일: common.py 프로젝트: lootaz/appflow_ta
    def setUp(self):
        app.config.from_object(TestConfig)
        self.client = app.test_client()
        db.drop_all()
        db.create_all()

        now = datetime.datetime.utcnow()
        self.exists_posts = [
            Post(source_id=111,
                 title="Test_444",
                 url="http://test.org/666",
                 created=now),
            Post(source_id=222,
                 title="Test_333",
                 url="http://test.org/333",
                 created=now),
            Post(source_id=333,
                 title="Test_222",
                 url="http://test.org/444",
                 created=now),
            Post(source_id=444,
                 title="Test_111",
                 url="http://test.org/222",
                 created=now),
            Post(source_id=555,
                 title="Test_555",
                 url="http://test.org/111",
                 created=now),
            Post(source_id=666,
                 title="Test_666",
                 url="http://test.org/555",
                 created=now),
        ]
        db.session.add_all(self.exists_posts)
        db.session.commit()
예제 #3
0
    def test_login_team_selection_no_leader(self):
        """
        Ensure that when a user joins a team without a team leader they are selected as the leader
        """
        with app.test_client() as testClient:
            ###Register a tutor and student and login the user###
            self.register(testClient, 'Test tutor', '*****@*****.**',
                          'password', 'password', 'test entry')
            self.register(testClient, 'Test student', '*****@*****.**',
                          'password', 'password', 'test tutor')
            self.loginuser(testClient, '*****@*****.**', 'password')

            ###Test that the select team feature works###
            response = self.selectTeam(testClient, "test tutor",
                                       "test tutor team 1")
            checkUserTeam = getTeamFromStudentID(
                getStudentID('*****@*****.**')[0]['STUDENT_ID'])

            self.assertEqual(response.status_code, 200)
            self.assert_template_used('mobile/First_Choose.html')
            self.assertEqual(checkUserTeam[0]['TEAM_ID'],
                             getTeamID('test tutor team 1')[0]['TEAM_ID'])

            ###Select a route and eneter a new name ensure the changes save###
            response = self.selectRoute(testClient, 1, "TEST NEW NAME")
            self.assertEqual(response.status_code, 200)
            self.assert_template_used('mobile/Clue_Page.html')
            checkTeam = getTeamID("TEST NEW NAME")
            self.assertGreater(len(checkTeam), 0)
            checkRoute = getRouteID(session['teamID'])
            self.assertEqual(checkRoute[0]['CURRENT_ROUTE_ID'], 1)
예제 #4
0
def test_client():
    with app.test_client() as testing_client:
        testing_client.application.config['TESTING'] = True
        testing_client.application.config['WTF_CSRF_METHODS'] = []
        testing_client.application.config['WTF_CSRF_ENABLED'] = False
        with app.app_context():
            yield testing_client
예제 #5
0
    def test_registration_existing_email(self):
        """
        Test to ensure if email that is already used is entered into registration registration is blacked
        """
        with app.test_client() as testClient:
            ###Register a tutor and student###
            self.register(testClient, 'Test tutor', '*****@*****.**',
                          'password', 'password', 'matt colinson')
            self.existingStudent('Test student', '*****@*****.**', 'NULL',
                                 'test tutor')

            ###Try to register a student with the same email check that redirect occurs###
            response = self.registerIndividual(testClient, 'Test student',
                                               '*****@*****.**',
                                               'password', 'password',
                                               'matt colinson')
            self.assertEqual(response.status_code, 200)
            self.assert_template_used('Desktop/register.html')
            self.assertIn(b"Email is already in use", response.data)

            ###Try to register a tutor with the same email check that redirect occurs###
            insertTutorUser('*****@*****.**', 1, 'test tester')
            response = self.registerIndividual(testClient, 'Test tutor',
                                               '*****@*****.**', 'password',
                                               'password', 'matt')
            self.assertEqual(response.status_code, 200)
            self.assert_template_used('Desktop/register.html')
            self.assertIn(b"Email or tutor name is already in use",
                          response.data)
예제 #6
0
    def test_post_invalid_checksum(self, m):
        test_app = app.test_client()

        payload = self.generate_payload_with_artefact_invalid_checksum()
        m.get('http://example.com/apk', content=b'abcdef', status_code=200)

        response = test_app.post('/webhook/greenhouse', content_type='application/json', data=json.dumps(payload))
        self.assertEqual(response.status_code, 403)
예제 #7
0
 def setUp(self):
     """Setting the app up for tests suite"""
     self.app = app.test_client()
     self.base_request_url = "/pay/?client_id=1&buyer_name=Vittor&[email protected]&" \
                             "buyer_cpf=12345678910&payment_amount=1200&"
     db.create_all()
     db.session.add(Client())
     db.session.commit()
예제 #8
0
 def test_login_tutor(self):
     """
     Check that when a tutor logs in they are redirected to the dashboard
     """
     with app.test_client() as testClient:
         response = self.loginuser(testClient, '*****@*****.**',
                                   'password')
         self.assertEqual(response.status_code, 200)
         self.assert_template_used('Desktop/Game_Keeper_Page.html')
def client(request):
    app.config['TESTING'] = True
    client = app.test_client()

    def teardown():  # 每个测试运行后都会执行该函数
        app.config['TESTING'] = False

    request.addfinalizer(teardown)  # 执行回收函数
    return client
예제 #10
0
def test002_search_route_bad_payload():
    client = app.test_client()
    url = "/api/v1/search"
    mock_data = {
        "queries": "in your l",
        "size": 3
    }
    response = client.post(url, data=json.dumps(mock_data), headers={'Content-Type': 'application/json'})
    assert response.status_code == 400
예제 #11
0
    def create_app(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.secret_key = 'eXeplore_241199_brjbtk'
        app.SECURITY_PASSWORD_SALT = 'BFR241199'
        self.app = app.test_client()

        self.assertEqual(app.debug, False)
        return app
예제 #12
0
 def test_login_wrong_password(self):
     """
     Test that when an incorrect password is entered the access is denied
     """
     with app.test_client() as testClient:
         response = self.loginuser(testClient, '*****@*****.**',
                                   'notcorrectpassword')
         self.assertEqual(response.status_code, 200)
         self.assert_template_used('Desktop/Game_Keeper_Login.html')
         self.assertIn(b"User does not exist", response.data)
예제 #13
0
def test003_search_route_empty_query():
    client = app.test_client()
    url = "/api/v1/search"
    mock_data = {
        "queries": [],
        "size": 3
    }
    response = client.post(url, data=json.dumps(mock_data), headers={'Content-Type': 'application/json'})
    data = json.loads(response.get_data(as_text=True))
    assert response.status_code == 200
    assert len(data["results"]) == 0
예제 #14
0
 def test_registation_incorrect_email_extension(self):
     """
     Tests that if email with incorrect extension is passed the user is informed with a flash message
     """
     with app.test_client() as testClient:
         ###Create a user with incorrect email###
         response = self.register(testClient, 'Test student',
                                  '*****@*****.**',
                                  'password', 'password', 'matt colinson')
         self.assertEqual(response.status_code, 200)
         self.assertIn(b"email of extension", response.data)
    def setUp(self):

        try:
            Scenario.drop_collection()
        except:
            pass

        self.client = app.test_client()

        # send requests to server that will edit test/data/parameter.nc
        raw_data = '''
            {
                "name": "test-scenario-1",
                "veg_map_by_hru": {
                    "bare_ground": [0, 1, 2, 3, 5, 10, 11],
                    "grasses": [4, 6, 7, 17, 18, 19],
                    "shrubs": [9, 12, 13],
                    "trees": [8, 14, 15, 16],
                    "conifers": []
                }
            }
        '''

        raw_data2 = '''
            {
                "name": "test-scenario-2",
                "veg_map_by_hru": {
                    "bare_ground": [0, 10, 11],
                    "grasses": [2, 3, 5, 7, 17, 18, 19],
                    "shrubs": [9, 12, 13],
                    "trees": [8, 14, 15, 16],
                    "conifers": [4, 6, 1]
                }
            }
        '''

        self.res1 = self.client.post('/api/scenarios', data=raw_data,
                                     headers={
                                        'Content-Type': 'application/json',
                                        'Origin': '*'}
                                     )

        self.res2 = self.client.post('/api/scenarios', data=raw_data2,
                                     headers={
                                         'Content-Type': 'application/json',
                                         'Origin': '*'}
                                     )

        self.r1_scenario = json.loads(json.loads(self.res1.data)['scenario'])
        self.r2_scenario = json.loads(json.loads(self.res2.data)['scenario'])

        self.id1 = self.r1_scenario['id']
        self.id2 = self.r2_scenario['id']
예제 #16
0
    def test_delete_failure(self, mock_todocontext):
        # arrange
        test_id = "abcde"
        test_timestamp = 123456789
        mock_todocontext.return_value.delete.return_value = None

        # act
        response = app.test_client().delete(
            f"/todo?todoID={test_id}&timestamp={test_timestamp}")

        # assert
        self.assert404(response)
        self.assertEquals(response.json['success'], False)
예제 #17
0
    def test_get_one(self, mock_todocontext):
        # arrange
        test_id = "abcde"
        test_todo = dict(todoID=test_id, message="test todo")
        mock_todocontext.return_value.get.return_value = test_todo

        # act
        response = app.test_client().get(f"/todo/{test_id}")

        # assert
        self.assert200(response)
        self.assertTrue(response.json['success'])
        self.assertEquals(response.json['todo'], test_todo)
예제 #18
0
    def test_get_all(self, mock_todocontext):
        # arrange
        test_todos = [
            dict(todoID="b271", message="test todo"),
            dict(todoID="abcde", message="test todo # 2")
        ]
        mock_todocontext.return_value.getAll.return_value = test_todos

        # act
        response = app.test_client().get("/todos")

        # assert
        self.assert200(response)
        self.assertTrue(response.json['success'])
        self.assertEquals(response.json['todos'], test_todos)
예제 #19
0
 def test_login_new_user_no_team(self):
     """
     When a user with no team logs in redirect to the select team screen
     """
     with app.test_client() as testClient:
         ###Register the team and tutor###
         self.register(testClient, 'Test tutor', '*****@*****.**',
                       'password', 'password', 'test entry')
         self.register(testClient, 'Test student', '*****@*****.**',
                       'password', 'password', 'test tutor')
         ###Login the user ensure redirect to the join team page###
         response = self.loginuser(testClient, '*****@*****.**',
                                   'password')
         self.assertEqual(response.status_code, 200)
         self.assert_template_used('mobile/Join_Team.html')
예제 #20
0
    def setUp(self):
        """
        Add bucketlists and items directly to db to avoid using tokens 
        required for POST request.
        """
        app.config.from_object(TestingConfig)
        self.client = app.test_client()
        db.create_all()

        self.client.post("/auth/register",
                         data=json.dumps(
                             dict(username="******", password="******")),
                         content_type="application/json")

        response = self.client.post("/auth/login",
                                    data=json.dumps(
                                        dict(username="******",
                                             password="******")),
                                    content_type="application/json")
        response_msg = json.loads(response.data)
        self.token = response_msg["Token"]

        bucket = {"name": "testbucketlist"}
        test_bucket = Bucketlist()
        test_bucket.import_data(bucket)
        test_bucket.created_by = 1

        bucket2 = {"name": "testbucketlist2"}
        test_bucket2 = Bucketlist()
        test_bucket2.import_data(bucket2)
        test_bucket2.created_by = 1

        bucket3 = {"name": "testbucketlist3"}
        test_bucket3 = Bucketlist()
        test_bucket3.import_data(bucket3)
        test_bucket3.created_by = 2

        item = {"name": "testitem", "done": ""}
        test_item = BucketlistItem()
        test_item.import_data(item)
        test_item.bucket = 1
        test_item.created_by = 1

        db.session.add(test_bucket)
        db.session.add(test_bucket2)
        db.session.add(test_bucket3)
        db.session.add(test_item)
        db.session.commit()
예제 #21
0
    def test_delete_success(self, mock_todocontext):
        # arrange
        test_id = "abcde"
        test_timestamp = 123456789
        test_todo = dict(todoID=test_id,
                         timestamp=test_timestamp,
                         message="test message")
        mock_todocontext.return_value.delete.return_value = test_todo

        # act
        response = app.test_client().delete(
            f"/todo?todoID={test_id}&timestamp={test_timestamp}")

        # assert
        self.assert200(response)
        self.assertEquals(response.json['todoID'], test_id)
 def setUpClass(cls):
     app.config.from_object('app.main.config.TestingConfig')
     cls.app = app.test_client()
     ComputationApplication.query.delete()
     ComputationAccount.query.delete()
     ComputationTask.query.delete()
     user = ComputationAccount(id=1,
                               username='******',
                               password='******',
                               created=datetime.datetime.now(),
                               lastLogin=datetime.datetime.now(),
                               email='email')
     user_repository.save_changes(user)
     application = ComputationApplication(id="1",
                                          description="a",
                                          name="a",
                                          icon="a")
     application_repository.save_changes(application)
예제 #23
0
    def test_registration_valid_tutor(self):
        """
         Register a valid tutor and ensure redirect to login pages
         """
        with app.test_client() as testClient:
            ###Register a tutor###
            response = self.register(testClient, 'Test tutor',
                                     '*****@*****.**', 'password',
                                     'password', 'matt')
            self.assertEqual(response.status_code, 200)
            self.assert_template_used('Desktop/Game_Keeper_Login.html')
            self.assertIn(b"Tutor registration successful", response.data)

            #Checks that user added to student but not tutor
            check = getStudentID('*****@*****.**')
            self.assertEqual(len(check), 0)
            check = getTutorPassword('*****@*****.**')
            self.assertGreater(len(check), 0)
예제 #24
0
def test001_search_route():
    client = app.test_client()
    url = "/api/v1/search"
    mock_data = {
        "queries": ["in your l", "is your problems", "I should do"],
        "size": 3
    }
    response = client.post(url, data=json.dumps(mock_data), headers={'Content-Type': 'application/json'})
    data = json.loads(response.get_data(as_text=True))
    assert response.status_code == 200
    assert len(data["results"]) == 3
    for result in data["results"]:
        assert len(result) == 3
        for summary in result:
            assert "author" in summary
            assert "query" in summary
            assert "id" in summary
            assert "summary" in summary
예제 #25
0
    def setUp(self):
        self.app = create_app(os.environ['TEST_APP_SETTINGS'])
        self.client = app.test_client()

        self.name = "test name"
        self.username = "******"
        self.email = "test email"
        self.phone = "test phone"
        self.website = "test.test"

        self.name_update = "test name_update"
        self.username_update = "test username_update"
        self.email_update = "test email_update"
        self.phone_update = "test phone_update"
        self.website_update = "test.test_update"

        self.name_update_detail = "test name_update_detail"
        self.username_update_detail = "test username_update_detail"
예제 #26
0
    def test_dashboard_Assign_Team_Leader(self):
        """
        Register a new tutor and two new users, then assign one user as the team leader of the tutors first team
        And Then assign the second to be the team leader. Assert that these changes are made
        """
        # Set up the student with a team
        with app.test_client() as testClient:
            ###Register Users###
            self.register(testClient, self.TUTORNAME, self.TUTOREMAIL,
                          self.PASSWORD, self.PASSWORD, self.NOTAPPLICABLE)
            self.registerIndividual(testClient, self.STUDENTNAME,
                                    self.STUDENTEMAIL, self.PASSWORD,
                                    self.PASSWORD, self.TUTORNAME.lower())
            self.registerIndividual(testClient, self.STUDENTNAME + "2",
                                    self.STUDENTEMAIL2, self.PASSWORD,
                                    self.PASSWORD, self.TUTORNAME.lower())

            ###Login user1 and assign team and route###
            self.loginuser(testClient, self.STUDENTEMAIL, self.PASSWORD)
            self.selectTeam(testClient, self.TUTORNAME.lower(), self.TEAMNAME)
            self.selectRoute(testClient, 1, self.TEAMNAME)
            session.clear

            ###Login user2 and assign team###
            self.loginuser(testClient, self.STUDENTEMAIL2, self.PASSWORD)
            self.selectTeam(testClient, self.TUTORNAME.lower(), self.TEAMNAME)

            ###Check current teamleader is user 1###
            currentLeader = getTeamLeader(
                getTeamID(self.TEAMNAME)[0]['TEAM_ID'])[0]['TEAM_LEADER']
            studentID = self.getStudentIDFromEmail(self.STUDENTEMAIL)
            self.assertEqual(currentLeader, studentID)

            ###Login tutor and assign new team leader (user 2)###
            self.loginuser(testClient, self.TUTOREMAIL, self.PASSWORD)
            response = self.assignNewTeamLeader(testClient, self.TEAMNAME,
                                                self.STUDENTEMAIL2)

            ###Check the team leader is now user 2###
            newLeader = getTeamLeader(getTeamID(
                self.TEAMNAME)[0]['TEAM_ID'])[0]['TEAM_LEADER']
            studentID2 = self.getStudentIDFromEmail(self.STUDENTEMAIL2)
            self.assertEqual(currentLeader, studentID)
            self.assert_template_used('Desktop/Game_Keeper_Page.html')
예제 #27
0
    def setUp(self):
        app.config['LOGIN_DISABLED'] = True
        app.config['SECRET_KEY'] = 'secret_key'
        app.config['CSRF_SESSION_KEY'] = 'secret_key'
        app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('GAME_STAT_DB')
        app.login_manager.init_app(app)

        self.app = app.test_client()
        self.app.testing = True

        with app.app_context():
            '''
            Необходимо использовать raw sql для удаления sequences, в связи с тем, что
            db.drop_all() пытается удалить sequence перед удалением зависимой от неё таблицы,
            что приводит к ошибке. Это наиболее простое решение.
            '''
            db.engine.execute('DROP SEQUENCE IF EXISTS device_id_seq CASCADE;')
            db.engine.execute('DROP SEQUENCE IF EXISTS event_id_seq CASCADE;')
            db.engine.execute(
                'DROP SEQUENCE IF EXISTS event_type_id_seq CASCADE;')
            db.drop_all()
            db.create_all()
            db.session.commit()
예제 #28
0
    def setUp(self):
        """
        Clean up pre-existing unittest modelruns and generate new test mr's
        """
        # create a model run and push some meta+data to VW then query files
        self.vwc = default_vw_client()

        modelruns = self.vwc.modelrun_search()
        unittest_uuids = [
            r['Model Run UUID'] for r in modelruns.records
            if 'unittest' in r['Model Run Name']
        ]

        for u in unittest_uuids:
            s = self.vwc.delete_modelrun(u)
            print "pre-test cleanup success on %s: %s" % (u, str(s))

        self.config = _get_config('vwpy/vwpy/test/test.conf')

        self.kwargs = {
            'keywords': 'Snow,iSNOBAL,wind',
            'researcher_name': self.config['Researcher']['researcher_name'],
            'description': 'unittest',
            'model_run_name': 'unittest' + str(uuid4())
        }

        self.mr_uuid = self.vwc.initialize_modelrun(**self.kwargs)
        # for testing purposes set parent to itself to make it the root node
        self.parent_uuid = self.mr_uuid

        # test_filename = 'vwpy/vwpy/test/data/flat_sample.nc'
        test_filename = 'test/data/test1.txt'
        start_datetime = '2010-10-01 00:00:00'
        end_datetime = '2010-10-01 01:00:00'
        self.vwc.upload(self.mr_uuid, test_filename)

        fgdc_md = make_fgdc_metadata(test_filename, self.config, self.mr_uuid,
                                     start_datetime, end_datetime)

        wmd_from_file = metadata_from_file(
            test_filename,
            self.parent_uuid,
            self.mr_uuid,
            'testing file list; file #1 starting at 12am',
            'Dry Creek',
            'Idaho',
            start_datetime=start_datetime,
            end_datetime=end_datetime,
            fgdc_metadata=fgdc_md,
            model_set_type='grid',
            taxonomy='geoimage',
            model_set_taxonomy='grid',
            model_name='isnobal',
            epsg=4326,
            orig_epsg=26911)

        insert_res = self.vwc.insert_metadata(wmd_from_file)

        # give a second for the upload and insert to finish successfully
        time.sleep(1)

        # now insert the second file so we have at least two to test our lists
        # test_filename = 'vwpy/vwpy/test/data/ref_in.nc'
        test_filename = 'test/data/test2.asc'
        start_datetime = '2010-10-01 09:00:00'
        end_datetime = '2010-10-01 10:00:00'
        self.vwc.upload(self.mr_uuid, test_filename)

        fgdc_md = make_fgdc_metadata(test_filename, self.config, self.mr_uuid,
                                     start_datetime, end_datetime)

        wmd_from_file = metadata_from_file(
            test_filename,
            self.parent_uuid,
            self.mr_uuid,
            'testing file list; file #2 starting at 9am',
            'Dry Creek',
            'Idaho',
            start_datetime=start_datetime,
            end_datetime=end_datetime,
            fgdc_metadata=fgdc_md,
            model_set_type='grid',
            model_set='inputs',
            taxonomy='geoimage',
            model_set_taxonomy='grid',
            model_name='isnobal',
            epsg=4326,
            orig_epsg=26911)

        insert_res = self.vwc.insert_metadata(wmd_from_file)

        time.sleep(1)

        # initialize a Flask/Werkzeug test client for making API calls
        self.client = app.test_client()
예제 #29
0
from manage import app

client = app.test_client()


def test_app():
    response = client.get('/')

    assert response.status_code == 200
    assert type(response.data) == bytes
예제 #30
0
    def setUp(self):
        """
        Clean up pre-existing unittest modelruns and generate new test mr's
        """
        # create a model run and push some meta+data to VW then query files
        self.vwc = default_vw_client()

        modelruns = self.vwc.modelrun_search()
        unittest_uuids = [r['Model Run UUID'] for r in modelruns.records
                          if 'unittest' in r['Model Run Name']]

        for u in unittest_uuids:
            s = self.vwc.delete_modelrun(u)
            print "pre-test cleanup success on %s: %s" % (u, str(s))

        self.config = _get_config('vwpy/vwpy/test/test.conf')

        self.kwargs = {
            'keywords': 'Snow,iSNOBAL,wind',
            'researcher_name': self.config['Researcher']['researcher_name'],
            'description': 'unittest',
            'model_run_name': 'unittest' + str(uuid4())
        }

        self.mr_uuid = self.vwc.initialize_modelrun(**self.kwargs)
        # for testing purposes set parent to itself to make it the root node
        self.parent_uuid = self.mr_uuid

        # test_filename = 'vwpy/vwpy/test/data/flat_sample.nc'
        test_filename = 'test/data/test1.txt'
        start_datetime = '2010-10-01 00:00:00'
        end_datetime = '2010-10-01 01:00:00'
        self.vwc.upload(self.mr_uuid, test_filename)

        fgdc_md = make_fgdc_metadata(
            test_filename, self.config, self.mr_uuid, start_datetime,
            end_datetime
        )

        wmd_from_file = metadata_from_file(
            test_filename, self.parent_uuid, self.mr_uuid,
            'testing file list; file #1 starting at 12am', 'Dry Creek',
            'Idaho', start_datetime=start_datetime, end_datetime=end_datetime,
            fgdc_metadata=fgdc_md, model_set_type='grid',
            taxonomy='geoimage', model_set_taxonomy='grid',
            model_name='isnobal', epsg=4326, orig_epsg=26911
        )

        insert_res = self.vwc.insert_metadata(wmd_from_file)

        # give a second for the upload and insert to finish successfully
        time.sleep(1)

        # now insert the second file so we have at least two to test our lists
        # test_filename = 'vwpy/vwpy/test/data/ref_in.nc'
        test_filename = 'test/data/test2.asc'
        start_datetime = '2010-10-01 09:00:00'
        end_datetime = '2010-10-01 10:00:00'
        self.vwc.upload(self.mr_uuid, test_filename)

        fgdc_md = make_fgdc_metadata(
            test_filename, self.config, self.mr_uuid,
            start_datetime, end_datetime
        )

        wmd_from_file = metadata_from_file(
            test_filename, self.parent_uuid, self.mr_uuid,
            'testing file list; file #2 starting at 9am', 'Dry Creek', 'Idaho',
            start_datetime=start_datetime, end_datetime=end_datetime,
            fgdc_metadata=fgdc_md, model_set_type='grid',
            model_set='inputs', taxonomy='geoimage', model_set_taxonomy='grid',
            model_name='isnobal', epsg=4326, orig_epsg=26911
        )

        insert_res = self.vwc.insert_metadata(wmd_from_file)

        time.sleep(1)

        # initialize a Flask/Werkzeug test client for making API calls
        self.client = app.test_client()
예제 #31
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
     self.app = app.test_client()
     db.create_all()
예제 #32
0
    def test_post_invalid_payload(self):
        test_app = app.test_client()
        payload = dict()

        response = test_app.post('/webhook/greenhouse', content_type='application/json', data=json.dumps(payload))
        self.assertEqual(response.status_code, 400)
예제 #33
0
def client():
    app.config['TESTING'] = True
    client = app.test_client()
    yield client
예제 #34
0
 def setUp(self):
     """Set up: Put Flask app in test mode."""
     app.testing = True
     self.app = app.test_client()