Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce duplication of fixture SHAs in tests #15610

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chrismytton
Copy link
Contributor

@chrismytton chrismytton commented Feb 21, 2017

What does this do?

This reduces the number of places that we're storing the SHA of the fixtures in the tests.

Why was this needed?

Previously we were storing the SHA in the following places:

  • In the VCR cassettes My mistake, we're not using VCR on this project!
  • In the countries.json fixture
  • In the directory names of the popolo fixtures
  • In the tests themselves, with code like stub_popolo('faa324', 'UK/Commons')

This meant that updating the fixtures to a newer version (which we want to do as part of adding cabinet memberships #24, and probably again when we finalise where that data is going to live), was quite a complicated and hard to script process.

So this change removes the SHA from the fixture directory name and the tests themselves, which should be enough to make updating the fixtures relatively painless.

Relevant Issue(s)

Fixes #15607

Unblocks #15606

Notes to Reviewer

As part of this change I've also switched some places that were still using stub_everypolitician_data_request to use the newer stub_popolo method. I've done this in a separate commit so that can be split off into a separate pull request if preferred.

Having the SHA in the path makes it harder to script updates to the
fixtures and means that the knowledge of the current SHA is duplicated
between `countries.json` and the path.

We do want to track the SHA of the fixtures, but this information is
already in git in the `countries.json` fixture and in the VCR cassettes,
so we don't need to also be tracking it in the directory names in the
fixtures and in the tests themselves.
This removes the SHA argument from the stub_popolo method. We don't want
to couple ourselves to the SHA in too many places, as it makes updating
the test fixtures much harder than it needs to be.
This makes the tests use stub_popolo consistently, whereas before we
were using stub_popolo in some places and
stub_everypolitician_data_request in others.
@tmtmtmtm tmtmtmtm temporarily deployed to everypolitician-viewe-pr-15610 February 21, 2017 16:05 Inactive
We no longer include the SHA in the tests, so this rake task needs to
lookup the current SHA for the requested legislature using the local
`countries.json` file. Then it can use this information to grab the
correct version of the requested file.
@chrismytton
Copy link
Contributor Author

Have popped another commit on the end of this to fix the rake which downloads fixtures. So I think this is actually ready for review now.

@chrismytton
Copy link
Contributor Author

This is needed because the tests are currently using the index_at_known_sha method to access countries and legislatures. This method uses the local countries.json fixture to determine which SHA to use for a given legislature. So even though we can have different legislatures at different SHAs, most of the tests go through countries.json, so will use that SHA for the legislature.

@tmtmtmtm
Copy link
Contributor

@chrismytton I suspect it's probably best if you could resolve all the conflicts before this gets reviewed…

@chrismytton chrismytton removed their assignment Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to update test fixtures
2 participants