當前位置: 首頁>>代碼示例>>Python>>正文


Python Extractor.create方法代碼示例

本文整理匯總了Python中comport.department.models.Extractor.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Extractor.create方法的具體用法?Python Extractor.create怎麽用?Python Extractor.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在comport.department.models.Extractor的用法示例。


在下文中一共展示了Extractor.create方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_extractor_post_triggers_slack_notification

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
    def test_extractor_post_triggers_slack_notification(self, testapp):
        ''' A valid heartbeat post triggers a Slack notification
        '''
        # set up the extractor
        department = Department.create(name="Good Police Department", short_name="GPD", load_defaults=False)
        Extractor.create(username='extractor', email='[email protected]', password="password", department_id=department.id, next_month=10, next_year=2006)

        # set the correct authorization
        testapp.authorization = ('Basic', ('extractor', 'password'))

        # set a fake Slack webhook URL
        fake_webhook_url = 'http://webhook.example.com/'
        current_app.config['SLACK_WEBHOOK_URL'] = fake_webhook_url

        # create a mock to receive POST requests to that URL
        responses.add(responses.POST, fake_webhook_url, status=200)

        # post a sample json object to the heartbeat URL
        testapp.post_json("/data/heartbeat", params={"heartbeat": "heartbeat"})

        # test the captured post payload
        post_body = json.loads(responses.calls[0].request.body)
        assert 'Comport Pinged by Extractor!' in post_body['text']

        # delete the fake Slack webhook URL
        del(current_app.config['SLACK_WEBHOOK_URL'])
        # reset the mock
        responses.reset()
開發者ID:carolynjoneslee,項目名稱:comport,代碼行數:30,代碼來源:test_extractor_api.py

示例2: test_reject_extractor_post_with_wrong_password

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
 def test_reject_extractor_post_with_wrong_password(self, testapp):
     ''' An extractor login with the wrong password is rejected.
     '''
     Extractor.create(username='extractor', email='[email protected]', password="password")
     testapp.authorization = ('Basic', ('extractor', 'drowssap'))
     response = testapp.post("/data/heartbeat", expect_errors=True)
     assert response.status_code == 401
     assert response.text == 'Extractor authorization failed!'
開發者ID:carolynjoneslee,項目名稱:comport,代碼行數:10,代碼來源:test_extractor_api.py

示例3: test_valid_login_replies_with_request

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
    def test_valid_login_replies_with_request(self, testapp):
        right_department = Department.create(name="good2", load_defaults=False)

        Extractor.create(username="good4", email="[email protected]", password="valid", department_id=right_department.id)
        testapp.authorization = ("Basic", ("good4", "valid"))

        res = testapp.post_json("/data/heartbeat", params={"json": "yep"}, expect_errors=True)
        assert res.status_code == 200
開發者ID:webmaven,項目名稱:comport,代碼行數:10,代碼來源:test_extractor_api.py

示例4: test_extractors_are_users

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
    def test_extractors_are_users(self):
        department = DepartmentFactory()
        department.save()

        extractor = Extractor.create(username='foobarbaz', email='[email protected]', department_id=department.id)

        assert extractor.department_id == department.id
開發者ID:webmaven,項目名稱:comport,代碼行數:9,代碼來源:test_user_models.py

示例5: test_successful_extractor_post

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
    def test_successful_extractor_post(self, testapp):
        ''' Send a valid heartbeat post, get a valid response.
        '''
        # set up the extractor
        department = Department.create(name="Good Police Department", short_name="GPD", load_defaults=False)
        Extractor.create(username='extractor', email='[email protected]', password="password", department_id=department.id, next_month=10, next_year=2006)

        # set the correct authorization
        testapp.authorization = ('Basic', ('extractor', 'password'))

        # post a sample json object to the heartbeat URL
        response = testapp.post_json("/data/heartbeat", params={"heartbeat": "heartbeat"})
        # assert that we got the expected response
        assert response.status_code == 200
        assert response.json_body['nextMonth'] == 10
        assert response.json_body['nextYear'] == 2006
        assert response.json_body['received'] == {'heartbeat': 'heartbeat'}
開發者ID:carolynjoneslee,項目名稱:comport,代碼行數:19,代碼來源:test_extractor_api.py

示例6: test_extractors_are_users

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
    def test_extractors_are_users(self):
        department = DepartmentFactory()
        department.save()

        extractor = Extractor.create(username='foobarbaz', email='[email protected]')
        extractor.departments.append(department)
        extractor.save()

        assert extractor.first_department().id == department.id
開發者ID:carolynjoneslee,項目名稱:comport,代碼行數:11,代碼來源:test_user_models.py

示例7: test_bad_extractor_password_is_a_401

# 需要導入模塊: from comport.department.models import Extractor [as 別名]
# 或者: from comport.department.models.Extractor import create [as 別名]
 def test_bad_extractor_password_is_a_401(self, testapp):
     Extractor.create(username="good", email="[email protected]", password="valid")
     testapp.authorization = ("Basic", ("good", "fake"))
     res = testapp.post("/data/heartbeat", expect_errors=True)
     assert res.status_code == 401
開發者ID:webmaven,項目名稱:comport,代碼行數:7,代碼來源:test_extractor_api.py


注:本文中的comport.department.models.Extractor.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。