<commit_before>import json

import responses

from app import tree_controller

treestatus_response = {
  "logs": [
    {
      "reason": "",
      "tags": "",
      "action": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-09T10:42:37"
    },
    {
      "reason": "Infra issues",
      "tags": [
        "infra"
      ],
      "action": "closed",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-09T09:42:06"
    },
    {
      "reason": "",
      "tags": "",
      "action": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T22:30:03"
    },
    {
      "reason": "Too many leaks, not enough fingers",
      "tags": [
        "checkin-test"
      ],
      "action": "closed",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T20:24:20"
    },
    {
      "reason": "",
      "tags": [],
      "action": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T14:39:47"
    },
  ]
}

@responses.activate
def test_we_can_get_tree_closure_status_and_values():
    responses.add(responses.GET, 'https://treestatus.mozilla.org/mozilla-inbound/logs?format=json&all=1',
                  body=json.dumps(treestatus_response), status=200,
                  content_type='application/json', match_querystring=True)
    month, dates, status, status_reason = tree_controller.calculate_closures("mozilla-inbound")

    assert status == 'open'
    assert status_reason == ''
<commit_msg>Fix broken test after moving to releng API<commit_after>import json

import responses

from app import tree_controller

treestatus_response = {
  "result": [
    {
      "reason": "",
      "tags": "",
      "status": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-09T10:42:37+00:00"
    },
    {
      "reason": "Infra issues",
      "tags": [
        "infra"
      ],
      "status": "closed",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-09T09:42:06"
    },
    {
      "reason": "",
      "tags": "",
      "status": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T22:30:03"
    },
    {
      "reason": "Too many leaks, not enough fingers",
      "tags": [
        "checkin-test"
      ],
      "status": "closed",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T20:24:20"
    },
    {
      "reason": "",
      "tags": [],
      "status": "open",
      "tree": "mozilla-inbound",
      "who": "<EMAIL>",
      "when": "2014-08-08T14:39:47"
    },
  ]
}

@responses.activate
def test_we_can_get_tree_closure_status_and_values():
    responses.add(responses.GET, 'https://api.pub.build.mozilla.org/treestatus/trees/mozilla-inbound/logs?all=1',
                  body=json.dumps(treestatus_response), status=200,
                  content_type='application/json', match_querystring=True)
    month, dates, status, status_reason = tree_controller.calculate_closures("mozilla-inbound")

    assert status == 'open'
    assert status_reason == ''
{'fraction_non_alphanumeric': 0.19011406844106463, 'fraction_numerical': 0.048162230671736375, 'mean_word_length': 2.4129729729729728, 'pattern_counts': {'":': 62, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1434753', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1091, 'n_words': 185}