from flask import json

from tests import create_authorization_header


def test_get_dvla_organisations(client):
    auth_header = create_authorization_header()

    response = client.get('/dvla_organisations', headers=[auth_header])

    assert response.status_code == 200
    dvla_organisations = json.loads(response.get_data(as_text=True))
    assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}

from flask import json

from tests import create_authorization_header


def test_get_dvla_organisations(client):
    auth_header = create_authorization_header()

    response = client.get('/dvla_organisations', headers=[auth_header])

    assert response.status_code == 200
    dvla_organisations = json.loads(response.get_data(as_text=True))
    assert dvla_organisations['001'] == 'HM Government'
    assert dvla_organisations['500'] == 'Land Registry'

Refactor test so that it does not have to change every time we add a new organisation.
Refactor test so that it does not have to change every time we add a new organisation.

  from flask import json
  
  from tests import create_authorization_header
  
  
  def test_get_dvla_organisations(client):
      auth_header = create_authorization_header()
  
      response = client.get('/dvla_organisations', headers=[auth_header])
  
      assert response.status_code == 200
      dvla_organisations = json.loads(response.get_data(as_text=True))
-     assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
+     assert dvla_organisations['001'] == 'HM Government'
+     assert dvla_organisations['500'] == 'Land Registry'
  
Refactor test so that it does not have to change every time we add a new organisation.
## Code Before:
from flask import json

from tests import create_authorization_header


def test_get_dvla_organisations(client):
    auth_header = create_authorization_header()

    response = client.get('/dvla_organisations', headers=[auth_header])

    assert response.status_code == 200
    dvla_organisations = json.loads(response.get_data(as_text=True))
    assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}

## Instruction:
Refactor test so that it does not have to change every time we add a new organisation.
## Code After:
from flask import json

from tests import create_authorization_header


def test_get_dvla_organisations(client):
    auth_header = create_authorization_header()

    response = client.get('/dvla_organisations', headers=[auth_header])

    assert response.status_code == 200
    dvla_organisations = json.loads(response.get_data(as_text=True))
    assert dvla_organisations['001'] == 'HM Government'
    assert dvla_organisations['500'] == 'Land Registry'
