Giter Site home page Giter Site logo

Add unit tests about chess-pipeline HOT 7 CLOSED

guidopetri avatar guidopetri commented on June 24, 2024
Add unit tests

from chess-pipeline.

Comments (7)

guidopetri avatar guidopetri commented on June 24, 2024

The big question here is: how do you do unit tests on a Luigi Task? In the past, I offloaded the actual processing into a method in the Task class, then ran that on some dummy input. However, this seems a little silly and artificial. Could we come up with tests that work directly on a Task's run method?

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Something to look into: Great Expectations, a sort of testing library for your data, apparently.

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Looks like Great Expectations was not really what I was expecting. Haha. I guess what I can do is set up some pytest type framework and just init the Luigi Tasks and then pass custom input into them, then see what their output is. I'd have to make sure the output comes back inside the test, though, and not as a file - or maybe I could actually output it as files and then just verify inside the test by loading the file and seeing what the output is? I'm not exactly sure how this would work so it'll take some experimenting.

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Looks like the best way to do this is by offloading "business logic" into functions that are called by luigi.Tasks, and then test those with a small data sample (probably via pytest?).

I'll keep a list of things I need to offload here, as well as a list of tests to write.

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Functions to write:

  • parse headers fade7ac
  • provisional rating manip ca50eaa
  • sf evaluation filter not sure that this is needed
  • clock time manip 8ce3534
  • FEN manip d7df467
  • all the GetGameInfos dataframe manipulation 32b3861
  • newsletter SQL cfc15e8
  • newsletter tables 20392b0 , f451bef
  • newsletter plots (test the fact that they worked? maybe md5 of saved image?) cdbac9f , df86077

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Tests to write:

  • parse headers 965face
  • provisional rating manip bbbb1b3
  • clock time manip 272f254
  • FEN manip 8223b37
  • all the GetGameInfos dataframe manipulation 05b5fee
  • newsletter SQL c5bce7a
  • newsletter tables 42bb4a8 , eac7e7f
  • newsletter plots (test the fact that they worked? maybe md5 of saved image?) 240b9dd , 8268527
  • visitors 00f5993
  • column queries (mock with a .sqlite somehow?) skipping this for now
  • stockfish evaluation (must fix to a specific version of stockfish) 2b358c9 (testing on stockfish 10 working)
  • sf evaluation filter

from chess-pipeline.

guidopetri avatar guidopetri commented on June 24, 2024

Got most of the tests written that I wanted to. I'm not sure what I meant by "sf evaluation filter" but at some point I'm sure it will come up.

I'm skipping the column query since it would require a more extensive rewrite and would probably require mocking the test with a .sqlite, which is a little bit more complicated than I'm willing to do right now, especially for such a simple SQL query.

Next step is setting up TravisCI or something similar, I guess.

from chess-pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.