コード例 #1
0
def test_fail_to_fetch_teams(submission_path):
    responses.add(responses.GET,
                  url=urljoin(MOCK_API_URL, '/teams/'),
                  json={},
                  status=404)
    with pytest.raises(ValueError):
        create_submission(1, file=submission_path)
コード例 #2
0
def test_fail_to_fetch_my_tea(submission_path):
    # request success but no teams are matched
    responses.add(responses.GET,
                  url=urljoin(MOCK_API_URL, '/teams/'),
                  json={'results': []},
                  status=200)
    with pytest.raises(ValueError):
        create_submission(1, file=submission_path)
コード例 #3
0
def test_can_submit_by_fail_to_calculation(submission_path):
    responses.add(responses.GET,
                  url=urljoin(MOCK_API_URL, '/teams/'),
                  json={'results': [{
                      'id': 128
                  }]},
                  status=200)

    responses.add(responses.POST,
                  url=urljoin(MOCK_API_URL, '/teams/submissions/'),
                  json={
                      'id': '12345',
                      'succeeded': False
                  },
                  status=201)

    with pytest.raises(ValueError):
        create_submission(1, file=submission_path)
コード例 #4
0
def test_can_submit_by_fail_to_calculation(submission_path, monkeypatch):
    responses.add(responses.GET,
                  url=urljoin(MOCK_API_URL, '/teams/'),
                  json={'results': [{
                      'id': 128
                  }]},
                  status=200)

    responses.add(responses.POST,
                  url=urljoin(MOCK_API_URL, '/teams/submissions/'),
                  json={
                      'id': '12345',
                      'privateScore': .7,
                      'publicScore': .8
                  },
                  status=201)

    def silent(*args, **kwargs):
        return None

    monkeypatch.setattr('guruguru.submissions.show_lb', silent)
    create_submission(1, file=submission_path)
コード例 #5
0
def test_no_username_in_token(monkeypatch, submission_path):
    monkeypatch.setattr('guruguru.constance.config.load',
                        lambda: {'foo': 'bar'})
    with pytest.raises(ValueError):
        create_submission(1, file=submission_path)
コード例 #6
0
def test_not_authorized(submission_path):
    with pytest.raises(NotAuthenticatedError):
        create_submission(1, file=submission_path)